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 double t;
00034
00035 int N=14;
00036 int M=19;
00037 int n=32;
00038
00040 nfft_init_1d(&p,N,M);
00041
00043 nfft_vrand_shifted_unit_double(p.x,p.M_total);
00044
00046 if(p.nfft_flags & PRE_ONE_PSI)
00047 nfft_precompute_one_psi(&p);
00048
00050 nfft_vrand_unit_complex(p.f_hat,p.N_total);
00051 nfft_vpr_complex(p.f_hat,p.N_total,"given Fourier coefficients, vector f_hat");
00052
00054 t=nfft_second();
00055 ndft_trafo(&p);
00056 t=nfft_second()-t;
00057 nfft_vpr_complex(p.f,p.M_total,"ndft, vector f");
00058 printf(" took %e seconds.\n",t);
00059
00061 nfft_trafo(&p);
00062 nfft_vpr_complex(p.f,p.M_total,"nfft, vector f");
00063
00065 ndft_adjoint(&p);
00066 nfft_vpr_complex(p.f_hat,p.N_total,"adjoint ndft, vector f_hat");
00067
00069 nfft_adjoint(&p);
00070 nfft_vpr_complex(p.f_hat,p.N_total,"adjoint nfft, vector f_hat");
00071
00073 nfft_finalize(&p);
00074 }
00075
00076 void simple_test_nfft_2d(void)
00077 {
00078 int K,N[2],n[2],k,M;
00079 double t;
00080
00081 nfft_plan p;
00082
00083 N[0]=32; n[0]=64;
00084 N[1]=14; n[1]=32;
00085 M=N[0]*N[1];
00086 K=16;
00087
00088 t=nfft_second();
00090 nfft_init_guru(&p, 2, N, M, n, 7,
00091 PRE_PHI_HUT| PRE_FULL_PSI| MALLOC_F_HAT| MALLOC_X| MALLOC_F |
00092 FFTW_INIT| FFT_OUT_OF_PLACE,
00093 FFTW_ESTIMATE| FFTW_DESTROY_INPUT);
00094
00096 nfft_vrand_shifted_unit_double(p.x,p.d*p.M_total);
00097
00099 if(p.nfft_flags & PRE_ONE_PSI)
00100 nfft_precompute_one_psi(&p);
00101
00103 nfft_vrand_unit_complex(p.f_hat,p.N_total);
00104
00105 t=nfft_second()-t;
00106 nfft_vpr_complex(p.f_hat,K,
00107 "given Fourier coefficients, vector f_hat (first few entries)");
00108 printf(" ... initialisation took %e seconds.\n",t);
00109
00111 t=nfft_second();
00112 ndft_trafo(&p);
00113 t=nfft_second()-t;
00114 nfft_vpr_complex(p.f,K,"ndft, vector f (first few entries)");
00115 printf(" took %e seconds.\n",t);
00116
00118 t=nfft_second();
00119 nfft_trafo(&p);
00120 t=nfft_second()-t;
00121 nfft_vpr_complex(p.f,K,"nfft, vector f (first few entries)");
00122 printf(" took %e seconds.\n",t);
00123
00125 t=nfft_second();
00126 ndft_adjoint(&p);
00127 t=nfft_second()-t;
00128 nfft_vpr_complex(p.f_hat,K,"adjoint ndft, vector f_hat (first few entries)");
00129 printf(" took %e seconds.\n",t);
00130
00132 t=nfft_second();
00133 nfft_adjoint(&p);
00134 t=nfft_second()-t;
00135 nfft_vpr_complex(p.f_hat,K,"adjoint nfft, vector f_hat (first few entries)");
00136 printf(" took %e seconds.\n",t);
00137
00139 nfft_finalize(&p);
00140 }
00141
00142 int main(void)
00143 {
00144 system("clear");
00145 printf("1) computing an one dimensional ndft, nfft and an adjoint nfft\n\n");
00146 simple_test_nfft_1d();
00147 getc(stdin);
00148
00149 system("clear");
00150 printf("2) computing a two dimensional ndft, nfft and an adjoint nfft\n\n");
00151 simple_test_nfft_2d();
00152
00153 return 1;
00154 }