//
// Code borrowed from :Java Digital Signal Processing book by Lyon and Rao
- public Matrix data1, data2;
+ public Matrix data1;
public int x0, x1;
// Constructor: 2-d FFT of Complex data.
- public fft2d(Matrix data1, Matrix data2, int x0, int x1) {
+ public fft2d(Matrix data1, int x0, int x1) {
this.data1 = data1;
- this.data2 = data2;
this.x0 = x0;
this.x1 = x1;
}
double inputIm[] = tempdataIm[i];
fft(fft1, inputRe, inputIm);
} //end of for
-
// Tranpose data.
if (start == 0) {
- transpose(tempdataRe,tempdataIm, data2.dataRe,data2.dataIm, rowlength, columnlength);
+ transpose(tempdataRe,tempdataIm, rowlength, columnlength);
}
// Calculate FFT for each column of the data.
double transtempRe[][];
double transtempIm[][];
- transtempRe = data2.dataRe;
- transtempIm = data2.dataIm;
+ transtempRe = data1.dataRe;
+ transtempIm = data1.dataIm;
for (int j = start; j < end; j++) {
//input of FFT
double inputRe[] = transtempRe[j]; //local array
} //end of fft2 for
} //end of run
- public void transpose(double[][] tempdataRe, double[][] tempdataIm, double[][] outputRe,
- double[][] outputIm, int rowlength, int columnlength) {
+ public void transpose(double[][] tempdataRe, double[][] tempdataIm, int rowlength, int columnlength) {
for(int i = 0; i<rowlength; i++) {
double tRe[] = tempdataRe[i];
double tIm[] = tempdataIm[i];
- for(int j = 0; j<columnlength; j++) {
- outputRe[j][i] = tRe[j];
- outputIm[j][i] = tIm[j];
+ double a;
+ for(int j = 0; j<i; j++) {
+ a=tempdataRe[j][i];
+ tempdataRe[j][i] = tRe[j];
+ tRe[j]=a;
+ a=tempdataIm[j][i];
+ tempdataIm[j][i] = tIm[j];
+ tIm[j]=a;
}
}
}
System.printString("Num threads = " + NUM_THREADS + " SIZE= " + SIZE + "\n");
Matrix data1;
- Matrix data2;
// Create threads to do FFT
fft2d[] myfft2d;
// Set up data for FFT transform
data1 = new Matrix(SIZE, SIZE);
- data2 = new Matrix(SIZE, SIZE);
data1.setValues(); //Input Matrix
- data2.setZeros(); //Transpose Matrix
myfft2d = new fft2d[NUM_THREADS];
int increment = SIZE/NUM_THREADS;
int base = 0;
for(int i =0 ; i<NUM_THREADS; i++) {
if((i+1)==NUM_THREADS)
- myfft2d[i] = new fft2d(data1, data2, base, SIZE);
+ myfft2d[i] = new fft2d(data1, base, SIZE);
else
- myfft2d[i] = new fft2d(data1, data2, base, base+increment);
+ myfft2d[i] = new fft2d(data1, base, base+increment);
base+=increment;
}