00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <stdio.h>
00022 #include <math.h>
00023 #include <string.h>
00024 #include <stdlib.h>
00025 #include <complex.h>
00026
00027 #include "nfft3util.h"
00028 #include "nfft3.h"
00029
00030 void simple_test_nfft_1d(void)
00031 {
00032 nfft_plan p;
00033
00034 int N=14;
00035 int M=19;
00036
00038 nfft_init_1d(&p,N,M);
00039
00041 nfft_vrand_shifted_unit_double(p.x,p.M_total);
00042
00044 if(p.nfft_flags & PRE_ONE_PSI)
00045 nfft_precompute_one_psi(&p);
00046
00048 nfft_vrand_unit_complex(p.f_hat,p.N_total);
00049 nfft_vpr_complex(p.f_hat,p.N_total,"given Fourier coefficients, vector f_hat");
00050
00052 ndft_trafo(&p);
00053 nfft_vpr_complex(p.f,p.M_total,"ndft, vector f");
00054
00056 nfft_trafo(&p);
00057 nfft_vpr_complex(p.f,p.M_total,"nfft, vector f");
00058
00060 ndft_adjoint(&p);
00061 nfft_vpr_complex(p.f_hat,p.N_total,"adjoint ndft, vector f_hat");
00062
00064 nfft_adjoint(&p);
00065 nfft_vpr_complex(p.f_hat,p.N_total,"adjoint nfft, vector f_hat");
00066
00068 nfft_finalize(&p);
00069 }
00070
00071 void simple_test_nfft_2d(void)
00072 {
00073 int K,N[2],n[2];
00074 double t;
00075
00076 nfft_plan p;
00077
00078 N[0]=20; n[0]=32;
00079 N[1]=16; n[1]=32;
00080 K=12;
00081
00082 t=nfft_second();
00084 nfft_init_guru(&p, 2, N, N[0]*N[1], n, 4,
00085 PRE_PHI_HUT| PRE_PSI| MALLOC_F_HAT| MALLOC_X| MALLOC_F |
00086 FFTW_INIT| FFT_OUT_OF_PLACE,
00087 FFTW_ESTIMATE| FFTW_DESTROY_INPUT);
00088
00090 nfft_vrand_shifted_unit_double(p.x,p.d*p.M_total);
00091
00093 if(p.nfft_flags & PRE_ONE_PSI)
00094 nfft_precompute_one_psi(&p);
00095
00097 nfft_vrand_unit_complex(p.f_hat,p.N_total);
00098
00099 t=nfft_second()-t;
00100 nfft_vpr_complex(p.f_hat,K,
00101 "given Fourier coefficients, vector f_hat (first few entries)");
00102 printf(" ... initialisation took %e seconds.\n",t);
00103
00105 t=nfft_second();
00106 ndft_trafo(&p);
00107 t=nfft_second()-t;
00108 nfft_vpr_complex(p.f,K,"ndft, vector f (first few entries)");
00109 printf(" took %e seconds.\n",t);
00110
00112 t=nfft_second();
00113 nfft_trafo(&p);
00114 t=nfft_second()-t;
00115 nfft_vpr_complex(p.f,K,"nfft, vector f (first few entries)");
00116 printf(" took %e seconds.\n",t);
00117
00119 t=nfft_second();
00120 ndft_adjoint(&p);
00121 t=nfft_second()-t;
00122 nfft_vpr_complex(p.f_hat,K,"adjoint ndft, vector f_hat (first few entries)");
00123 printf(" took %e seconds.\n",t);
00124
00126 t=nfft_second();
00127 nfft_adjoint(&p);
00128 t=nfft_second()-t;
00129 nfft_vpr_complex(p.f_hat,K,"adjoint nfft, vector f_hat (first few entries)");
00130 printf(" took %e seconds.\n",t);
00131
00133 nfft_finalize(&p);
00134 }
00135
00136 int main(void)
00137 {
00138 system("clear");
00139 printf("1) computing an one dimensional ndft, nfft and an adjoint nfft\n\n");
00140 simple_test_nfft_1d();
00141 getc(stdin);
00142
00143 system("clear");
00144 printf("2) computing a two dimensional ndft, nfft and an adjoint nfft\n\n");
00145 simple_test_nfft_2d();
00146
00147 return 1;
00148 }