BornAgain
1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
|
Fourier transform of vectors (in 1D or 2D) using Fast Fourier Transform (fftw package).
Usage: std::vector<double> signal, result; FourierTransform ft; ft.fft(signal, result)
Given code rely on code from Jeremy Fix page, http://jeremy.fix.free.fr/spip.php?article15, see also "Efficient convolution using the Fast Fourier Transform, Application in C++" by Jeremy Fix, May 30, 2011
Definition at line 36 of file FourierTransform.h.
Classes | |
class | Workspace |
Workspace for Fourier Transform. More... | |
Public Types | |
using | double1d_t = std::vector< double > |
definition of 1D vector of double More... | |
using | double2d_t = std::vector< double1d_t > |
definition of 2D vector of double More... | |
Public Member Functions | |
FourierTransform () | |
void | fft (const double1d_t &source, double1d_t &result) |
FT in 1D. More... | |
void | fft (const double2d_t &source, double2d_t &result) |
FT in 2D. More... | |
void | fftshift (double1d_t &result) const |
Shift low frequency to the center of 1D FT array. More... | |
void | fftshift (double2d_t &result) const |
Shift low frequency to the center of 2D FT array. More... | |
void | init (int h_src, int w_src) |
prepare arrays for 2D Fourier Transformation (FT) of the given vector More... | |
Private Member Functions | |
void | fftw_forward_FT (const double2d_t &src) |
compute FT of source using Fast Fourier transformation from fftw More... | |
Private Attributes | |
Workspace | ws |
input and output data for fftw3 More... | |
using FourierTransform::double1d_t = std::vector<double> |
definition of 1D vector of double
Definition at line 39 of file FourierTransform.h.
using FourierTransform::double2d_t = std::vector<double1d_t> |
definition of 2D vector of double
Definition at line 42 of file FourierTransform.h.
|
default |
void FourierTransform::fft | ( | const double1d_t & | source, |
double1d_t & | result | ||
) |
FT in 1D.
Definition at line 114 of file FourierTransform.cpp.
References ASSERT.
void FourierTransform::fft | ( | const double2d_t & | source, |
double2d_t & | result | ||
) |
FT in 2D.
Definition at line 49 of file FourierTransform.cpp.
References fftw_forward_FT(), FourierTransform::Workspace::h_fftw, init(), FourierTransform::Workspace::out_fftw, FourierTransform::Workspace::w_fftw, and ws.
void FourierTransform::fftshift | ( | double1d_t & | result | ) | const |
Shift low frequency to the center of 1D FT array.
Definition at line 130 of file FourierTransform.cpp.
void FourierTransform::fftshift | ( | double2d_t & | result | ) | const |
Shift low frequency to the center of 2D FT array.
Definition at line 87 of file FourierTransform.cpp.
References FourierTransform::Workspace::h_fftw, and ws.
|
private |
compute FT of source using Fast Fourier transformation from fftw
Definition at line 174 of file FourierTransform.cpp.
References ASSERT, FourierTransform::Workspace::h_fftw, FourierTransform::Workspace::h_src, FourierTransform::Workspace::in_src, FourierTransform::Workspace::out_fftw, FourierTransform::Workspace::p_forw_src, FourierTransform::Workspace::w_fftw, FourierTransform::Workspace::w_src, and ws.
Referenced by fft().
void FourierTransform::init | ( | int | h_src, |
int | w_src | ||
) |
prepare arrays for 2D Fourier Transformation (FT) of the given vector
Definition at line 145 of file FourierTransform.cpp.
References ASSERT, FourierTransform::Workspace::clear(), FourierTransform::Workspace::h_fftw, FourierTransform::Workspace::h_src, FourierTransform::Workspace::in_src, FourierTransform::Workspace::out_fftw, FourierTransform::Workspace::p_forw_src, FourierTransform::Workspace::w_fftw, FourierTransform::Workspace::w_src, and ws.
Referenced by fft().
|
private |
input and output data for fftw3
Definition at line 91 of file FourierTransform.h.
Referenced by fft(), fftshift(), fftw_forward_FT(), and init().