package org.das2.qds.math.fft.jnt;
import org.das2.qds.math.fft.ComplexArray;
/** Computes FFT's of complex, double precision data of arbitrary length n.
* This class uses the Mixed Radix method; it has special methods to handle
* factors 2, 3, 4, 5, 6 and 7, as well as a general factor.
*
* This method appears to be faster than the Radix2 method, when both methods apply,
* but requires extra storage (which ComplexDoubleFFT_Mixed manages itself).
*
* See {@link ComplexDoubleFFT ComplexDoubleFFT} for details of data layout.
*
* @author Bruce R. Miller bruce.miller@nist.gov
* @author Contribution of the National Institute of Standards and Technology,
* @author not subject to copyright.
* @author Derived from GSL (Gnu Scientific Library)
* @author GSL's FFT Code by Brian Gough bjg@vvv.lanl.gov
* @author Since GSL is released under
* @author GPL,
* @author this package must also be.
*/
public class ComplexDoubleFFT_Mixed extends ComplexDoubleFFT{
static final double PI = Math.PI;
public ComplexDoubleFFT_Mixed(int n){
super(n);
setup_wavetable(n);
}
public void transform( ComplexArray.Double data, int i0, int stride) {
checkData(data,i0,stride);
transform_internal(data, i0, stride, -1); }
public void backtransform ( ComplexArray.Double data, int i0, int stride){
checkData(data,i0,stride);
transform_internal(data, i0, stride, +1); }
/*______________________________________________________________________
Setting up the Wavetable */
private int factors[];
// Reversed the last 2 levels of the twiddle array compared to what the C version had.
private double twiddle[][][];
private int available_factors[]={7, 6, 5, 4, 3, 2};
void setup_wavetable(int n){
if (n <= 0)
throw new Error("length must be positive integer : "+n);
this.n = n;
factors = Factorize.factor(n, available_factors);
double d_theta = -2.0 * PI / ((double) n);
int product = 1;
twiddle = new double[factors.length][][];
for (int i = 0; i < factors.length; i++) {
int factor = factors[i];
int product_1 = product; /* product_1 = p_(i-1) */
product *= factor;
int q = n / product;
twiddle[i] = new double[q+1][2*(factor-1)];
double twid[][] = twiddle[i];
for(int j=1; j