NFFT Logo 3.2.3
construct_data_3d.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_3d.c 3896 2012-10-10 12:19:26Z tovo $ */
20 #include "config.h"
21 
22 #include <stdlib.h>
23 #include <math.h>
24 #ifdef HAVE_COMPLEX_H
25 #include <complex.h>
26 #endif
27 
28 #include "nfft3util.h"
29 #include "nfft3.h"
30 
37 static void construct(char * file, int N, int M, int Z)
38 {
39  int j,k,l; /* some variables */
40  double real;
41  nfft_plan my_plan; /* plan for the three dimensional nfft */
42  FILE* fp,*fk;
43  int my_N[3],my_n[3]; /* to init the nfft */
44 
45 
46  /* initialise my_plan */
47  //nfft_init_3d(&my_plan,Z,N,N,M);
48  my_N[0]=Z; my_n[0]=ceil(Z*1.2);
49  my_N[1]=N; my_n[1]=ceil(N*1.2);
50  my_N[2]=N; my_n[2]=ceil(N*1.2);
51  nfft_init_guru(&my_plan, 3, my_N, M, my_n, 6,
52  PRE_PHI_HUT| PRE_PSI |MALLOC_X| MALLOC_F_HAT|
53  MALLOC_F| FFTW_INIT| FFT_OUT_OF_PLACE,
54  FFTW_MEASURE| FFTW_DESTROY_INPUT);
55 
56  fp=fopen("knots.dat","r");
57 
58  for(j=0;j<M;j++)
59  fscanf(fp,"%le %le %le",&my_plan.x[3*(j)+1],
60  &my_plan.x[3*(j)+2],&my_plan.x[3*(j)+0]);
61 
62  fclose(fp);
63 
64  fp=fopen("input_f.dat","r");
65  fk=fopen(file,"w");
66 
67  for(l=0;l<Z;l++) {
68  for(j=0;j<N;j++)
69  {
70  for(k=0;k<N;k++)
71  {
72  //fscanf(fp,"%le ",&my_plan.f_hat[(N*N*(Z-l)+N*j+k+N*N*Z/2)%(N*N*Z)][0]);
73  fscanf(fp,"%le ",&real);
74  my_plan.f_hat[(N*N*l+N*j+k)] = real;
75  }
76  }
77  }
78 
79  if(my_plan.nfft_flags & PRE_PSI)
80  nfft_precompute_psi(&my_plan);
81 
82  nfft_trafo(&my_plan);
83 
84 
85  for(j=0;j<my_plan.M_total;j++)
86  fprintf(fk,"%le %le %le %le %le\n",my_plan.x[3*j+1],
87  my_plan.x[3*j+2],my_plan.x[3*j+0],creal(my_plan.f[j]),cimag(my_plan.f[j]));
88 
89 
90 
91  fclose(fk);
92  fclose(fp);
93 
94  nfft_finalize(&my_plan);
95 }
96 
97 int main(int argc, char **argv)
98 {
99  if (argc <= 4) {
100  printf("usage: ./construct_data FILENAME N M Z\n");
101  return 1;
102  }
103 
104  construct(argv[1], atoi(argv[2]),atoi(argv[3]),atoi(argv[4]));
105 
106  return 1;
107 }
108 /* \} */

Generated on Tue Apr 30 2013 by Doxygen 1.8.1