package lab4; /** * @author Timmy * */ /** * @author Timmy * */ public class ArrayStatic { private int initialize; private static int init = 0; /** * Name: dotProduct * PreCondition: arrays are not null * arrays are the same size * PostCondition: Returns the calculated dot product * @params vec1 - contains a vector to perform dot product with * @params vec2 - contains a vector to perform dot product with */ public static double dotProduct(double vec1[], double vec2[]) { /*Step 1: comment the following call (making a static reference to a non-static field) * */ initialize = 0; double value = init; int length = vec1.length; for (int i = 0; i < length; i++) { value += vec1[i] * vec2[i]; } return value; } /** * Name: copyArray * PreCondition: array is not null * PostCondition: Returns copy of the array * @params vec - contains a vector to copy */ public static double[] copyArray(double vector[]) { /* Step 2: Make a deep copy of the array passed * First find the length of the array, allocate memory for * the new array. Then perform the actual copy of elements. * The logic is similar to the one you used in * ArrayInstance class. */ } }