FastFourierTransformer implements Serializable { @Deprecated public Object mdfft(Object mdca, TransformType type) { MultiDimensionalComplexMatrix mdcm = (MultiDimensionalComplexMatrix) new MultiDimensionalComplexMatrix(mdca).clone(); int[] dimensionSize = mdcm.getDimensionSizes(); for (int i = 0; i < dimensionSize.length; i++) { mdfft(mdcm, type, i, new int[0]); } return mdcm.getArray(); } FastFourierTransformer(final DftNormalization normalization); static void transformInPlace(final double[][] dataRI,
        final DftNormalization normalization, final TransformType type); Complex[] transform(final double[] f, final TransformType type); Complex[] transform(final UnivariateFunction f,
                               final double min, final double max, final int n,
                               final TransformType type); Complex[] transform(final Complex[] f, final TransformType type); @Deprecated Object mdfft(Object mdca, TransformType type);  }
@Test public void test2DData() { FastFourierTransformer transformer; transformer = new FastFourierTransformer(DftNormalization.STANDARD); double tolerance = 1E-12; Complex[][] input = new Complex[][] {new Complex[] {new Complex(1, 0), new Complex(2, 0)}, new Complex[] {new Complex(3, 1), new Complex(4, 2)}}; Complex[][] goodOutput = new Complex[][] {new Complex[] {new Complex(5, 1.5), new Complex(-1, -.5)}, new Complex[] {new Complex(-2, -1.5), new Complex(0, .5)}}; for (int i = 0; i < goodOutput.length; i++) { TransformUtils.scaleArray( goodOutput[i], FastMath.sqrt(goodOutput[i].length) * FastMath.sqrt(goodOutput.length)); } Complex[][] output = (Complex[][])transformer.mdfft(input, TransformType.FORWARD); Complex[][] output2 = (Complex[][])transformer.mdfft(output, TransformType.INVERSE); Assert.assertEquals(input.length, output.length); Assert.assertEquals(input.length, output2.length); Assert.assertEquals(input[0].length, output[0].length); Assert.assertEquals(input[0].length, output2[0].length); Assert.assertEquals(input[1].length, output[1].length); Assert.assertEquals(input[1].length, output2[1].length); for (int i = 0; i < input.length; i++) { for (int j = 0; j < input[0].length; j++) { Assert.assertEquals(input[i][j].getImaginary(), output2[i][j].getImaginary(), tolerance); Assert.assertEquals(input[i][j].getReal(), output2[i][j].getReal(), tolerance); Assert.assertEquals(goodOutput[i][j].getImaginary(), output[i][j].getImaginary(), tolerance); Assert.assertEquals(goodOutput[i][j].getReal(), output[i][j].getReal(), tolerance); } } }
@Test public void test2DDataUnitary() { FastFourierTransformer transformer; transformer = new FastFourierTransformer(DftNormalization.UNITARY); double tolerance = 1E-12; Complex[][] input = new Complex[][] {new Complex[] {new Complex(1, 0), new Complex(2, 0)}, new Complex[] {new Complex(3, 1), new Complex(4, 2)}}; Complex[][] goodOutput = new Complex[][] {new Complex[] {new Complex(5, 1.5), new Complex(-1, -.5)}, new Complex[] {new Complex(-2, -1.5), new Complex(0, .5)}}; Complex[][] output = (Complex[][])transformer.mdfft(input, TransformType.FORWARD); Complex[][] output2 = (Complex[][])transformer.mdfft(output, TransformType.INVERSE); Assert.assertEquals(input.length, output.length); Assert.assertEquals(input.length, output2.length); Assert.assertEquals(input[0].length, output[0].length); Assert.assertEquals(input[0].length, output2[0].length); Assert.assertEquals(input[1].length, output[1].length); Assert.assertEquals(input[1].length, output2[1].length); for (int i = 0; i < input.length; i++) { for (int j = 0; j < input[0].length; j++) { Assert.assertEquals(input[i][j].getImaginary(), output2[i][j].getImaginary(), tolerance); Assert.assertEquals(input[i][j].getReal(), output2[i][j].getReal(), tolerance); Assert.assertEquals(goodOutput[i][j].getImaginary(), output[i][j].getImaginary(), tolerance); Assert.assertEquals(goodOutput[i][j].getReal(), output[i][j].getReal(), tolerance); } } }