NFFT Logo 3.1.2 API Reference

construct_data_2d.c

00001 /*
00002  * Copyright (c) 2002, 2009 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 3198 2009-05-27 14:16:50Z keiner $ */
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;            /* some variables */
00040   double real;
00041   nfft_plan my_plan;  /* plan for the two dimensional nfft  */
00042   FILE* fp;
00043   FILE* fk;
00044   FILE* fi;
00045 
00046   /* initialise my_plan */
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 /* \} */

Generated on 16 Sep 2009 by Doxygen 1.5.3