NFFT Logo 3.2.2
accuracy.c
00001 /*
00002  * Copyright (c) 2002, 2012 Jens Keiner, Stefan Kunis, Daniel Potts
00003  *
00004  * This program is free software; you can redistribute it and/or modify it under
00005  * the terms of the GNU General Public License as published by the Free Software
00006  * Foundation; either version 2 of the License, or (at your option) any later
00007  * version.
00008  *
00009  * This program is distributed in the hope that it will be useful, but WITHOUT
00010  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00011  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
00012  * details.
00013  *
00014  * You should have received a copy of the GNU General Public License along with
00015  * this program; if not, write to the Free Software Foundation, Inc., 51
00016  * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  */
00018 
00019 /* $Id: accuracy.c 3896 2012-10-10 12:19:26Z tovo $ */
00020 
00021 #include "config.h"
00022 
00023 #include <math.h>
00024 #include <stdlib.h>
00025 #ifdef HAVE_COMPLEX_H
00026 #include <complex.h>
00027 #endif
00028 
00029 #include "nfft3util.h"
00030 #include "nfft3.h"
00031 #include "infft.h"
00032 
00033 void accuracy(int d)
00034 {
00035   int m,t;
00036   nnfft_plan my_plan;
00037   double _Complex *slow;
00038 
00039   int N[d],n[d];
00040   int M_total,N_total;
00041   M_total=10000;N_total=1;
00042 
00043   slow=(double _Complex*)nfft_malloc(M_total*sizeof(double _Complex));
00044 
00045   for(t=0; t<d; t++)
00046     {
00047       N[t]=(1<<(12/d));
00048       n[t]=2*N[t];
00049       N_total*=N[t];
00050     }
00051 
00053   for(m=0; m<10; m++)
00054     {
00055       nnfft_init_guru(&my_plan, d, N_total, M_total, N, n, m,
00056           PRE_PSI| PRE_PHI_HUT|
00057           MALLOC_X| MALLOC_V| MALLOC_F_HAT| MALLOC_F);
00058 
00059 
00061       nfft_vrand_shifted_unit_double(my_plan.x, d*my_plan.M_total);
00062       nfft_vrand_shifted_unit_double(my_plan.v, d*my_plan.N_total);
00063 
00065       if(my_plan.nnfft_flags & PRE_PSI)
00066         nnfft_precompute_psi(&my_plan);
00067 
00068       if(my_plan.nnfft_flags & PRE_LIN_PSI)
00069         nnfft_precompute_lin_psi(&my_plan);
00070 
00071       if(my_plan.nnfft_flags & PRE_FULL_PSI)
00072         nnfft_precompute_full_psi(&my_plan);
00073 
00075       if(my_plan.nnfft_flags & PRE_PHI_HUT)
00076         nnfft_precompute_phi_hut(&my_plan);
00077 
00079       nfft_vrand_unit_complex(my_plan.f_hat, my_plan.N_total);
00080 
00082       nnfft_trafo_direct(&my_plan);
00083 
00084       NFFT_SWAP_complex(my_plan.f,slow);
00085 
00087       nnfft_trafo(&my_plan);
00088 
00089       printf("%e, %e\n",
00090        X(error_l_infty_complex)(slow, my_plan.f, M_total),
00091        X(error_l_infty_1_complex)(slow, my_plan.f, M_total, my_plan.f_hat,
00092              my_plan.N_total));
00093 
00095       nnfft_finalize(&my_plan);
00096     }
00097 }
00098 
00099 int main(void)
00100 {
00101   int d;
00102   for(d=1; d<4; d++)
00103     accuracy(d);
00104 
00105   return 1;
00106 }

Generated on Fri Oct 12 2012 by Doxygen 1.8.0-20120409