28 #define CSWAP(x,y) {double _Complex * NFFT_SWAP_temp__; \
29 NFFT_SWAP_temp__=(x); (x)=(y); (y)=NFFT_SWAP_temp__;}
31 static void accuracy_nsfft(
int d,
int J,
int M,
int m)
34 double _Complex *swap_sndft_trafo, *swap_sndft_adjoint;
39 sizeof(
double _Complex));
41 sizeof(
double _Complex));
46 nsfft_trafo_direct(&p);
48 CSWAP(swap_sndft_trafo,p.
f);
53 printf(
"%5d\t %+.5E\t",J,
54 nfft_error_l_infty_1_complex(swap_sndft_trafo, p.
f, p.
M_total,
61 nsfft_adjoint_direct(&p);
69 nfft_error_l_infty_1_complex(swap_sndft_adjoint, p.
f_hat,
81 static void time_nsfft(
int d,
int J,
int M,
unsigned test_nsdft,
unsigned test_nfft)
84 double t, t_nsdft, t_nfft, t_nsfft;
92 N[r]= nfft_exp2i(J+2);
109 t0 = nfft_clock_gettime_seconds();
110 nsfft_trafo_direct(&p);
111 t1 = nfft_clock_gettime_seconds();
134 t0 = nfft_clock_gettime_seconds();
136 t1 = nfft_clock_gettime_seconds();
154 t0 = nfft_clock_gettime_seconds();
156 t1 = nfft_clock_gettime_seconds();
162 printf(
"%d\t%.2e\t%.2e\t%.2e\n", J, t_nsdft, t_nfft, t_nsfft);
171 int main(
int argc,
char **argv)
177 fprintf(stderr,
"nsfft_test type d [first last trials]\n");
182 fprintf(stderr,
"Testing the nfft on the hyperbolic cross (nsfft).\n");
186 fprintf(stderr,
"Testing the accuracy of the nsfft vs. nsdft\n");
187 fprintf(stderr,
"Columns: d, E_{1,\\infty}(trafo) E_{1,\\infty}(adjoint)\n\n");
189 accuracy_nsfft(d, J, 1000, 6);
194 fprintf(stderr,
"Testing the computation time of the nsdft, nfft, and nsfft\n");
195 fprintf(stderr,
"Columns: d, J, M, t_nsdft, t_nfft, t_nsfft\n\n");
196 for(J=atoi(argv[3]); J<=atoi(argv[4]); J++)
199 M=(J+4)*nfft_exp2i(J+1);
201 M=6*nfft_exp2i(J)*(nfft_exp2i((J+1)/2+1)-1)+nfft_exp2i(3*(J/2+1));
204 time_nsfft(d, J, M, 1, 1);
207 time_nsfft(d, J, M, 0, 1);
209 time_nsfft(d, J, M, 0, 0);
NFFT_INT N_total
Total number of Fourier coefficients.
void nsfft_init(nsfft_plan *ths, int d, int J, int M, int m, unsigned flags)
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 nsfft_cp(nsfft_plan *ths, nfft_plan *ths_nfft)
void nfft_trafo(nfft_plan *ths)
void * nfft_malloc(size_t n)
void nfft_finalize(nfft_plan *ths)
void nfft_precompute_one_psi(nfft_plan *ths)
void nsfft_init_random_nodes_coeffs(nsfft_plan *ths)
void nsfft_adjoint(nsfft_plan *ths)
Header file for the nfft3 library.
double * x
Nodes in time/spatial domain, size is doubles.
void nsfft_finalize(nsfft_plan *ths)
unsigned flags
Flags for precomputation, (de)allocation, and FFTW usage, default setting is PRE_PHI_HUT | PRE_PSI | ...
void nsfft_trafo(nsfft_plan *ths)
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.