You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sambit Paul edited this page Dec 2, 2023
·
14 revisions
Forward Fourier Transform
We apply the Discrete Fourier Transform to decompose the signal and represent it as a sum of periodic components. On decomposition we get a real component and an imaginary component. For DFT on real signals, the frequencies are mirrored around the centre.
In this library, we are able to get all 4 variations:
Only Magnitude
Only Phase (in Radians/Degrees)
Magnitude and Phase (in Radians/Degrees)
Complex Signal
The examples provided here use this signal:
$\sin(40\pi t) + \frac{1}{2}\sin(400\pi t)$
CODE
_Fourier dft = new DiscreteFourier(signal); //Works well for short signals (<200 points)
OR
_Fourier dft = new FastFourier(signal); //Works well for longer signals (>200 points)
dft.transform();
CODE
boolean onlyPositive = true;
double[] out = dft.getMagnitude(onlyPositive); //Positive Absolute
boolean onlyPositive = true;
double[][] out = dft.getComplex2D(onlyPositive); //Positive Complex
boolean onlyPositive = false;
double[] out = dft.getMagnitude(onlyPositive); //Full Absolute
boolean onlyPositive = false;
double[][] out = dft.getComplex2D(onlyPositive); //Full Complex
Inverse Fourier Transform
We apply the Inverse Discrete Fourier Transform to a complex sequence to reconstruct the original signal. This process also generate a signal with a real and an imaginary component.
In this library, the IDFT works in 2 modes:
For a real sequence
For a complex sequence
In the examples provided here the source signal is:
$\sin(40\pi t) + \frac{1}{2}\sin(400\pi t)$
CODE
// Automatically detects real and complex sequence and performs IDFT accordingly
_InverseFourier idft = new InverseDiscreteFourier(complexSequence); //When DFT is performed using DiscreteFourier
OR
_InverseFourier idft = new InverseFastFourier(complexSequence); //When DFT is performed using FasrFourier
idft.transform();
CODE
double[] outReal = idft.getReal(); //To get only the real component
double[] outAbsolute = idft.getMagnitude(); //To get the absolute value of the complex signal
double[][] out = idft.getComplex2D(); // To get the complex signal
The image shows the plot of the complex output. As you can see, the real component represents the original signal: $\sin(40\pi t) + \frac{1}{2}\sin(400\pi t)$