67 nfft_init_guru((
nfft_plan*)ths, 1, &N, M, &n, m,
68 MALLOC_X| MALLOC_F_HAT| MALLOC_F|
69 FFTW_INIT| FFT_OUT_OF_PLACE,
70 FFTW_ESTIMATE| FFTW_PRESERVE_INPUT);
91 ths->
idx0[j] = ((int)round((cths->
x[j]+0.5)*cths->
n[0]) +
92 cths->
n[0]/2)%cths->
n[0];
93 ths->
deltax0[j] = cths->
x[j] - (round((cths->
x[j]+0.5)*cths->
n[0]) /
126 double _Complex *f, *f_hat, *g1;
132 for(j=0, f=cths->
f; j<cths->M_total; j++)
139 f_hat=cths->
f_hat; k<0; k++)
140 (*g1++)=cpow( - 2*
PI*_Complex_I*k,cths->
m)* (*f_hat++);
145 k<cths->N_total/2; k++)
146 (*g1++)=cpow( - 2*
PI*_Complex_I*k,cths->
m)* (*f_hat++);
148 for(l=cths->
m-1; l>=0; l--)
152 (*g1++) /= (-2*
PI*_Complex_I*k);
154 for(k=1, g1=cths->
g1+1; k<cths->N_total/2; k++)
155 (*g1++) /= (-2*
PI*_Complex_I*k);
157 fftw_execute(cths->my_fftw_plan1);
160 for(j=0, f=cths->
f, deltax=ths->
deltax0, idx=ths->
idx0; j<cths->M_total;
162 (*f) = ((*f) * (*deltax++) + cths->
g2[*idx++]) /ll;
180 int m_taylor,
unsigned test_accuracy)
183 double t_ndft, t_nfft, t_taylor, t;
184 double _Complex *swapndft = NULL;
190 printf(
"%d\t%d\t",N, M);
194 nfft_init_guru(&np, 1, &N, M, &n, m,
195 PRE_PHI_HUT| PRE_FG_PSI|
196 FFTW_INIT| FFT_OUT_OF_PLACE,
197 FFTW_ESTIMATE| FFTW_DESTROY_INPUT);
206 swapndft=(
double _Complex*)
nfft_malloc(M*
sizeof(
double _Complex));
216 nfft_precompute_one_psi(&np);
232 nfft_trafo_direct(&np);
234 t = nfft_elapsed_seconds(t1,t0);
240 printf(
"%.2e\t",t_ndft);
254 t = nfft_elapsed_seconds(t1,t0);
259 printf(
"%.2f\t%d\t%.2e\t",((
double)n)/N, m, t_nfft);
262 printf(
"%.2e\t",X(error_l_infty_complex)(swapndft, np.
f, np.
M_total));
275 t = nfft_elapsed_seconds(t1,t0);
281 printf(
"%.2f\t%d\t%.2e\t",((
double)n_taylor)/N,m_taylor,t_taylor);
284 printf(
"%.2e\n",X(error_l_infty_complex)(swapndft, np.
f, np.
M_total));
298 int main(
int argc,
char **argv)
304 fprintf(stderr,
"taylor_nfft type first last trials sigma_nfft sigma_taylor.\n");
308 fprintf(stderr,
"Testing the Nfft & a Taylor expansion based version.\n\n");
309 fprintf(stderr,
"Columns: N, M, t_ndft, sigma_nfft, m_nfft, t_nfft, e_nfft");
310 fprintf(stderr,
", sigma_taylor, m_taylor, t_taylor, e_taylor\n");
315 fprintf(stderr,
"Fixed target accuracy, timings.\n\n");
316 for(l=atoi(argv[2]); l<=atoi(argv[3]); l++)
317 for(trial=0; trial<atoi(argv[4]); trial++)
320 (1U<< l)), 6, (
int)(atof(argv[6])*(1U<< l)),
324 (1U<< l)), 6, (
int)(atof(argv[6])*(1U<< l)),
332 fprintf(stderr,
"Fixed N=M=%d, error vs. m.\n\n",N);
333 for(m=atoi(argv[2]); m<=atoi(argv[3]); m++)
334 for(trial=0; trial<atoi(argv[4]); trial++)
336 (
int)(atof(argv[6])*N), m, 1);
void nfft_vrand_unit_complex(fftw_complex *x, int n)
Inits a vector of random complex numbers in .
fftw_complex * f_hat
Vector of Fourier coefficients, size is N_total * sizeof( fftw_complex )
static void taylor_finalize(taylor_plan *ths)
Destroys a transform plan.
static void taylor_precompute(taylor_plan *ths)
Precomputation of weights and indices in Taylor expansion.
int * idx0
index of next neighbour of x_j on the oversampled regular grid
fftw_complex * g1
Input of fftw.
fftw_complex * f
Vector of samples, size is M_total * sizeof( fftw_complex )
static void taylor_trafo(taylor_plan *ths)
Executes a Taylor-NFFT, see equation (1.1) in [Guide], computes fast and approximate by means of a Ta...
#define NFFT_SWAP_complex(x, y)
Swapping of two vectors.
int m
Cut-off parameter of the window function, default value is 6 (KAISER_BESSEL), 9 (SINC_POWER), 11 (B_SPLINE), 12 (GAUSSIAN)
void nfft_trafo(nfft_plan *ths)
user routines
int M_total
Total number of samples.
Header file for utility functions used by the nfft3 library.
static void taylor_init(taylor_plan *ths, int N, int M, int n, int m)
Initialisation of a transform plan.
double * deltax0
distance to the grid point
#define PI
Formerly known to be an irrational number.
void nfft_vrand_shifted_unit_double(double *x, int n)
Inits a vector of random double numbers in .
unsigned nfft_flags
Flags for precomputation, (de)allocation, and FFTW usage, default setting is PRE_PHI_HUT | PRE_PSI | ...
void * nfft_malloc(size_t n)
static void taylor_time_accuracy(int N, int M, int n, int m, int n_taylor, int m_taylor, unsigned test_accuracy)
Compares NDFT, NFFT, and Taylor-NFFT.
int * n
FFTW length, equal to sigma*N, default is the power of 2 such that .
nfft_plan p
used for fftw and data
double * x
Nodes in time/spatial domain, size is doubles.
int N_total
Total number of Fourier coefficients.
fftw_complex * g2
Output of fftw.
int n_total
Total size of FFTW.