41 static void ndft_horner_trafo(
nfft_plan *ths)
44 double _Complex *f_hat_k, *f_j;
45 double _Complex exp_omega_0;
47 for(j=0, f_j=ths->
f; j<ths->M_total; j++, f_j++)
50 for(j=0, f_j=ths->
f; j<ths->M_total; j++, f_j++)
52 exp_omega_0 = cexp(+2*
PI*_Complex_I*ths->
x[j]);
53 for(k=0, f_hat_k= ths->
f_hat; k<ths->N[0]; k++, f_hat_k++)
58 (*f_j)*=cexp(-
PI*_Complex_I*ths->
N[0]*ths->
x[j]);
62 static void ndft_pre_full_trafo(
nfft_plan *ths,
double _Complex *A)
65 double _Complex *f_hat_k, *f_j;
66 double _Complex *A_local;
68 for(j=0, f_j=ths->
f; j<ths->M_total; j++, f_j++)
71 for(j=0, f_j=ths->
f, A_local=A; j<ths->M_total; j++, f_j++)
72 for(k=0, f_hat_k= ths->
f_hat; k<ths->N[0]; k++, f_hat_k++, A_local++)
73 (*f_j) += (*f_hat_k)*(*A_local);
76 static void ndft_pre_full_init(
nfft_plan *ths,
double _Complex *A)
79 double _Complex *f_hat_k, *f_j, *A_local;
81 for(j=0, f_j=ths->
f, A_local=A; j<ths->M_total; j++, f_j++)
82 for(k=0, f_hat_k= ths->
f_hat; k<ths->N[0]; k++, f_hat_k++, A_local++)
83 (*A_local) = cexp(-2*
PI*_Complex_I*(k-ths->
N[0]/2)*ths->
x[j]);
87 static void ndft_time(
int N,
int M,
unsigned test_ndft,
unsigned test_pre_full)
90 double t, t_ndft, t_horner, t_pre_full, t_nfft;
91 double _Complex *A = NULL;
96 printf(
"%d\t%d\t",N, M);
98 nfft_init_1d(&np, N, M);
105 A=(
double _Complex*)
nfft_malloc(N*M*
sizeof(
double _Complex));
106 ndft_pre_full_init(&np, A);
121 nfft_trafo_direct(&np);
123 t = nfft_elapsed_seconds(t1,t0);
128 printf(
"%.2e\t",t_ndft);
140 ndft_horner_trafo(&np);
142 t = nfft_elapsed_seconds(t1,t0);
147 printf(
"%.2e\t", t_horner);
154 while(t_pre_full<0.1)
158 ndft_pre_full_trafo(&np,A);
160 t = nfft_elapsed_seconds(t1,t0);
165 printf(
"%.2e\t", t_pre_full);
178 t = nfft_elapsed_seconds(t1,t0);
183 printf(
"%.2e\n", t_nfft);
193 int main(
int argc,
char **argv)
199 fprintf(stderr,
"ndft_fast type first last trials\n");
203 fprintf(stderr,
"Testing ndft, Horner-like ndft, fully precomputed ndft.\n");
204 fprintf(stderr,
"Columns: N, M, t_ndft, t_horner, t_pre_full, t_nfft\n\n");
209 for(l=atoi(argv[2]); l<=atoi(argv[3]); l++)
210 for(trial=0; trial<atoi(argv[4]); trial++)
212 ndft_time((1U<< l), (1U<< l), 1, 1);
215 ndft_time((1U<< l), (1U<< l), 1, 0);
217 ndft_time((1U<< l), (1U<< l), 0, 0);