NFFT Logo 3.0 API Reference
Main Page | Modules | Data Structures | Directories | File List | Data Fields | Globals

construct_data_2d.c

00001 #include <stdlib.h>
00002 
00003 #include "util.h"
00004 #include "nfft3.h"
00005 
00015 void construct(char * file, int N, int M)
00016 {
00017   int j,k;            /* some variables */
00018   double real;
00019   nfft_plan my_plan;  /* plan for the two dimensional nfft  */
00020   FILE* fp;
00021   FILE* fk;
00022   FILE* fi;
00023   
00024   /* initialise my_plan */
00025   nfft_init_2d(&my_plan,N,N,M);
00026 
00027   fp=fopen("knots.dat","r");
00028   
00029   for(j=0;j<my_plan.M_total;j++)
00030   {
00031     fscanf(fp,"%le %le ",&my_plan.x[2*j+0],&my_plan.x[2*j+1]);
00032   }
00033   fclose(fp);
00034 
00035   fi=fopen("input_f.dat","r");
00036   fk=fopen(file,"w");
00037 
00038   for(j=0;j<N;j++)
00039   {
00040     for(k=0;k<N;k++) {
00041       fscanf(fi,"%le ",&real);
00042       my_plan.f_hat[(N*j+k)] = real;
00043     }
00044   }
00045     
00046   if(my_plan.nfft_flags & PRE_PSI)
00047     nfft_precompute_psi(&my_plan);
00048 
00049   nfft_trafo(&my_plan);
00050 
00051   for(j=0;j<my_plan.M_total;j++)
00052   {
00053     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]));
00054   }
00055   fclose(fk);
00056   fclose(fi);
00057 
00058   nfft_finalize(&my_plan);
00059 }
00060 
00061 int main(int argc, char **argv)
00062 { 
00063   if (argc <= 3) {
00064     printf("usage: ./construct_data FILENAME N M\n");
00065     return 1;
00066   }
00067   
00068   construct(argv[1],atoi(argv[2]),atoi(argv[3]));
00069   
00070   return 1;
00071 }
00072 /* \} */

Generated on 1 Nov 2006 by Doxygen 1.4.4