/Users/lyon/j4p/src/math/transforms/fft/IFFT1d.java
|
1 package math.transforms.fft;
2
3 //Title: 1-d mixed radix Inverse FFT.
4 //Version:
5 //Copyright: Copyright (c) 1998
6 //Author: Dongyan Wang
7 //Company: University of Wisconsin-Milwaukee.
8 //Description:
9 // According to the definition of the inverse fourier transform,
10 // We can use FFT to calculate the IFFT,
11 // IFFT(x) = 1/N * conj(FFT(conj(x)).
12 //
13 // . Change the sign of the imaginary part of the FFT input.
14 // . Calculate the FFT.
15 // . Change the sign of the imaginary part of the FFT output.
16 // . Scale the output by 1/N.
17 //
18
19
20 public class IFFT1d {
21 int N;
22
23 // Constructor: IFFT of Complex data.
24 public IFFT1d(int N) {
25 this.N = N;
26 }
27
28 public void ifft(float inputRe[], float inputIm[]) {
29
30 // Change the sign of the imaginary part of the FFT input.
31 for (int i = 0; i < N; i++)
32 inputIm[i] = -inputIm[i];
33
34 // Calculate the FFT.
35 FFT1d fft1 = new FFT1d(N);
36 fft1.fft(inputRe, inputIm);
37
38 // Change the sign of the imaginary part of the FFT output.
39 // Scale output by 1/N.
40
41 for (int i = 0; i < inputRe.length; i++) {
42 inputRe[i] = inputRe[i] / N;
43 inputIm[i] = -inputIm[i] / N;
44 }
45 }
46 }
47