32#include "vtkCommonMathModule.h"
36#include "vtk_kissfft.h"
38#include VTK_KISSFFT_HEADER(kiss_fft.h)
39#include VTK_KISSFFT_HEADER(tools/kiss_fftr.h)
63 static std::vector<ComplexNumber>
Fft(
const std::vector<ComplexNumber>& in);
64 static std::vector<ComplexNumber>
Fft(
const std::vector<ScalarNumber>& in);
73 static std::vector<ComplexNumber>
RFft(
const std::vector<ScalarNumber>& in);
85 static std::vector<ComplexNumber>
IFft(
const std::vector<ComplexNumber>& in);
95 static std::vector<ScalarNumber>
IRFft(
const std::vector<ComplexNumber>& in);
110 static std::vector<double>
FftFreq(
int windowLength,
double sampleSpacing);
116 static std::vector<double>
RFftFreq(
int windowLength,
double sampleSpacing);
130 static inline double HanningGenerator(
const std::size_t x,
const std::size_t
size);
131 static inline double BartlettGenerator(
const std::size_t x,
const std::size_t
size);
132 static inline double SineGenerator(
const std::size_t x,
const std::size_t
size);
133 static inline double BlackmanGenerator(
const std::size_t x,
const std::size_t
size);
134 static inline double RectangularGenerator(
const std::size_t x,
const std::size_t
size);
141 template <
typename Array1D>
142 static void GenerateKernel1D(Array1D* kernel,
const std::size_t n,
WindowGenerator generator);
148 template <
typename Array2D>
149 static void GenerateKernel2D(
150 Array2D* kernel,
const std::size_t n,
const std::size_t m,
WindowGenerator generator);
158 void operator=(
const vtkFFT&) =
delete;
164 return std::sqrt(in.r * in.r + in.i * in.i);
170 return in.r * in.r + in.i * in.i;
182 return 2.0 * x / (
size - 1);
205template <
typename Array1D>
208 const std::size_t half = (n / 2) + (n % 2);
209 for (std::size_t i = 0; i < half; ++i)
211 kernel[i] = kernel[n - 1 - i] = generator(i, n);
216template <
typename Array2D>
218 Array2D* kernel,
const std::size_t n,
const std::size_t m,
WindowGenerator generator)
220 const std::size_t halfX = (n / 2) + (n % 2);
221 const std::size_t halfY = (m / 2) + (m % 2);
222 for (std::size_t i = 0; i < halfX; ++i)
224 for (std::size_t j = 0; j < halfY; ++j)
228 = kernel[n - 1 - i][j]
229 = kernel[i][m - 1 - j]
230 = kernel[n - 1 - i][m - 1 - j]
231 = generator(i, n) * generator(j, m);
perform Discrete Fourier Transforms
static double BlackmanGenerator(const std::size_t x, const std::size_t size)
static std::vector< double > RFftFreq(int windowLength, double sampleSpacing)
Return the DFT sample frequencies for the real version of the dft (see Rfft).
static double RectangularGenerator(const std::size_t x, const std::size_t size)
kiss_fft_scalar ScalarNumber
static void GenerateKernel1D(Array1D *kernel, const std::size_t n, WindowGenerator generator)
Given a window generator function, create a symmetric 1D kernel.
static std::vector< ScalarNumber > IRFft(const std::vector< ComplexNumber > &in)
Compute the inverse of RFft.
static double SquaredAbs(const ComplexNumber &in)
Return the squared absolute value of the complex number.
static std::vector< ComplexNumber > Fft(const std::vector< ScalarNumber > &in)
double(*)(const std::size_t, const std::size_t) WindowGenerator
Window generator functions.
static double HanningGenerator(const std::size_t x, const std::size_t size)
static std::vector< ComplexNumber > Fft(const std::vector< ComplexNumber > &in)
Compute the one-dimensional DFT for complex input.
~vtkFFT() override=default
static double BartlettGenerator(const std::size_t x, const std::size_t size)
static void GenerateKernel2D(Array2D *kernel, const std::size_t n, const std::size_t m, WindowGenerator generator)
Given a window generator function, create a symmetric 2D kernel.
static double Abs(const ComplexNumber &in)
Return the absolute value (also known as norm, modulus, or magnitude) of complex number.
static std::vector< ComplexNumber > RFft(const std::vector< ScalarNumber > &in)
Compute the one-dimensional DFT for real input.
kiss_fft_cpx ComplexNumber
static std::vector< double > FftFreq(int windowLength, double sampleSpacing)
Return the DFT sample frequencies.
static std::vector< ComplexNumber > IFft(const std::vector< ComplexNumber > &in)
Compute the inverse of Fft.
static double SineGenerator(const std::size_t x, const std::size_t size)
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
a simple class to control print indentation
static constexpr double Pi()
A mathematical constant.
abstract base class for most VTK objects