NFFT Logo 3.2.3
construct_data_2d.c
1 /*
2  * Copyright (c) 2002, 2012 Jens Keiner, Stefan Kunis, Daniel Potts
3  *
4  * This program is free software; you can redistribute it and/or modify it under
5  * the terms of the GNU General Public License as published by the Free Software
6  * Foundation; either version 2 of the License, or (at your option) any later
7  * version.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12  * details.
13  *
14  * You should have received a copy of the GNU General Public License along with
15  * this program; if not, write to the Free Software Foundation, Inc., 51
16  * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  */
18 
19 /* $Id: construct_data_2d.c 3896 2012-10-10 12:19:26Z tovo $ */
20 
21 #include "config.h"
22 
23 #include <stdlib.h>
24 #include <math.h>
25 #ifdef HAVE_COMPLEX_H
26 #include <complex.h>
27 #endif
28 
29 #include "nfft3util.h"
30 #include "nfft3.h"
31 
41 static void construct(char * file, int N, int M)
42 {
43  int j,k; /* some variables */
44  double real;
45  nfft_plan my_plan; /* plan for the two dimensional nfft */
46  FILE* fp;
47  FILE* fk;
48  FILE* fi;
49 
50  /* initialise my_plan */
51  nfft_init_2d(&my_plan,N,N,M);
52 
53  fp=fopen("knots.dat","r");
54 
55  for(j=0;j<my_plan.M_total;j++)
56  {
57  fscanf(fp,"%le %le ",&my_plan.x[2*j+0],&my_plan.x[2*j+1]);
58  }
59  fclose(fp);
60 
61  fi=fopen("input_f.dat","r");
62  fk=fopen(file,"w");
63 
64  for(j=0;j<N;j++)
65  {
66  for(k=0;k<N;k++) {
67  fscanf(fi,"%le ",&real);
68  my_plan.f_hat[(N*j+k)] = real;
69  }
70  }
71 
72  if(my_plan.nfft_flags & PRE_PSI)
73  nfft_precompute_psi(&my_plan);
74 
75  nfft_trafo(&my_plan);
76 
77  for(j=0;j<my_plan.M_total;j++)
78  {
79  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]));
80  }
81  fclose(fk);
82  fclose(fi);
83 
84  nfft_finalize(&my_plan);
85 }
86 
87 int main(int argc, char **argv)
88 {
89  if (argc <= 3) {
90  printf("usage: ./construct_data FILENAME N M\n");
91  return 1;
92  }
93 
94  construct(argv[1],atoi(argv[2]),atoi(argv[3]));
95 
96  return 1;
97 }
98 /* \} */

Generated on Tue Apr 30 2013 by Doxygen 1.8.1