20 cout <<
"=== FT: one-dimensional Fourier Transform (slow) ====\n";
24 const double xMax(20);
32 for ( std::size_t i = 0; i < N; ++i ) {
34 h(i,0) = 1./(1+(xNodes[i]-0)*(xNodes[i]-0))
35 +
D_complex(0.,1.)/(1+(xNodes[i]-4)*(xNodes[i]-4));
37 h(i,1) = sin(xNodes[i]);
43 testft.
dump_gnu(
"./DATA/testft.dat");
68 for ( std::size_t i = 0; i < N; ++i ) {
69 h(i,0) -= hReconstructed(i,0);
70 h(i,1) -= hReconstructed(i,1);
74 if ( max(
h.max_abs(0),
h.max_abs(1)) < 1.e-12 ) {
75 cout <<
"\033[1;32;48m * PASSED \033[0m\n";
78 cout <<
"\033[1;31;48m * FAILED \033[0m\n";
79 cout <<
" Final |error| = " <<
h.max_abs(0) <<
"\n";
A spec for a collection of Fourier methods that act on Noddy containers.
A specification for a one dimensional mesh object.
A spec for a collection of utility functions.
An DenseVector class – a dense vector object.
A one dimensional mesh utility object.
void dump_gnu(std::string filename, int precision=10) const
A simple method for dumping data to a file for gnuplot.
OneD_Node_Mesh< D_complex > dft(const OneD_Node_Mesh< D_complex > &f)
(Slow) DFT of the real data (x_i,f_i), i = 0, ... N-1; N must be EVEN.
OneD_Node_Mesh< D_complex > dft_with_shift(const OneD_Node_Mesh< D_complex > &f)
A wrapper that calls the 'dft' method above followed by the 'shift' method.
OneD_Node_Mesh< D_complex > idft_with_ishift(const OneD_Node_Mesh< D_complex > &ft, double origin=0)
A wrapper that calls the 'ishift' method above followed by the 'idft' method.
OneD_Node_Mesh< D_complex > shift(const OneD_Node_Mesh< D_complex > &ft)
Shift the frequency spectrum obtained from dft to give positive and negative freq.
OneD_Node_Mesh< D_complex > idft(const OneD_Node_Mesh< D_complex > &ft, double origin=0)
(Slow) Inverse DFT of the complex data (omega_i,F_i), i = 0,...,N-1; N must be EVEN.
DenseVector< double > uniform_node_vector(const double &lower, const double &upper, const std::size_t &N)
Return a DENSE vector with the nodal points of a uniform mesh distributed between the upper/lower bou...
A collection of OO numerical routines aimed at simple (typical) applied problems in continuum mechani...
std::complex< double > D_complex
A complex double precision number using std::complex.