38 static void simple_test_nfsoft(
int bw,
int M)
48 unsigned int flags = NFSOFT_MALLOC_X | NFSOFT_MALLOC_F | NFSOFT_MALLOC_F_HAT;
61 nfsoft_init_guru(&plan_ndsoft, bw, M, flags | NFSOFT_USE_NDFT
62 | NFSOFT_USE_DPT, PRE_PHI_HUT | PRE_PSI | MALLOC_X | MALLOC_F_HAT
63 | MALLOC_F | FFTW_INIT | FFT_OUT_OF_PLACE, m, k);
65 nfsoft_init_guru(&plan_nfsoft, bw, M, flags, PRE_PHI_HUT | PRE_PSI | MALLOC_X
66 | MALLOC_F_HAT | MALLOC_F | FFTW_INIT | FFT_OUT_OF_PLACE, m, k);
69 for (j = 0; j < plan_nfsoft.
M_total; j++)
71 d1 = ((R) rand()) / RAND_MAX - 0.5;
72 d2 = 0.5 * ((R) rand()) / RAND_MAX;
73 d3 = ((R) rand()) / RAND_MAX - 0.5;
75 plan_nfsoft.
x[3* j ] = d1;
76 plan_nfsoft.
x[3* j + 1] = d2;
77 plan_nfsoft.
x[3* j + 2] = d3;
79 plan_ndsoft.
x[3* j ] = d1;
80 plan_ndsoft.
x[3* j + 1] = d2;
81 plan_ndsoft.
x[3* j + 2] = d3;
85 for (j = 0; j < (bw + 1) * (4* (bw +1)*(bw+1)-1)/3;j++)
87 d1=((R)rand())/RAND_MAX - 0.5;
88 d2=((R)rand())/RAND_MAX - 0.5;
89 plan_nfsoft.
f_hat[j]=d1 + I*d2;
90 plan_ndsoft.
f_hat[j]=d1 + I*d2;
93 if ((bw+1)*(4*(bw+1)*(bw+1)-1)/3<=20)
94 nfft_vpr_complex(plan_nfsoft.
f_hat,(bw+1)*(4*(bw+1)*(bw+1)-1)/3,
"randomly generated SO(3) Fourier coefficients");
98 printf(
"\n---------------------------------------------\n");
101 nfsoft_precompute(&plan_nfsoft);
102 nfsoft_precompute(&plan_ndsoft);
107 nfsoft_trafo(&plan_nfsoft);
109 time = nfft_elapsed_seconds(t1,t0);
114 printf(
" computed in %11le seconds\n",time);
118 nfsoft_trafo(&plan_ndsoft);
120 time = nfft_elapsed_seconds(t1,t0);
125 printf(
" computed in %11le seconds\n",time);
128 error= X(error_l_infty_complex)(plan_ndsoft.
f,plan_nfsoft.
f, plan_nfsoft.
M_total);
129 printf(
"\n The NFSOFT of bandwidth=%d for %d rotations has infty-error %11le \n",bw, M,error);
131 printf(
"\n---------------------------------------------\n");
133 plan_nfsoft.
f[0]=1.0;
134 plan_ndsoft.
f[0]=1.0;
139 nfsoft_adjoint(&plan_nfsoft);
141 time = nfft_elapsed_seconds(t1,t0);
142 if ((bw+1)*(4*(bw+1)*(bw+1)-1)/3<=20)
146 printf(
" computed in %11le seconds\n",time);
150 nfsoft_adjoint(&plan_ndsoft);
152 time = nfft_elapsed_seconds(t1,t0);
153 if ((bw+1)*(4*(bw+1)*(bw+1)-1)/3<=20)
157 printf(
" computed in %11le seconds\n",time);
161 error=X(error_l_infty_complex)(plan_ndsoft.
f_hat,plan_nfsoft.
f_hat, (bw+1)*(4*(bw+1)*(bw+1)-1)/3);
162 printf(
"\n The adjoint NFSOFT of bandwidth=%d for %d rotations has infty-error %11le \n",bw, M,error);
164 printf(
"\n---------------------------------------------\n");
167 nfsoft_finalize(&plan_ndsoft);
168 nfsoft_finalize(&plan_nfsoft);
187 int main(
int argc,
char **argv)
195 "This test programm computes the NFSOFT with maximum polynomial degree N at M input rotations\n");
196 printf(
"Usage: simple_test N M \n");
197 printf(
"e.g.: simple_test 8 64\n");
206 "computing an NDSOFT, an NFSOFT, an adjoint NDSOFT, and an adjoint NFSOFT\n\n");
208 simple_test_nfsoft(N, M);