|
00001 #include <stdio.h> 00002 #include <math.h> 00003 #include <string.h> 00004 #include <stdlib.h> 00005 00006 #include "util.h" 00007 #include "nfft3.h" 00008 00009 void measure_time_nfft(int d, int N, unsigned test_ndft) 00010 { 00011 int r, M, NN[d], nn[d]; 00012 double t, t_fft, t_ndft, t_nfft; 00013 00014 nfft_plan p; 00015 fftw_plan p_fft; 00016 00017 printf("$%d$&\t",(int)(log(N)/log(2)*d+0.5)); 00018 00019 for(r=0,M=1;r<d;r++) 00020 { 00021 M=N*M; 00022 NN[r]=N; 00023 nn[r]=2*N; 00024 } 00025 00026 nfft_init_guru(&p, d, NN, M, nn, 4, 00027 PRE_PHI_HUT| PRE_PSI| MALLOC_F_HAT| MALLOC_X| MALLOC_F| 00028 FFTW_INIT| FFT_OUT_OF_PLACE, 00029 FFTW_ESTIMATE| FFTW_DESTROY_INPUT); 00030 00031 p_fft=fftw_plan_dft(d, NN, p.f_hat, p.f, FFTW_FORWARD, FFTW_MEASURE); 00032 00034 nfft_vrand_shifted_unit_double(p.x, p.d*p.M_total); 00035 00036 nfft_precompute_one_psi(&p); 00037 00039 nfft_vrand_unit_complex(p.f_hat, p.N_total); 00040 00042 t_fft=0; 00043 r=0; 00044 while(t_fft<0.1) 00045 { 00046 r++; 00047 t=nfft_second(); 00048 fftw_execute(p_fft); 00049 t=nfft_second()-t; 00050 t_fft+=t; 00051 } 00052 t_fft/=r; 00053 00054 printf("$%.1e$&\t",t_fft); 00055 00057 if(test_ndft) 00058 { 00059 t_ndft=0; 00060 r=0; 00061 while(t_ndft<0.1) 00062 { 00063 r++; 00064 t=nfft_second(); 00065 ndft_trafo(&p); 00066 t=nfft_second()-t; 00067 t_ndft+=t; 00068 } 00069 t_ndft/=r; 00070 printf("$%.1e$&\t",t_ndft); 00071 } 00072 else 00073 printf("*&\t\t"); 00074 00076 t_nfft=0; 00077 r=0; 00078 while(t_nfft<0.1) 00079 { 00080 r++; 00081 t=nfft_second(); 00082 nfft_trafo(&p); 00083 t=nfft_second()-t; 00084 t_nfft+=t; 00085 } 00086 t_nfft/=r; 00087 00088 if(d==1) 00089 printf("$%.1e$&\t",t_nfft); 00090 else 00091 printf("$%.1e$ \\\\\n",t_nfft); 00092 00093 fftw_destroy_plan(p_fft); 00094 nfft_finalize(&p); 00095 } 00096 00097 int main() 00098 { 00099 int l,d,logIN; 00100 00101 printf("\\multicolumn{4}{c|}{$d=1$}&\t\\multicolumn{4}{c|}{$d=2$}\\\\\n"); 00102 for(l=3;l<=22;l++) 00103 { 00104 d=1; 00105 logIN=l; 00106 if(logIN<=15) 00107 measure_time_nfft(d,(1U<< (logIN/d)),1); 00108 else 00109 measure_time_nfft(d,(1U<< (logIN/d)),0); 00110 00111 if(l<12) 00112 { 00113 d=2; 00114 logIN=d*l; 00115 if(logIN<=15) 00116 measure_time_nfft(d,(1U<< (logIN/d)),1); 00117 else 00118 measure_time_nfft(d,(1U<< (logIN/d)),0); 00119 } 00120 00121 if(l==12) 00122 printf("\\multicolumn{4}{c|}{$d=3$}\\\\\n"); 00123 00124 if((l>12)&&(l<=17)) 00125 { 00126 d=3; 00127 logIN=d*(l-10); 00128 if(logIN<=15) 00129 measure_time_nfft(d,(1U<< (logIN/d)),1); 00130 else 00131 measure_time_nfft(d,(1U<< (logIN/d)),0); 00132 } 00133 00134 if(l>17) 00135 printf(" & & & \\\\\n"); 00136 00137 fflush(stdout); 00138 } 00139 00140 return 1; 00141 }