![]() |
NFFT
3.3.2
|
00001 /* 00002 * Copyright (c) 2002, 2016 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 #include "config.h" 00020 00021 #include <stdlib.h> 00022 #include <math.h> 00023 #ifdef HAVE_COMPLEX_H 00024 #include <complex.h> 00025 #endif 00026 00027 #include "nfft3.h" 00028 00038 static void construct(char * file, int N, int M) 00039 { 00040 int j,k; /* some variables */ 00041 double real; 00042 nfft_plan my_plan; /* plan for the two dimensional nfft */ 00043 FILE* fp; 00044 FILE* fk; 00045 FILE* fi; 00046 00047 /* initialise my_plan */ 00048 nfft_init_2d(&my_plan,N,N,M); 00049 00050 fp=fopen("knots.dat","r"); 00051 00052 for(j=0;j<my_plan.M_total;j++) 00053 { 00054 fscanf(fp,"%le %le ",&my_plan.x[2*j+0],&my_plan.x[2*j+1]); 00055 } 00056 fclose(fp); 00057 00058 fi=fopen("input_f.dat","r"); 00059 fk=fopen(file,"w"); 00060 00061 for(j=0;j<N;j++) 00062 { 00063 for(k=0;k<N;k++) { 00064 fscanf(fi,"%le ",&real); 00065 my_plan.f_hat[(N*j+k)] = real; 00066 } 00067 } 00068 00069 if(my_plan.flags & PRE_PSI) 00070 nfft_precompute_psi(&my_plan); 00071 00072 nfft_trafo(&my_plan); 00073 00074 for(j=0;j<my_plan.M_total;j++) 00075 { 00076 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])); 00077 } 00078 fclose(fk); 00079 fclose(fi); 00080 00081 nfft_finalize(&my_plan); 00082 } 00083 00084 int main(int argc, char **argv) 00085 { 00086 if (argc <= 3) { 00087 printf("usage: ./construct_data FILENAME N M\n"); 00088 return 1; 00089 } 00090 00091 construct(argv[1],atoi(argv[2]),atoi(argv[3])); 00092 00093 return 1; 00094 } 00095 /* \} */