37 const string myname =
"test_FftwReal2dDftData: ";
39 cout << myname <<
"NDEBUG must be off." <<
endl;
42 string line = myname +
"-----------------------------";
45 cout << myname <<
"Sample sizes: " << nsam0 <<
", " << nsam1 <<
endl;
48 cout << myname <<
"Checking index array." <<
endl;
50 assert( nsams[0] == nsam0 );
51 assert( nsams[1] == nsam1 );
52 Index nComplexExp = nsam0*(nsam1/2 + 1);
54 cout << myname <<
" Complex size: " << ndftComplex <<
endl;
56 cout << myname <<
" Float size: " << ndftFloat <<
endl;
57 assert( ndftComplex == nComplexExp );
58 assert( ndftFloat == 2*nComplexExp );
61 cout << myname <<
"Construct DFT object." <<
endl;
64 assert( dft.
rank() == 2 );
66 assert( dft.
size() == ndftComplex );
68 assert( dft.
size(0) == nsam0 );
70 assert( dft.
size(1) == nsam1 );
72 cout << myname <<
"Check indexing." <<
endl;
74 for (
Index idat=0; idat<nComplexExp; ++idat ) {
76 cout << myname <<
setw(3) << idat <<
": ";
77 Index nerr = idxas.size() == 0;
81 if ( first ) first =
false;
83 cout <<
"[" <<
setw(3) << idxa[0] <<
"," <<
setw(3) << idxa[1] <<
"]";
84 if ( jdat != idat ) cout <<
" --> " << jdat <<
" (!)";
85 if ( jdat != idat ) ++nerr;
91 assert( cntij == nsam0*nsam1 );
94 cout << myname <<
"Create test data." <<
endl;
95 vector<Complex> datc(nComplexExp);
96 vector<Float> datf(2*nComplexExp);
99 for ( idat=0; idat<nComplexExp; ++idat ) {
108 assert( idat == datc.size() );
109 assert( iflt == datf.size() );
111 cout << line <<
endl;
112 cout << myname <<
"Copy data in." <<
endl;
113 assert( dft.
copyIn(nsams, datc) == 0 );
114 for (
Index idat=0; idat<nComplexExp; ++idat ) {
116 assert( idxas.size() );
118 Index ire = cval.real() + 0.1;
119 Index iim = cval.imag() + 0.1;
120 cout << myname <<
setw(3) << idat <<
": [" 121 <<
setw(3) << idxas[0][0] <<
"," <<
setw(3) << idxas[0][1] <<
"]: " 122 <<
"(" <<
setw(3) << ire <<
"," <<
setw(3) << iim <<
")" 126 cout << line <<
endl;
127 cout << myname <<
"Copy object." <<
endl;
129 assert( dft2.
rank() == 2 );
131 assert( dft2.
size() == ndftComplex );
132 assert( dft2.
nSamples(0) == nsam0 );
133 assert( dft2.
size(0) == nsam0 );
134 assert( dft2.
nSamples(1) == nsam1 );
135 assert( dft2.
size(1) == nsam1 );
136 for (
Index idat=0; idat<nComplexExp; ++idat ) {
138 assert( idxas.size() );
140 Index ire = cval.real() + 0.1;
141 Index iim = cval.imag() + 0.1;
142 cout << myname <<
setw(3) << idat <<
": [" 143 <<
setw(3) << idxas[0][0] <<
"," <<
setw(3) << idxas[0][1] <<
"]: " 144 <<
"(" <<
setw(3) << ire <<
"," <<
setw(3) << iim <<
")" 148 cout << line <<
endl;
149 cout << myname <<
"All tests passed." <<
endl;
157 cout <<
"Usage: " << argv[0] <<
" [ARG]" <<
endl;
std::array< Index, 2 > IndexArray
DftData::IndexArrayVector IndexArrayVector
Index imagval(Index idat)
int copyIn(const IndexArray nsams, const ComplexVector &data)
IndexArrayVector indexArrays(Index idat) const
Norm normalization() const override
int test_FftwReal2dDftData(Index nsam0, Index nsam1)
DftData::IndexArray IndexArray
static Index dftComplexDataSize(const std::array< Index, N > &nsams)
Index realval(Index idat)
Index globalIndex(const IndexArray &ifrqs) const
FftwReal2dDftData< double > FftwDouble2dDftData
auto norm(Vector const &v)
Return norm of the specified vector.
Q_EXPORT QTSManip setw(int w)
std::complex< Float > Complex
static Index dftFloatDataSize(const std::array< Index, N > &nsams)
void line(double t, double *p, double &x, double &y, double &z)
const IndexArray & nSamples() const override
Complex value(Index idat) const
std::vector< IndexArray > IndexArrayVector
int main(int argc, char *argv[])
QTextStream & endl(QTextStream &s)