jnt.FFT.ComplexFloatFFT_Mixed Maven / Gradle / Ivy
Show all versions of sspace Show documentation
package jnt.FFT;
/** Computes FFT's of complex, single 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 ComplexFloatFFT ComplexFloatFFT} for details of data layout.
*
* @author Bruce R. Miller [email protected]
* @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 [email protected]
* @author Since GSL is released under
* @author GPL,
* @author this package must also be.
*/
public class ComplexFloatFFT_Mixed extends ComplexFloatFFT{
static final double PI = (float) Math.PI;
static final int FORWARD = -1;
static final int BACKWARD = +1;
public ComplexFloatFFT_Mixed(int n){
super(n);
setup_wavetable(n);
}
public void transform(float data[], int i0, int stride) {
checkData(data,i0,stride);
transform_internal(data, i0, stride, FORWARD); }
public void backtransform (float data[], int i0, int stride){
checkData(data,i0,stride);
transform_internal(data, i0, stride, BACKWARD); }
/*______________________________________________________________________
Setting up the Wavetable */
private int factors[];
// Reversed the last 2 levels of the twiddle array compared to what the C version had.
private float 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 float[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 float[q+1][2*(factor-1)];
float twid[][] = twiddle[i];
for(int j=1; j