NFFT  3.3.0
accuracy.c
1 /*
2  * Copyright (c) 2002, 2015 Jens Keiner, Stefan Kunis, Daniel Potts
3  *
4  * This program is free software; you can redistribute it and/or modify it under
5  * the terms of the GNU General Public License as published by the Free Software
6  * Foundation; either version 2 of the License, or (at your option) any later
7  * version.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12  * details.
13  *
14  * You should have received a copy of the GNU General Public License along with
15  * this program; if not, write to the Free Software Foundation, Inc., 51
16  * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  */
18 
19 /* $Id$ */
20 
21 #include <math.h>
22 #include <stdlib.h>
23 #include <complex.h>
24 
25 #include "nfft3.h"
26 
28 #define CSWAP(x,y) {double _Complex * NFFT_SWAP_temp__; \
29  NFFT_SWAP_temp__=(x); (x)=(y); (y)=NFFT_SWAP_temp__;}
30 
31 void accuracy(int d)
32 {
33  int m,t;
34  nnfft_plan my_plan;
35  double _Complex *slow;
36 
37  int N[d],n[d];
38  int M_total,N_total;
39  M_total=10000;N_total=1;
40 
41  slow=(double _Complex*)nfft_malloc(M_total*sizeof(double _Complex));
42 
43  for(t=0; t<d; t++)
44  {
45  N[t]=(1<<(12/d));
46  n[t]=2*N[t];
47  N_total*=N[t];
48  }
49 
51  for(m=0; m<10; m++)
52  {
53  nnfft_init_guru(&my_plan, d, N_total, M_total, N, n, m,
54  PRE_PSI| PRE_PHI_HUT|
55  MALLOC_X| MALLOC_V| MALLOC_F_HAT| MALLOC_F);
56 
57 
59  nfft_vrand_shifted_unit_double(my_plan.x, d*my_plan.M_total);
60  nfft_vrand_shifted_unit_double(my_plan.v, d*my_plan.N_total);
61 
63  if(my_plan.nnfft_flags & PRE_PSI)
64  nnfft_precompute_psi(&my_plan);
65 
66  if(my_plan.nnfft_flags & PRE_LIN_PSI)
67  nnfft_precompute_lin_psi(&my_plan);
68 
69  if(my_plan.nnfft_flags & PRE_FULL_PSI)
70  nnfft_precompute_full_psi(&my_plan);
71 
73  if(my_plan.nnfft_flags & PRE_PHI_HUT)
74  nnfft_precompute_phi_hut(&my_plan);
75 
77  nfft_vrand_unit_complex(my_plan.f_hat, my_plan.N_total);
78 
80  nnfft_trafo_direct(&my_plan);
81 
82  CSWAP(my_plan.f,slow);
83 
85  nnfft_trafo(&my_plan);
86 
87  printf("%e, %e\n",
88  nfft_error_l_infty_complex(slow, my_plan.f, M_total),
89  nfft_error_l_infty_1_complex(slow, my_plan.f, M_total, my_plan.f_hat,
90  my_plan.N_total));
91 
93  nnfft_finalize(&my_plan);
94  }
95 }
96 
97 int main(void)
98 {
99  int d;
100  for(d=1; d<4; d++)
101  accuracy(d);
102 
103  return 1;
104 }
fftw_complex * f_hat
Fourier coefficients.
Definition: nfft3.h:426
void nnfft_precompute_full_psi(nnfft_plan *ths_plan)
computes all entries of B explicitly
Definition: nnfft.c:426
unsigned nnfft_flags
flags for precomputation, malloc
Definition: nfft3.h:426
fftw_complex * f
Samples.
Definition: nfft3.h:426
double * v
nodes (in fourier domain)
Definition: nfft3.h:426
void nfft_vrand_shifted_unit_double(double *x, const NFFT_INT n)
Inits a vector of random double numbers in .
void nnfft_trafo(nnfft_plan *ths_plan)
user routines
Definition: nnfft.c:293
void nnfft_precompute_phi_hut(nnfft_plan *ths_plan)
initialisation of direct transform
Definition: nnfft.c:349
void nfft_vrand_unit_complex(fftw_complex *x, const NFFT_INT n)
Inits a vector of random complex numbers in .
NFFT_INT M_total
Total number of samples.
Definition: nfft3.h:426
data structure for an NNFFT (nonequispaced in time and frequency fast Fourier transform) plan with do...
Definition: nfft3.h:426
double * x
nodes (in time/spatial domain)
Definition: nfft3.h:426
void * nfft_malloc(size_t n)
void nnfft_precompute_lin_psi(nnfft_plan *ths_plan)
create a lookup table
Definition: nnfft.c:369
NFFT_INT N_total
Total number of Fourier coefficients.
Definition: nfft3.h:426
#define CSWAP(x, y)
Swap two vectors.
Definition: infft.h:152