00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <stdlib.h>
00022 #include <math.h>
00023 #include <complex.h>
00024
00025 #include "nfft3util.h"
00026 #include "nfft3.h"
00027
00037 void construct(char * file, int N, int M)
00038 {
00039 int j,k;
00040 double real;
00041 nfft_plan my_plan;
00042 FILE* fp;
00043 FILE* fk;
00044 FILE* fi;
00045
00046
00047 nfft_init_2d(&my_plan,N,N,M);
00048
00049 fp=fopen("knots.dat","r");
00050
00051 for(j=0;j<my_plan.M_total;j++)
00052 {
00053 fscanf(fp,"%le %le ",&my_plan.x[2*j+0],&my_plan.x[2*j+1]);
00054 }
00055 fclose(fp);
00056
00057 fi=fopen("input_f.dat","r");
00058 fk=fopen(file,"w");
00059
00060 for(j=0;j<N;j++)
00061 {
00062 for(k=0;k<N;k++) {
00063 fscanf(fi,"%le ",&real);
00064 my_plan.f_hat[(N*j+k)] = real;
00065 }
00066 }
00067
00068 if(my_plan.nfft_flags & PRE_PSI)
00069 nfft_precompute_psi(&my_plan);
00070
00071 nfft_trafo(&my_plan);
00072
00073 for(j=0;j<my_plan.M_total;j++)
00074 {
00075 fprintf(fk,"%le %le %le %le\n",my_plan.x[2*j+0],my_plan.x[2*j+1],creal(my_plan.f[j]),cimag(my_plan.f[j]));
00076 }
00077 fclose(fk);
00078 fclose(fi);
00079
00080 nfft_finalize(&my_plan);
00081 }
00082
00083 int main(int argc, char **argv)
00084 {
00085 if (argc <= 3) {
00086 printf("usage: ./construct_data FILENAME N M\n");
00087 return 1;
00088 }
00089
00090 construct(argv[1],atoi(argv[2]),atoi(argv[3]));
00091
00092 return 1;
00093 }
00094