### Question:
ArrayOperations { public static double[] convolve(double[] array1, double[] array2) { int n = array1.length + array2.length - 1; double[] result = new double[n]; double[] f = padArrayWithZerosToSize(array1, n); double[] g = padArrayWithZerosToSize(array2, n); int i; int fpos, gpos; for (i = 0; i < result.length; i++) { fpos = 0; gpos = i; for (; fpos <= i && gpos >= 0; fpos++, gpos--) { result[i] += f[fpos] * g[gpos]; } } return result; }  static double[] padArrayWithZerosToSize(double[] array, int newSize); static double[] convolve(double[] array1, double[] array2); static double[] reverse(double[] array); static double[] trimArrayToSize(double[] array, int size); static double[] removeFirstElements(double[] array, int numberOfElements); static Complex[] convertDoubleArrayToComplex(double[] input); static void fillArrayWithValue(double[] array, double value, int startIndex, int endIndex);  }### Answer:
@Test public void testConvolve() { double[] array1; double[] array2; array1 = new double[] {1, 1, 1}; array2 = new double[] {1, 2, 3}; assertArrayEquals(ArrayOperations.convolve(array1, array2), new double[] {1, 3, 6, 5, 3}, 0.01); array1 = new double[] {0.1, 0.6, -5.432, 0.44}; array2 = new double[] {9, -12, -0.33}; assertArrayEquals(ArrayOperations.convolve(array1, array2), new double[] {0.9000, 4.2000, -56.1210, 68.9460, -3.4874, -0.1452}, 0.0001); }