33 static void reconstruct(
char* filename,
int N,
int M,
int iteration,
int weight)
44 double epsilon=0.0000003;
46 unsigned infft_flags = CGNR | PRECOMPUTE_DAMP;
50 my_N[0]=N; my_n[0]=ceil(N*alpha);
51 my_N[1]=N; my_n[1]=ceil(N*alpha);
52 nfft_init_guru(&my_plan, 2, my_N, M, my_n, m, PRE_PHI_HUT| PRE_PSI|
53 MALLOC_X| MALLOC_F_HAT| MALLOC_F|
54 FFTW_INIT| FFT_OUT_OF_PLACE,
55 FFTW_MEASURE| FFTW_DESTROY_INPUT);
58 if(my_plan.
flags & PRE_LIN_PSI)
59 nfft_precompute_lin_psi(&my_plan);
63 infft_flags = infft_flags | PRECOMPUTE_WEIGHT;
69 if(my_iplan.
flags & PRECOMPUTE_WEIGHT)
71 fin=fopen(
"weights.dat",
"r");
74 fscanf(fin,
"%le ",&my_iplan.
w[j]);
80 if(my_iplan.
flags & PRECOMPUTE_DAMP)
86 double r=sqrt(j2*j2+k2*k2);
88 my_iplan.
w_hat[j*N+k]=0.0;
90 my_iplan.
w_hat[j*N+k]=1.0;
96 fin=fopen(filename,
"r");
101 fscanf(fin,
"%le %le %le %le ",&my_plan.
x[2*j+0],&my_plan.
x[2*j+1],
103 my_iplan.
y[j] = real + _Complex_I*imag;
109 if(my_plan.
flags & PRE_PSI)
110 nfft_precompute_psi(&my_plan);
113 if(my_plan.
flags & PRE_FULL_PSI)
114 nfft_precompute_full_psi(&my_plan);
120 t0 = nfft_clock_gettime_seconds();
123 solver_before_loop_complex(&my_iplan);
124 for(l=0;l<iteration;l++)
129 fprintf(stderr,
"%e, %i of %i\n",sqrt(my_iplan.
dot_r_iter),
131 solver_loop_one_step_complex(&my_iplan);
135 t1 = nfft_clock_gettime_seconds();
138 fout_real=fopen(
"output_real.dat",
"w");
139 fout_imag=fopen(
"output_imag.dat",
"w");
141 for(k=0;k<my_plan.
N_total;k++) {
142 fprintf(fout_real,
"%le ", creal(my_iplan.
f_hat_iter[k]));
143 fprintf(fout_imag,
"%le ", cimag(my_iplan.
f_hat_iter[k]));
150 solver_finalize_complex(&my_iplan);
153 nfft_finalize(&my_plan);
156 int main(
int argc,
char **argv)
159 printf(
"usage: ./reconstruct_data_2d FILENAME N M ITER WEIGHTS\n");
163 reconstruct(argv[1],atoi(argv[2]),atoi(argv[3]),atoi(argv[4]),atoi(argv[5]));
double * w
weighting factors
unsigned flags
iteration type
double dot_r_iter
weighted dotproduct of r_iter
data structure for an NFFT (nonequispaced fast Fourier transform) plan with double precision ...
NFFT_INT N_total
Total number of Fourier coefficients.
NFFT_INT M_total
Total number of samples.
double * alpha
Precomputed recursion coefficients /f$^n/f$ for /f$k = 0,/ldots, N_{{max}}; n=-k,/ldots,k/f$ of associated Legendre-functions /f$P_k^n/f$.
fftw_complex * y
right hand side, samples
double * x
Nodes in time/spatial domain, size is doubles.
unsigned flags
Flags for precomputation, (de)allocation, and FFTW usage, default setting is PRE_PHI_HUT | PRE_PSI | ...
data structure for an inverse NFFT plan with double precision
double * w_hat
damping factors
static void reconstruct(char *filename, int N, int M, int iteration, int weight)
reconstruct makes an inverse 2d nfft
fftw_complex * f_hat_iter
iterative solution