NFFT Logo 3.2.2
construct_data_2d.c
00001 /*
00002  * Copyright (c) 2002, 2012 Jens Keiner, Stefan Kunis, Daniel Potts
00003  *
00004  * This program is free software; you can redistribute it and/or modify it under
00005  * the terms of the GNU General Public License as published by the Free Software
00006  * Foundation; either version 2 of the License, or (at your option) any later
00007  * version.
00008  *
00009  * This program is distributed in the hope that it will be useful, but WITHOUT
00010  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00011  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
00012  * details.
00013  *
00014  * You should have received a copy of the GNU General Public License along with
00015  * this program; if not, write to the Free Software Foundation, Inc., 51
00016  * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  */
00018 
00019 /* $Id: construct_data_2d.c 3896 2012-10-10 12:19:26Z tovo $ */
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;            /* some variables */
00044   double real;
00045   nfft_plan my_plan;  /* plan for the two dimensional nfft  */
00046   FILE* fp;
00047   FILE* fk;
00048   FILE* fi;
00049 
00050   /* initialise my_plan */
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 /* \} */

Generated on Fri Oct 12 2012 by Doxygen 1.8.0-20120409