NFFT Logo 3.2.3
accuracy.c
1 /*
2  * Copyright (c) 2002, 2012 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: accuracy.c 3896 2012-10-10 12:19:26Z tovo $ */
20 
21 #include "config.h"
22 
23 #include <math.h>
24 #include <stdlib.h>
25 #ifdef HAVE_COMPLEX_H
26 #include <complex.h>
27 #endif
28 
29 #include "nfft3util.h"
30 #include "nfft3.h"
31 #include "infft.h"
32 
33 void accuracy(int d)
34 {
35  int m,t;
36  nnfft_plan my_plan;
37  double _Complex *slow;
38 
39  int N[d],n[d];
40  int M_total,N_total;
41  M_total=10000;N_total=1;
42 
43  slow=(double _Complex*)nfft_malloc(M_total*sizeof(double _Complex));
44 
45  for(t=0; t<d; t++)
46  {
47  N[t]=(1<<(12/d));
48  n[t]=2*N[t];
49  N_total*=N[t];
50  }
51 
53  for(m=0; m<10; m++)
54  {
55  nnfft_init_guru(&my_plan, d, N_total, M_total, N, n, m,
56  PRE_PSI| PRE_PHI_HUT|
57  MALLOC_X| MALLOC_V| MALLOC_F_HAT| MALLOC_F);
58 
59 
61  nfft_vrand_shifted_unit_double(my_plan.x, d*my_plan.M_total);
62  nfft_vrand_shifted_unit_double(my_plan.v, d*my_plan.N_total);
63 
65  if(my_plan.nnfft_flags & PRE_PSI)
66  nnfft_precompute_psi(&my_plan);
67 
68  if(my_plan.nnfft_flags & PRE_LIN_PSI)
69  nnfft_precompute_lin_psi(&my_plan);
70 
71  if(my_plan.nnfft_flags & PRE_FULL_PSI)
72  nnfft_precompute_full_psi(&my_plan);
73 
75  if(my_plan.nnfft_flags & PRE_PHI_HUT)
76  nnfft_precompute_phi_hut(&my_plan);
77 
79  nfft_vrand_unit_complex(my_plan.f_hat, my_plan.N_total);
80 
82  nnfft_trafo_direct(&my_plan);
83 
84  NFFT_SWAP_complex(my_plan.f,slow);
85 
87  nnfft_trafo(&my_plan);
88 
89  printf("%e, %e\n",
90  X(error_l_infty_complex)(slow, my_plan.f, M_total),
91  X(error_l_infty_1_complex)(slow, my_plan.f, M_total, my_plan.f_hat,
92  my_plan.N_total));
93 
95  nnfft_finalize(&my_plan);
96  }
97 }
98 
99 int main(void)
100 {
101  int d;
102  for(d=1; d<4; d++)
103  accuracy(d);
104 
105  return 1;
106 }

Generated on Tue Apr 30 2013 by Doxygen 1.8.1