fft
Functions
-
int main(int argc, char *argv[])
fft [ option ] [ infile ]
-l int
FFT length \((1 \le L)\)
-m int
order of sequence \((0 \le M < L)\)
-o int
output format
0
real and imaginary parts1
real part2
imaginary part3
amplitude spectrum4
power spectrum
infile str
double-type data sequence
stdout
double-type FFT sequence
The below example analyzes a sine wave using Blackman window by padding imaginary part with zeros.
sin -p 30 -l 256 | window -L 512 | fft -o 3 > sine.spec
- Parameters:
argc – [in] Number of arguments.
argv – [in] Argument vector.
- Returns:
0 on success, 1 on failure.
-
class FastFourierTransform
Calculate FFT of complex-valued input data.
The inputs are \(M\)-th order complex-valued data:
\[\begin{split} \begin{array}{cccc} \mathrm{Re}(x(0)), & \mathrm{Re}(x(1)), & \ldots, & \mathrm{Re}(x(M)), \\ \mathrm{Im}(x(0)), & \mathrm{Im}(x(1)), & \ldots, & \mathrm{Im}(x(M)). \end{array} \end{split}\]The outputs are\[\begin{split} \begin{array}{cccc} \mathrm{Re}(X(0)), & \mathrm{Re}(X(1)), & \ldots, & \mathrm{Re}(X(L-1)), \\ \mathrm{Im}(X(0)), & \mathrm{Im}(X(1)), & \ldots, & \mathrm{Im}(X(L-1)), \end{array} \end{split}\]where \(L\) is the FFT length and must be a power of two.Public Functions
-
explicit FastFourierTransform(int fft_length)
- Parameters:
fft_length – [in] FFT length, \(L\).
-
FastFourierTransform(int num_order, int fft_length)
- Parameters:
num_order – [in] Order of input, \(M\).
fft_length – [in] FFT length, \(L\).
-
inline int GetNumOrder() const
- Returns:
Order of input.
-
inline int GetFftLength() const
- Returns:
FFT length.
-
inline bool IsValid() const
- Returns:
True if this object is valid.
-
bool Run(const std::vector<double> &real_part_input, const std::vector<double> &imag_part_input, std::vector<double> *real_part_output, std::vector<double> *imag_part_output) const
- Parameters:
real_part_input – [in] \(M\)-th order real part of input.
imag_part_input – [in] \(M\)-th order imaginary part of input.
real_part_output – [out] \(L\)-length real part of output.
imag_part_output – [out] \(L\)-length imaginary part of output.
- Returns:
True on success, false on failure.
-
bool Run(std::vector<double> *real_part, std::vector<double> *imag_part) const
- Parameters:
real_part – [inout] Real part.
imag_part – [inout] Imaginary part.
- Returns:
True on success, false on failure.
-
explicit FastFourierTransform(int fft_length)