/** * Constructs an FFT for the specified 2D array of values. * Spatial dimensions are determined from the dimensions of the * specified array. Spatial sampling intervals are 1.0, and first * sample coordinates are 0.0. * @param complex true, for complex values; false, for real values. * @param f an array with dimensions like those to be transformed. */ public Fft(boolean complex, float[][] f) { this(f[0].length/2,f.length); setComplex(complex); }
/** * Constructs an FFT for the specified 1D array of values. * Spatial dimensions are determined from the dimensions of the * specified array. Spatial sampling intervals are 1.0, and first * sample coordinates are 0.0. * @param complex true, for complex values; false, for real values. * @param f an array with dimensions like those to be transformed. */ public Fft(boolean complex, float[] f) { this(f.length/2); setComplex(complex); }
/** * Constructs an FFT for the specified 3D array of values. * Spatial dimensions are determined from the dimensions of the * specified array. Spatial sampling intervals are 1.0, and first * sample coordinates are 0.0. * @param complex true, for complex values; false, for real values. * @param f an array with dimensions like those to be transformed. */ public Fft(boolean complex, float[][][] f) { this(f[0][0].length/2,f[0].length,f.length); setComplex(complex); }
private void test1( boolean complex, boolean overwrite, boolean center, int padding, int n1, double d1, double f1) { if (n1<=0) return; Sampling s1 = new Sampling(n1,d1,f1); Fft fft = new Fft(s1); fft.setComplex(complex); fft.setOverwrite(overwrite); fft.setCenter(center); fft.setPadding(padding); float[] f = (complex)?crandfloat(n1):randfloat(n1); float[] g = fft.applyForward(f); float[] h = fft.applyInverse(g); if (complex) assertComplexEqual(n1,f,h); else assertRealEqual(n1,f,h); } private void test2(
private void test2( boolean complex, boolean overwrite, boolean center1, boolean center2, int padding1, int padding2, int n1, double d1, double f1, int n2, double d2, double f2) { if (n1<=0 || n2<=0) return; Sampling s1 = new Sampling(n1,d1,f1); Sampling s2 = new Sampling(n2,d2,f2); Fft fft = new Fft(s1,s2); fft.setComplex(complex); fft.setOverwrite(overwrite); fft.setCenter1(center1); fft.setCenter2(center2); fft.setPadding1(padding1); fft.setPadding2(padding2); float[][] f = (complex)?crandfloat(n1,n2):randfloat(n1,n2); float[][] g = fft.applyForward(f); float[][] h = fft.applyInverse(g); if (complex) assertComplexEqual(n1,n2,f,h); else assertRealEqual(n1,n2,f,h); } private void test3(
private void test3( boolean complex, boolean overwrite, boolean center1, boolean center2, boolean center3, int padding1, int padding2, int padding3, int n1, double d1, double f1, int n2, double d2, double f2, int n3, double d3, double f3) { if (n1<=0 || n2<=0 || n3<=0) return; Sampling s1 = new Sampling(n1,d1,f1); Sampling s2 = new Sampling(n2,d2,f2); Sampling s3 = new Sampling(n3,d3,f3); Fft fft = new Fft(s1,s2,s3); fft.setComplex(complex); fft.setOverwrite(overwrite); fft.setCenter1(center1); fft.setCenter2(center2); fft.setCenter3(center3); fft.setPadding1(padding1); fft.setPadding2(padding2); fft.setPadding3(padding3); float[][][] f = (complex)?crandfloat(n1,n2,n3):randfloat(n1,n2,n3); float[][][] g = fft.applyForward(f); float[][][] h = fft.applyInverse(g); if (complex) assertComplexEqual(n1,n2,n3,f,h); else assertRealEqual(n1,n2,n3,f,h); }