NFFT Logo 3.1.1 API Reference

accuracy.c

00001 /*
00002  * Copyright (c) 2002, 2009 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 3198 2009-05-27 14:16:50Z keiner $ */
00020 
00021 #include <math.h>
00022 #include <stdlib.h>
00023 #include <complex.h>
00024 
00025 #include "nfft3util.h"
00026 #include "nfft3.h"
00027 
00028 void accuracy(int d)
00029 {
00030   int m,t;
00031   nnfft_plan my_plan;
00032   double _Complex *slow;
00033 
00034   int N[d],n[d];
00035   int M_total,N_total;
00036   M_total=10000;N_total=1;
00037 
00038   slow=(double _Complex*)nfft_malloc(M_total*sizeof(double _Complex));
00039 
00040   for(t=0; t<d; t++)
00041     {
00042       N[t]=(1<<(12/d));
00043       n[t]=2*N[t];
00044       N_total*=N[t];
00045     }
00046 
00048   for(m=0; m<10; m++)
00049     {
00050       nnfft_init_guru(&my_plan, d, N_total, M_total, N, n, m,
00051           PRE_PSI| PRE_PHI_HUT|
00052           MALLOC_X| MALLOC_V| MALLOC_F_HAT| MALLOC_F);
00053 
00054 
00056       nfft_vrand_shifted_unit_double(my_plan.x, d*my_plan.M_total);
00057       nfft_vrand_shifted_unit_double(my_plan.v, d*my_plan.N_total);
00058 
00060       if(my_plan.nnfft_flags & PRE_PSI)
00061         nnfft_precompute_psi(&my_plan);
00062 
00063       if(my_plan.nnfft_flags & PRE_LIN_PSI)
00064         nnfft_precompute_lin_psi(&my_plan);
00065 
00066       if(my_plan.nnfft_flags & PRE_FULL_PSI)
00067         nnfft_precompute_full_psi(&my_plan);
00068 
00070       if(my_plan.nnfft_flags & PRE_PHI_HUT)
00071         nnfft_precompute_phi_hut(&my_plan);
00072 
00074       nfft_vrand_unit_complex(my_plan.f_hat, my_plan.N_total);
00075 
00077       nndft_trafo(&my_plan);
00078 
00079       NFFT_SWAP_complex(my_plan.f,slow);
00080 
00082       nnfft_trafo(&my_plan);
00083 
00084       printf("%e, %e\n",
00085        nfft_error_l_infty_complex(slow, my_plan.f, M_total),
00086        nfft_error_l_infty_1_complex(slow, my_plan.f, M_total, my_plan.f_hat,
00087              my_plan.N_total));
00088 
00090       nnfft_finalize(&my_plan);
00091     }
00092 }
00093 
00094 int main(void)
00095 {
00096   int d;
00097   for(d=1; d<4; d++)
00098     accuracy(d);
00099 
00100   return 1;
00101 }

Generated on 17 Aug 2009 by Doxygen 1.5.3