|
00001 #include <stdio.h> 00002 #include <math.h> 00003 #include <string.h> 00004 #include <stdlib.h> 00005 #include "util.h" 00006 #include "nfft3.h" 00007 00008 void simple_test_nfft_1d() 00009 { 00010 nfft_plan p; 00011 00012 int N=14; 00013 int M=19; 00014 00016 nfft_init_1d(&p,N,M); 00017 00019 nfft_vrand_shifted_unit_double(p.x,p.M_total); 00020 00022 if(p.nfft_flags & PRE_ONE_PSI) 00023 nfft_precompute_one_psi(&p); 00024 00026 nfft_vrand_unit_complex(p.f_hat,p.N_total); 00027 nfft_vpr_complex(p.f_hat,p.N_total,"given Fourier coefficients, vector f_hat"); 00028 00030 ndft_trafo(&p); 00031 nfft_vpr_complex(p.f,p.M_total,"ndft, vector f"); 00032 00034 nfft_trafo(&p); 00035 nfft_vpr_complex(p.f,p.M_total,"nfft, vector f"); 00036 00038 ndft_adjoint(&p); 00039 nfft_vpr_complex(p.f_hat,p.N_total,"adjoint ndft, vector f_hat"); 00040 00042 nfft_adjoint(&p); 00043 nfft_vpr_complex(p.f_hat,p.N_total,"adjoint nfft, vector f_hat"); 00044 00046 nfft_finalize(&p); 00047 } 00048 00049 void simple_test_nfft_2d() 00050 { 00051 int K,N[2],n[2]; 00052 double t; 00053 00054 nfft_plan p; 00055 00056 N[0]=70; n[0]=128; 00057 N[1]=50; n[1]=128; 00058 K=12; 00059 00060 t=nfft_second(); 00062 nfft_init_guru(&p, 2, N, N[0]*N[1], n, 4, 00063 PRE_PHI_HUT| PRE_PSI| MALLOC_F_HAT| MALLOC_X| MALLOC_F | 00064 FFTW_INIT| FFT_OUT_OF_PLACE, 00065 FFTW_ESTIMATE| FFTW_DESTROY_INPUT); 00066 00068 nfft_vrand_shifted_unit_double(p.x,p.d*p.M_total); 00069 00071 if(p.nfft_flags & PRE_ONE_PSI) 00072 nfft_precompute_one_psi(&p); 00073 00075 nfft_vrand_unit_complex(p.f_hat,p.N_total); 00076 00077 t=nfft_second()-t; 00078 nfft_vpr_complex(p.f_hat,K, 00079 "given Fourier coefficients, vector f_hat (first few entries)"); 00080 printf(" ... initialisation took %e seconds.\n",t); 00081 00083 t=nfft_second(); 00084 ndft_trafo(&p); 00085 t=nfft_second()-t; 00086 nfft_vpr_complex(p.f,K,"ndft, vector f (first few entries)"); 00087 printf(" took %e seconds.\n",t); 00088 00090 t=nfft_second(); 00091 nfft_trafo(&p); 00092 t=nfft_second()-t; 00093 nfft_vpr_complex(p.f,K,"nfft, vector f (first few entries)"); 00094 printf(" took %e seconds.\n",t); 00095 00097 t=nfft_second(); 00098 ndft_adjoint(&p); 00099 t=nfft_second()-t; 00100 nfft_vpr_complex(p.f_hat,K,"adjoint ndft, vector f_hat (first few entries)"); 00101 printf(" took %e seconds.\n",t); 00102 00104 t=nfft_second(); 00105 nfft_adjoint(&p); 00106 t=nfft_second()-t; 00107 nfft_vpr_complex(p.f_hat,K,"adjoint nfft, vector f_hat (first few entries)"); 00108 printf(" took %e seconds.\n",t); 00109 00111 nfft_finalize(&p); 00112 } 00113 00114 int main() 00115 { 00116 system("clear"); 00117 printf("1) computing an one dimensional ndft, nfft and an adjoint nfft\n\n"); 00118 simple_test_nfft_1d(); 00119 getc(stdin); 00120 00121 system("clear"); 00122 printf("2) computing a two dimensional ndft, nfft and an adjoint nfft\n\n"); 00123 simple_test_nfft_2d(); 00124 00125 return 1; 00126 }