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