38 static void ndft_horner_trafo(NFFT(plan) *ths)
44 for (j = 0, f_j = ths->f; j < ths->M_total; j++, f_j++)
47 for (j = 0, f_j = ths->f; j < ths->M_total; j++, f_j++)
49 exp_omega_0 = CEXP(+K2PI * II * ths->x[j]);
50 for (k = 0, f_hat_k = ths->f_hat; k < ths->N[0]; k++, f_hat_k++)
53 (*f_j) *= exp_omega_0;
55 (*f_j) *= CEXP(-KPI * II * (R)(ths->N[0]) * ths->x[j]);
59 static void ndft_pre_full_trafo(NFFT(plan) *ths, C *A)
65 for (j = 0, f_j = ths->f; j < ths->M_total; j++, f_j++)
68 for (j = 0, f_j = ths->f, A_local = A; j < ths->M_total; j++, f_j++)
69 for (k = 0, f_hat_k = ths->f_hat; k < ths->N[0]; k++, f_hat_k++, A_local++)
70 (*f_j) += (*f_hat_k) * (*A_local);
73 static void ndft_pre_full_init(NFFT(plan) *ths, C *A)
76 C *f_hat_k, *f_j, *A_local;
78 for (j = 0, f_j = ths->f, A_local = A; j < ths->M_total; j++, f_j++)
79 for (k = 0, f_hat_k = ths->f_hat; k < ths->N[0]; k++, f_hat_k++, A_local++)
81 -K2PI * II * ((R) (k) - (R) (ths->N[0]) / K(2.0)) * ths->x[j]);
85 static void ndft_time(
int N,
int M,
unsigned test_ndft,
unsigned test_pre_full)
88 R t, t_ndft, t_horner, t_pre_full, t_nfft;
94 printf("%d\t%d\t", N, M);
96 NFFT(init_1d)(&np, N, M);
99 NFFT(vrand_shifted_unit_double)(np.x, np.M_total);
103 A = (C*) NFFT(malloc)((size_t)(N * M) *
sizeof(R));
104 ndft_pre_full_init(&np, A);
108 NFFT(vrand_unit_complex)(np.f_hat, np.N_total);
115 while (t_ndft < K(0.1))
119 NFFT(trafo_direct)(&np);
121 t = NFFT(elapsed_seconds)(t1, t0);
126 printf(
"%.2" __FES__
"\t", t_ndft);
134 while (t_horner < K(0.1))
138 ndft_horner_trafo(&np);
140 t = NFFT(elapsed_seconds)(t1, t0);
145 printf(
"%.2" __FES__
"\t", t_horner);
152 while (t_pre_full < K(0.1))
156 ndft_pre_full_trafo(&np, A);
158 t = NFFT(elapsed_seconds)(t1, t0);
161 t_pre_full /= (R)(r);
163 printf(
"%.2" __FES__
"\t", t_pre_full);
170 while (t_nfft < K(0.1))
176 t = NFFT(elapsed_seconds)(t1, t0);
181 printf(
"%.2" __FES__
"\n", t_nfft);
191 int main(
int argc,
char **argv)
197 fprintf(stderr,
"ndft_fast type first last trials\n");
202 int arg2 = (atoi(argv[2]));
203 int arg3 = (atoi(argv[3]));
204 int arg4 = (atoi(argv[4]));
205 fprintf(stderr,
"Testing ndft, Horner-like ndft, fully precomputed ndft.\n");
206 fprintf(stderr,
"Columns: N, M, t_ndft, t_horner, t_pre_full, t_nfft\n\n");
209 if (atoi(argv[1]) == 0)
211 for (l = arg2; l <= arg3; l++)
213 for (trial = 0; trial < arg4; trial++)
215 int N = (int)(1U << l);
216 int M = (int)(1U << l);
217 ndft_time(N, M, l <= 15 ? 1 : 0, l <= 13 ? 1 : 0);
Header file for the nfft3 library.