00001
00002 #include <stdio.h>
00003 #include <math.h>
00004 #include <string.h>
00005 #include <stdlib.h>
00006
00007
00008 #include "nfft3.h"
00009
00010
00011 #include "util.h"
00012
00013 void simple_test_nfsft()
00014 {
00015 int j;
00016 int k;
00017 int n;
00018 nfsft_plan plan;
00019 const int N = 8;
00020 const int M = 8;
00021 const int THRESHOLD = 1000;
00024
00025 nfsft_precompute(N,THRESHOLD,0U,0U);
00026
00027
00028
00029
00030
00031
00032
00033 nfsft_init_guru(&plan, N, M, NFSFT_MALLOC_X | NFSFT_MALLOC_F |
00034 NFSFT_MALLOC_F_HAT | NFSFT_NORMALIZED | NFSFT_PRESERVE_F_HAT,
00035 ((N>512)?(0U):(PRE_PHI_HUT | PRE_PSI)) | FFTW_INIT |
00036 FFT_OUT_OF_PLACE, 6);
00037
00038
00039 for (j = 0; j < plan.M_total; j++)
00040 {
00041 plan.x[2*j]=((double)rand())/RAND_MAX-0.5;
00042 plan.x[2*j+1]=0.5*((double)rand())/RAND_MAX;
00043 }
00044
00045
00046 nfsft_precompute_x(&plan);
00047
00048
00049 for (k = 0; k <= plan.N; k++)
00050 {
00051 for (n = -k; n <= k; n++)
00052 {
00053 plan.f_hat[NFSFT_INDEX(k,n,&plan)] =
00054 ((double)rand())/RAND_MAX - 0.5 + I*(((double)rand())/RAND_MAX - 0.5);
00055 }
00056 }
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067 ndsft_trafo(&plan);
00068 nfft_vpr_complex(plan.f,plan.M_total,"ndsft, vector f");
00069
00070
00071 nfsft_trafo(&plan);
00072 nfft_vpr_complex(plan.f, plan.M_total,"nfsft, vector f");
00073
00074
00075
00076
00077
00078
00079
00080 nfsft_adjoint(&plan);
00081 for (k = 0; k <= plan.N; k++)
00082 {
00083 for (n = -k; n <= k; n++)
00084 {
00085 fprintf(stdout,"f_hat[%d,%d] = %le + I*%le\n",k,n,
00086 creal(plan.f_hat[NFSFT_INDEX(k,n,&plan)]),
00087 cimag(plan.f_hat[NFSFT_INDEX(k,n,&plan)]));
00088 }
00089 }
00090
00091
00092
00093 ndsft_adjoint(&plan);
00094 for (k = 0; k <= plan.N; k++)
00095 {
00096 for (n = -k; n <= k; n++)
00097 {
00098 fprintf(stdout,"f_hat[%d,%d] = %le + I*%le\n",k,n,
00099 creal(plan.f_hat[NFSFT_INDEX(k,n,&plan)]),
00100 cimag(plan.f_hat[NFSFT_INDEX(k,n,&plan)]));
00101 }
00102 }
00103
00104
00105
00106 nfsft_finalize(&plan);
00107 nfsft_forget();
00108 }
00109
00110 int main()
00111 {
00112 system("clear");
00113 printf("1) computing a ndsft, a nfsft, an adjoint ndsft, and an adjoint nfsft\n\n");
00114 simple_test_nfsft();
00115
00116 return EXIT_SUCCESS;
00117 }