-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.cc
40 lines (33 loc) · 933 Bytes
/
test.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <fftw3.h>
#include <limits>
#include <cmath>
#include <cassert>
int main( )
{
int N = 60, Ngp = N*N*(N+2);
double *data = new double[Ngp];
for( std::size_t i=0; i<Ngp; ++i )
data[i] = std::numeric_limits<double>::signaling_NaN();
for( std::size_t i=0; i<N; ++i ){
for( std::size_t j=0; j<N; ++j ){
for( std::size_t k=0; k<N; ++k ){
std::size_t idx = (i*N+j)*(N+2)+k;
data[idx] = 0.0;
}
}
}
fftw_complex *cdata = reinterpret_cast<fftw_complex *>(data);
fftw_plan pf = fftw_plan_dft_r2c_3d(N, N, N, data, cdata, FFTW_ESTIMATE);
fftw_execute(pf);
for( std::size_t i=0; i<N; ++i ){
for( std::size_t j=0; j<N; ++j ){
for( std::size_t k=0; k<N/2+1; ++k ){
std::size_t idx = (i*N+j)*(N/2+1)+k;
assert( !std::isnan(cdata[idx][0]) );
assert( !std::isnan(cdata[idx][1]) );
}
}
}
fftw_destroy_plan(pf);
delete[] data;
}