30 #define CSWAP(x,y) {double _Complex * NFFT_SWAP_temp__; \
31 NFFT_SWAP_temp__=(x); (x)=(y); (y)=NFFT_SWAP_temp__;}
33 static void accuracy_nsfft(
int d,
int J,
int M,
int m)
36 double _Complex *swap_sndft_trafo, *swap_sndft_adjoint;
38 nsfft_init(&p, d, J, M, m, NSDFT);
41 sizeof(
double _Complex));
43 sizeof(
double _Complex));
45 nsfft_init_random_nodes_coeffs(&p);
48 nsfft_trafo_direct(&p);
50 CSWAP(swap_sndft_trafo,p.
f);
55 printf(
"%5d\t %+.5E\t",J,
56 nfft_error_l_infty_1_complex(swap_sndft_trafo, p.
f, p.
M_total,
63 nsfft_adjoint_direct(&p);
71 nfft_error_l_infty_1_complex(swap_sndft_adjoint, p.
f_hat,
83 static void time_nsfft(
int d,
int J,
int M,
unsigned test_nsdft,
unsigned test_nfft)
86 double t, t_nsdft, t_nfft, t_nsfft;
94 N[r]= nfft_exp2i(J+2);
100 nsfft_init(&p, d, J, M, 4, NSDFT);
101 nsfft_init_random_nodes_coeffs(&p);
111 t0 = nfft_clock_gettime_seconds();
112 nsfft_trafo_direct(&p);
113 t1 = nfft_clock_gettime_seconds();
124 nfft_init_guru(&np,d,N,M,n,6, FG_PSI| MALLOC_F_HAT| MALLOC_F| FFTW_INIT,
127 if(np.
flags & PRE_ONE_PSI)
128 nfft_precompute_one_psi(&np);
136 t0 = nfft_clock_gettime_seconds();
138 t1 = nfft_clock_gettime_seconds();
156 t0 = nfft_clock_gettime_seconds();
158 t1 = nfft_clock_gettime_seconds();
164 printf(
"%d\t%.2e\t%.2e\t%.2e\n", J, t_nsdft, t_nfft, t_nsfft);
173 int main(
int argc,
char **argv)
179 fprintf(stderr,
"nsfft_test type d [first last trials]\n");
184 fprintf(stderr,
"Testing the nfft on the hyperbolic cross (nsfft).\n");
188 fprintf(stderr,
"Testing the accuracy of the nsfft vs. nsdft\n");
189 fprintf(stderr,
"Columns: d, E_{1,\\infty}(trafo) E_{1,\\infty}(adjoint)\n\n");
191 accuracy_nsfft(d, J, 1000, 6);
196 fprintf(stderr,
"Testing the computation time of the nsdft, nfft, and nsfft\n");
197 fprintf(stderr,
"Columns: d, J, M, t_nsdft, t_nfft, t_nsfft\n\n");
198 for(J=atoi(argv[3]); J<=atoi(argv[4]); J++)
201 M=(J+4)*nfft_exp2i(J+1);
203 M=6*nfft_exp2i(J)*(nfft_exp2i((J+1)/2+1)-1)+nfft_exp2i(3*(J/2+1));
206 time_nsfft(d, J, M, 1, 1);
209 time_nsfft(d, J, M, 0, 1);
211 time_nsfft(d, J, M, 0, 0);
NFFT_INT N_total
Total number of Fourier coefficients.
NFFT_INT M_total
Total number of samples.
data structure for an NFFT (nonequispaced fast Fourier transform) plan with double precision ...
void nfft_vrand_unit_complex(fftw_complex *x, const NFFT_INT n)
Inits a vector of random complex numbers in .
void * nfft_malloc(size_t n)
double * x
Nodes in time/spatial domain, size is doubles.
unsigned flags
Flags for precomputation, (de)allocation, and FFTW usage, default setting is PRE_PHI_HUT | PRE_PSI | ...
data structure for an NSFFT (nonequispaced sparse fast Fourier transform) plan with double precision ...
nfft_plan * act_nfft_plan
current nfft block
#define CSWAP(x, y)
Swap two vectors.
fftw_complex * f_hat
Fourier coefficients.