JTransformsWrapper { public static ComplexNumber[] transform1DReal(final double[] h) { ArgumentChecker.notEmpty(h, "array of doubles"); final int n = h.length; final double[] a = Arrays.copyOf(h, n); DoubleFFT_1D fft = CACHE_1D.get(n); if (fft == null) { fft = new DoubleFFT_1D(n); CACHE_1D.put(n, fft); } fft.realForward(a); return unpack(a); }  static ComplexNumber[] transform1DComplex(final ComplexNumber[] z); static ComplexNumber[] inverseTransform1DComplex(final ComplexNumber[] z, final boolean scale); static ComplexNumber[] fullTransform1DReal(final double[] h); static ComplexNumber[] fullInverseTransform1DReal(final double[] x, final boolean scale); static ComplexNumber[] transform1DReal(final double[] h); static ComplexNumber[] inverseTransform1DReal(final double[] x, final boolean scale);  }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNull5() { JTransformsWrapper.transform1DReal(null); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testEmpty5() { JTransformsWrapper.transform1DReal(new double[0]); }
@Test public void testParsevalsTheorem() { final ComplexNumber[] transform = JTransformsWrapper.transform1DReal(A); final int n = A.length; double sum1 = 0; double sum2 = 0; for (int i = 0; i < n; i++) { sum1 += A[i] * A[i]; } for (final ComplexNumber element : transform) { final double temp = ComplexMathUtils.mod(element); sum2 += temp * temp; } sum2 *= 2.0; sum2 /= n; assertEquals(1.0, sum1 / sum2, 1e-2); }
@Test public void testGauss() { final ComplexNumber[] transform = JTransformsWrapper.transform1DReal(G); final int n = transform.length; assertEquals(N / 2, n - 1, 0); final double deltaOmega = 2 * Math.PI / N / DELTAX; double omega; for (int i = 0; i < n; i++) { omega = i * deltaOmega; final ComplexNumber scale = ComplexMathUtils.multiply(DELTAX, ComplexMathUtils.exp(new ComplexNumber(0.0, omega * X_MIN))); final ComplexNumber res = ComplexMathUtils.multiply(scale, transform[i]); assertComplexEquals(GAUSS_TRANSFORM.evaluate(new ComplexNumber(omega)), res); } }