28 #define MAX(a,b) (((a)>(b))?(a):(b))
40 static void reconstruct(
char* filename,
int N,
int M,
int iteration,
int weight)
52 double t,epsilon=0.0000003;
54 unsigned infft_flags = CGNR | PRECOMPUTE_DAMP;
55 double time,min_time,max_time,min_inh,max_inh;
67 ftime=fopen(
"readout_time.dat",
"r");
68 finh=fopen(
"inh.dat",
"r");
70 min_time=INT_MAX; max_time=INT_MIN;
73 fscanf(ftime,
"%le ",&time);
82 Ts=(min_time+max_time)/2.0;
84 min_inh=INT_MAX; max_inh=INT_MIN;
87 fscanf(finh,
"%le ",&w[j]);
95 N3=ceil((MAX(fabs(min_inh),fabs(max_inh))*(max_time-min_time)/2.0)*4);
98 W=MAX(fabs(min_inh),fabs(max_inh))*2.0;
100 fprintf(stderr,
"3: %i %e %e %e %e %e %e\n",N3,W,min_inh,max_inh,min_time,max_time,Ts);
103 my_N[0]=N;my_n[0]=ceil(N*sigma);
104 my_N[1]=N; my_n[1]=ceil(N*sigma);
105 my_N[2]=N3; my_n[2]=ceil(N3*sigma);
106 nnfft_init_guru(&my_plan, 3, N*N, M, my_N,my_n,m,
107 PRE_PSI| PRE_PHI_HUT| MALLOC_X| MALLOC_V| MALLOC_F_HAT| MALLOC_F );
115 infft_flags = infft_flags | PRECOMPUTE_WEIGHT;
121 if(my_iplan.
flags & PRECOMPUTE_WEIGHT)
123 fin=fopen(
"weights.dat",
"r");
126 fscanf(fin,
"%le ",&my_iplan.
w[j]);
132 if(my_iplan.
flags & PRECOMPUTE_DAMP)
138 double r=sqrt(j2*j2+k2*k2);
140 my_iplan.
w_hat[j*N+k]=0.0;
142 my_iplan.
w_hat[j*N+k]=1.0;
148 fin=fopen(filename,
"r");
149 ftime=fopen(
"readout_time.dat",
"r");
153 fscanf(fin,
"%le %le %le %le ",&my_plan.
x[3*j+0],&my_plan.
x[3*j+1],&real,&imag);
154 my_iplan.
y[j]=real+ _Complex_I*imag;
155 fscanf(ftime,
"%le ",&my_plan.
x[3*j+2]);
157 my_plan.
x[3*j+2] = (my_plan.
x[3*j+2]-Ts)*W/N3;
164 my_plan.
v[3*(N*j+l)+0]=(((
double) j) -(((
double) N)/2.0))/((
double) N);
165 my_plan.
v[3*(N*j+l)+1]=(((
double) l) -(((
double) N)/2.0))/((
double) N);
166 my_plan.
v[3*(N*j+l)+2] = w[N*j+l]/W ;
172 nnfft_precompute_psi(&my_plan);
186 t0 = nfft_clock_gettime_seconds();
189 solver_before_loop_complex(&my_iplan);
190 for(l=0;l<iteration;l++)
195 fprintf(stderr,
"%e, %i of %i\n",sqrt(my_iplan.
dot_r_iter),
197 solver_loop_one_step_complex(&my_iplan);
200 t1 = nfft_clock_gettime_seconds();
203 fout_real=fopen(
"output_real.dat",
"w");
204 fout_imag=fopen(
"output_imag.dat",
"w");
206 for(k=0;k<my_plan.
N_total;k++) {
208 my_iplan.
f_hat_iter[k]*=cexp(2.0*_Complex_I*M_PI*Ts*w[k]);
210 fprintf(fout_real,
"%le ", creal(my_iplan.
f_hat_iter[k]));
211 fprintf(fout_imag,
"%le ", cimag(my_iplan.
f_hat_iter[k]));
220 solver_finalize_complex(&my_iplan);
223 nnfft_finalize(&my_plan);
228 int main(
int argc,
char **argv)
231 printf(
"usage: ./reconstruct_data_inh_nnfft FILENAME N M ITER WEIGHTS\n");
235 reconstruct(argv[1],atoi(argv[2]),atoi(argv[3]),atoi(argv[4]),atoi(argv[5]));
static void reconstruct(char *filename, int N, int M, int iteration, int weight)
reconstruct
void nnfft_precompute_full_psi(nnfft_plan *ths_plan)
computes all entries of B explicitly
unsigned nnfft_flags
flags for precomputation, malloc
double * w
weighting factors
unsigned flags
iteration type
double dot_r_iter
weighted dotproduct of r_iter
double * v
nodes (in fourier domain)
void nnfft_precompute_phi_hut(nnfft_plan *ths_plan)
initialisation of direct transform
NFFT_INT M_total
Total number of samples.
data structure for an NNFFT (nonequispaced in time and frequency fast Fourier transform) plan with do...
double * x
nodes (in time/spatial domain)
void * nfft_malloc(size_t n)
void nnfft_precompute_lin_psi(nnfft_plan *ths_plan)
create a lookup table
fftw_complex * y
right hand side, samples
NFFT_INT N_total
Total number of Fourier coefficients.
data structure for an inverse NFFT plan with double precision
double * w_hat
damping factors
fftw_complex * f_hat_iter
iterative solution