40 static void reconstruct(
char* filename,
int N,
int M,
int Z,
int iteration,
int weight, fftw_complex *mem)
48 double tmp, epsilon=0.0000003;
51 unsigned infft_flags = CGNR | PRECOMPUTE_DAMP;
54 my_N[0]=N;my_n[0]=ceil(N*1.2);
55 my_N[1]=N; my_n[1]=ceil(N*1.2);
56 nfft_init_guru(&my_plan, 2, my_N, M/Z, my_n, 6, PRE_PHI_HUT| PRE_PSI|
57 MALLOC_X| MALLOC_F_HAT| MALLOC_F|
58 FFTW_INIT| FFT_OUT_OF_PLACE,
59 FFTW_MEASURE| FFTW_DESTROY_INPUT);
67 infft_flags = infft_flags | PRECOMPUTE_WEIGHT;
73 if(my_iplan.
flags & PRECOMPUTE_WEIGHT)
75 fin=fopen(
"weights.dat",
"r");
78 fscanf(fin,
"%le ",&my_iplan.
w[j]);
84 if(my_iplan.
flags & PRECOMPUTE_DAMP)
90 double r=sqrt(j2*j2+k2*k2);
92 my_iplan.
w_hat[j*N+k]=0.0;
94 my_iplan.
w_hat[j*N+k]=1.0;
100 fin=fopen(filename,
"r");
108 fscanf(fin,
"%le %le %le %le %le ",&my_plan.
x[2*j+0],&my_plan.
x[2*j+1], &tmp,
110 my_iplan.
y[j] = real + _Complex_I*imag;
115 nfft_precompute_psi(&my_plan);
119 nfft_precompute_full_psi(&my_plan);
126 solver_before_loop_complex(&my_iplan);
127 for(l=0;l<iteration;l++)
132 fprintf(stderr,
"%e, %i of %i\n",sqrt(my_iplan.
dot_r_iter),
133 iteration*z+l+1,iteration*Z);
136 for(k=0;k<my_plan.
N_total;k++) {
139 mem[(Z*N*N/2+z*N*N+ k)%(Z*N*N)] = my_iplan.
f_hat_iter[k];
149 nfft_finalize(&my_plan);
156 static void print(
int N,
int M,
int Z, fftw_complex *mem)
161 fout_real=fopen(
"output_real.dat",
"w");
162 fout_imag=fopen(
"output_imag.dat",
"w");
165 for (j=0;j<N*N;j++) {
166 fprintf(fout_real,
"%le ",creal(mem[(Z*N*N/2+i*N*N+ j)%(Z*N*N)]) /Z);
167 fprintf(fout_imag,
"%le ",cimag(mem[(Z*N*N/2+i*N*N+ j)%(Z*N*N)]) /Z);
169 fprintf(fout_real,
"\n");
170 fprintf(fout_imag,
"\n");
177 int main(
int argc,
char **argv)
184 printf(
"usage: ./reconstruct FILENAME N M Z ITER WEIGHTS\n");
194 mem = (fftw_complex*)
nfft_malloc(
sizeof(fftw_complex) * atoi(argv[2]) * atoi(argv[2]) * atoi(argv[4]));
197 plan = fftw_plan_many_dft(1, &Z, N*N,
202 FFTW_BACKWARD, FFTW_MEASURE);
205 reconstruct(argv[1],N,M,Z,atoi(argv[5]),atoi(argv[6]),mem);
215 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.dat for the imaginary part
double * w
weighting factors
unsigned flags
iteration type
double dot_r_iter
weighted dotproduct of r_iter
void nfft_precompute_lin_psi(nfft_plan *ths)
create a lookup table, but NOT for each node good idea K=2^xx TODO: estimate K, call from init assume...
int M_total
Total number of samples.
Header file for utility functions used by the nfft3 library.
unsigned nfft_flags
Flags for precomputation, (de)allocation, and FFTW usage, default setting is PRE_PHI_HUT | PRE_PSI | ...
void * nfft_malloc(size_t n)
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
fftw_complex * y
right hand side, samples
double * x
Nodes in time/spatial domain, size is doubles.
void solver_loop_one_step_complex(solver_plan_complex *ths)
void solver_loop_one_step
void solver_finalize_complex(solver_plan_complex *ths)
void solver_finalize
int N_total
Total number of Fourier coefficients.
double * w_hat
damping factors
fftw_complex * f_hat_iter
iterative solution