37 static void reconstruct(
char* filename,
int N,
int M,
int Z,
int iteration,
int weight, fftw_complex *mem)
42 solver_plan_complex my_iplan;
45 double tmp, epsilon=0.0000003;
51 my_N[0]=N;my_n[0]=ceil(N*1.2);
52 my_N[1]=N; my_n[1]=ceil(N*1.2);
60 nfft_precompute_lin_psi(&my_plan);
67 solver_init_advanced_complex(&my_iplan,(nfft_mv_plan_complex*)(&my_plan), infft_flags );
72 fin=fopen(
"weights.dat",
"r");
73 for(j=0;j<my_plan.M_total;j++)
75 fscanf(fin,
"%le ",&my_iplan.w[j]);
87 double r=sqrt(j2*j2+k2*k2);
89 my_iplan.w_hat[j*N+k]=0.0;
91 my_iplan.w_hat[j*N+k]=1.0;
97 fin=fopen(filename,
"r");
103 for(j=0;j<my_plan.M_total;j++)
105 fscanf(fin,
"%le %le %le %le %le ",&my_plan.x[2*j+0],&my_plan.x[2*j+1], &tmp,
107 my_iplan.y[j] = real + _Complex_I*imag;
111 if(z==0 && my_plan.flags &
PRE_PSI)
112 nfft_precompute_psi(&my_plan);
116 nfft_precompute_full_psi(&my_plan);
119 for(k=0;k<my_plan.N_total;k++)
120 my_iplan.f_hat_iter[k]=0.0;
123 solver_before_loop_complex(&my_iplan);
124 for(l=0;l<iteration;l++)
127 if(my_iplan.dot_r_iter<epsilon)
129 fprintf(stderr,
"%e, %i of %i\n",sqrt(my_iplan.dot_r_iter),
130 iteration*z+l+1,iteration*Z);
131 solver_loop_one_step_complex(&my_iplan);
133 for(k=0;k<my_plan.N_total;k++) {
136 mem[(Z*N*N/2+z*N*N+ k)%(Z*N*N)] = my_iplan.f_hat_iter[k];
143 solver_finalize_complex(&my_iplan);
146 nfft_finalize(&my_plan);
153 static void print(
int N,
int M,
int Z, fftw_complex *mem)
158 fout_real=fopen(
"output_real.dat",
"w");
159 fout_imag=fopen(
"output_imag.dat",
"w");
162 for (j=0;j<N*N;j++) {
163 fprintf(fout_real,
"%le ",creal(mem[(Z*N*N/2+i*N*N+ j)%(Z*N*N)]) /Z);
164 fprintf(fout_imag,
"%le ",cimag(mem[(Z*N*N/2+i*N*N+ j)%(Z*N*N)]) /Z);
166 fprintf(fout_real,
"\n");
167 fprintf(fout_imag,
"\n");
174 int main(
int argc,
char **argv)
181 printf(
"usage: ./reconstruct FILENAME N M Z ITER WEIGHTS\n");
191 mem = (fftw_complex*) nfft_malloc(
sizeof(fftw_complex) * atoi(argv[2]) * atoi(argv[2]) * atoi(argv[4]));
194 plan = fftw_plan_many_dft(1, &Z, N*N,
199 FFTW_BACKWARD, FFTW_MEASURE);
202 reconstruct(argv[1],N,M,Z,atoi(argv[5]),atoi(argv[6]),mem);
212 fftw_destroy_plan(plan);
static void print(int N, int M, int Z, fftw_complex *mem)
print writes the memory back in a file output_real.dat for the real part and output_imag....
static void reconstruct(char *filename, int N, int M, int Z, int iteration, int weight, fftw_complex *mem)
reconstruct makes an inverse 2d-nfft for every slice
#define PRECOMPUTE_WEIGHT
Header file for the nfft3 library.