23 using std::ostringstream;
54 string myname =
"printData: ";
55 Index nrow = dat.nSamples()[0];
56 Index ncol = dat.nSamples()[1];
58 Index& irow = ifrqs[0];
59 Index& icol = ifrqs[1];
60 for ( irow=0; irow<nrow; ++irow ) {
61 for ( icol=0; icol<ncol; ++icol ) {
63 cout <<
setw(4) << irow;
64 cout <<
setw(4) << icol;
74 string myname =
"printData: ";
75 assert( dat1.nSamples() == dat2.nSamples() );
76 Index nrow = dat1.nSamples()[0];
77 Index ncol = dat1.nSamples()[1];
79 Index& irow = ifrqs[0];
80 Index& icol = ifrqs[1];
82 for ( irow=0; irow<nrow; ++irow ) {
83 for ( icol=0; icol<ncol; ++icol ) {
85 cout <<
setw(4) << irow;
86 cout <<
setw(4) << icol;
87 float val1 = dat1.value(ifrqs);
88 float val2 = dat2.value(ifrqs);
93 if ( fabs(val2 - val1) > 0.001 ) {
106 const string myname =
"test_Fw2dFFT: ";
108 cout << myname <<
"NDEBUG must be off." <<
endl;
111 string line =
"-----------------------------";
114 cout << line <<
endl;
115 cout << myname <<
" Global norm: " << ignorm <<
" " << norm.
globalName() <<
endl;
116 cout << myname <<
" Term norm: " << itnorm <<
" " << norm.
termName() <<
endl;
118 cout << myname << line <<
endl;
119 cout << myname <<
"Create data." <<
endl;
123 Index ndft = 2*n0*(n1/2 + 1);
125 2.0, 3.0, 2.0, 1.0, 0.0, -1.0, -2.0, -3.0, -2.0, -1.0,
126 0.0, 1.0, 2.0, 3.0, 2.0, 1.0, 0.0, -1.0, -2.0, -3.0,
127 3.0, 6.0, 16.1, 28.6, 30.2, 27.7, 16.3, 9.6, 4.2, -1.0,
128 -2.3, -4.2, -9.2, -18.6, -21.9, -29.0, -24.3, -14.2, -5.0, -3.0,
129 -2.0, -3.0, -2.0, -1.0, 0.0, 1.0, 2.0, 3.0, 2.0, 1.0,
130 0.0, -1.0, -2.0, -3.0, -2.0, -1.0, 0.0, 1.0, 2.0, 3.0
132 assert( sams.size() == nsam );
133 cout << myname <<
"Sample length: " << nsam <<
endl;
135 for (
float sam : sams ) samsum +=
sam;
136 cout << myname <<
"Sample mean: " << samsum/nsam <<
endl;
137 cout << myname <<
" n0: " << n0 <<
endl;
138 cout << myname <<
" n1: " << n1 <<
endl;
139 cout << myname <<
" # samples: " << nsam <<
endl;
140 cout << myname <<
" # DFT: " << ndft <<
endl;
142 cout << myname << line <<
endl;
143 cout << myname <<
"Create the sample counts." <<
endl;
148 cout << myname << line <<
endl;
149 cout << myname <<
"Create data." <<
endl;
151 cout << myname <<
" Rank: " << dat.rank() <<
endl;
152 cout << myname <<
" Size: " << dat.
size() <<
endl;
153 assert( dat.isValid() );
155 assert( dat.
size() == nsam );
157 cout << myname << line <<
endl;
158 cout << myname <<
"Create an empty DFT." <<
endl;
160 assert( dft.
dataSize(nsams) == nsam );
164 cout << myname << line <<
endl;
165 cout << myname <<
"Build transform." <<
endl;
168 cout << myname << line <<
endl;
169 cout << myname <<
"Build plans." <<
endl;
177 cout << myname << line <<
endl;
178 cout << myname <<
"Transform forward." <<
endl;
180 assert( fstat == 0 );
183 cout << myname << line <<
endl;
184 cout << myname <<
"Transform backward." <<
endl;
187 assert( bstat == 0 );
235 cout << myname << line <<
endl;
236 cout << myname <<
"Done." <<
endl;
247 string sarg(argv[1]);
248 if ( sarg ==
"-h" ) {
249 cout <<
"Usage: " << argv[0] <<
" [ignorm [itnorm [loglev]]]" <<
endl;
252 ignorm = std::stoi(sarg);
255 string sarg(argv[2]);
256 itnorm = std::stoi(sarg);
259 string sarg(argv[3]);
260 loglev = std::stoi(sarg);
std::vector< DataFloat > DataVector
std::array< Index, 2 > IndexArray
Real2dData< DataFloat > Data
int fftForward(const Data &dat, DFT &dft, Index logLevel=0)
int main(int argc, char *argv[])
void printData(const Data &dat)
Fw2dFFT::DataFloat DataFloat
std::string termName() const
Plan & backwardPlan(const IndexArray &nsams)
DftData::IndexArray IndexArray
Q_EXPORT QTSManip setprecision(int p)
FftwReal2dDftData< DftFloat > DFT
int fftBackward(const DFT &dft, Data &dat, Index logLevel=0)
static Index dataSize(const std::array< Index, N > &nsams)
Plan & forwardPlan(const IndexArray &nsams)
auto norm(Vector const &v)
Return norm of the specified vector.
Q_EXPORT QTSManip setw(int w)
bool haveForwardPlan(const IndexArray &nsams) const
static Index dftFloatDataSize(const std::array< Index, N > &nsams)
void line(double t, double *p, double &x, double &y, double &z)
int test_Fw2dFFT(Index ignorm, Index itnorm, int loglev)
bool haveBackwardPlan(const IndexArray &nsams) const
std::string globalName() const
QTextStream & endl(QTextStream &s)