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 );
65 assert( dft.normalization() ==
norm );
66 assert( dft.size() == ndftComplex );
67 assert( dft.nSamples(0) == nsam0 );
68 assert( dft.size(0) == nsam0 );
69 assert( dft.nSamples(1) == nsam1 );
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;
80 Index jdat = dft.globalIndex(idxa);
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() );
117 Complex cval = dft.value(idat);
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 );
130 assert( dft2.normalization() ==
norm );
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() );
139 Complex cval = dft2.value(idat);
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;
DftData::IndexArrayVector IndexArrayVector
Index imagval(Index idat)
DftData::IndexArray IndexArray
static Index dftComplexDataSize(const std::array< Index, N > &nsams)
Index realval(Index idat)
auto norm(Vector const &v)
Return norm of the specified vector.
Q_EXPORT QTSManip setw(int w)
static Index dftFloatDataSize(const std::array< Index, N > &nsams)
void line(double t, double *p, double &x, double &y, double &z)
QTextStream & endl(QTextStream &s)