26 #define MAX(a,b) (((a)>(b))?(a):(b))
38 static void reconstruct(
char* filename,
int N,
int M,
int iteration,
int weight)
50 double t,epsilon=0.0000003;
53 double time,min_time,max_time,min_inh,max_inh;
65 ftime=fopen(
"readout_time.dat",
"r");
66 finh=fopen(
"inh.dat",
"r");
68 min_time=INT_MAX; max_time=INT_MIN;
71 fscanf(ftime,
"%le ",&time);
80 Ts=(min_time+max_time)/2.0;
82 min_inh=INT_MAX; max_inh=INT_MIN;
85 fscanf(finh,
"%le ",&w[j]);
93 N3=ceil((MAX(fabs(min_inh),fabs(max_inh))*(max_time-min_time)/2.0)*4);
96 W=MAX(fabs(min_inh),fabs(max_inh))*2.0;
98 fprintf(stderr,
"3: %i %e %e %e %e %e %e\n",N3,W,min_inh,max_inh,min_time,max_time,Ts);
101 my_N[0]=N;my_n[0]=ceil(N*sigma);
102 my_N[1]=N; my_n[1]=ceil(N*sigma);
103 my_N[2]=N3; my_n[2]=ceil(N3*sigma);
121 fin=fopen(
"weights.dat",
"r");
124 fscanf(fin,
"%le ",&my_iplan.
w[j]);
136 double r=sqrt(j2*j2+k2*k2);
138 my_iplan.
w_hat[j*N+k]=0.0;
140 my_iplan.
w_hat[j*N+k]=1.0;
146 fin=fopen(filename,
"r");
147 ftime=fopen(
"readout_time.dat",
"r");
151 fscanf(fin,
"%le %le %le %le ",&my_plan.
x[3*j+0],&my_plan.
x[3*j+1],&real,&imag);
152 my_iplan.
y[j]=real+ _Complex_I*imag;
153 fscanf(ftime,
"%le ",&my_plan.
x[3*j+2]);
155 my_plan.
x[3*j+2] = (my_plan.
x[3*j+2]-Ts)*W/N3;
162 my_plan.
v[3*(N*j+l)+0]=(((
double) j) -(((
double) N)/2.0))/((
double) N);
163 my_plan.
v[3*(N*j+l)+1]=(((
double) l) -(((
double) N)/2.0))/((
double) N);
164 my_plan.
v[3*(N*j+l)+2] = w[N*j+l]/W ;
184 t0 = nfft_clock_gettime_seconds();
187 solver_before_loop_complex(&my_iplan);
188 for(l=0;l<iteration;l++)
193 fprintf(stderr,
"%e, %i of %i\n",sqrt(my_iplan.
dot_r_iter),
195 solver_loop_one_step_complex(&my_iplan);
198 t1 = nfft_clock_gettime_seconds();
201 fout_real=fopen(
"output_real.dat",
"w");
202 fout_imag=fopen(
"output_imag.dat",
"w");
204 for(k=0;k<my_plan.
N_total;k++) {
206 my_iplan.
f_hat_iter[k]*=cexp(2.0*_Complex_I*M_PI*Ts*w[k]);
208 fprintf(fout_real,
"%le ", creal(my_iplan.
f_hat_iter[k]));
209 fprintf(fout_imag,
"%le ", cimag(my_iplan.
f_hat_iter[k]));
218 solver_finalize_complex(&my_iplan);
226 int main(
int argc,
char **argv)
229 printf(
"usage: ./reconstruct_data_inh_nnfft FILENAME N M ITER WEIGHTS\n");
233 reconstruct(argv[1],atoi(argv[2]),atoi(argv[3]),atoi(argv[4]),atoi(argv[5]));
void nnfft_precompute_psi(nnfft_plan *ths_plan)
static void reconstruct(char *filename, int N, int M, int iteration, int weight)
reconstruct
unsigned nnfft_flags
flags for precomputation, malloc
#define PRECOMPUTE_WEIGHT
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
void nnfft_precompute_full_psi(nnfft_plan *ths_plan)
computes all entries of B explicitly
void nnfft_precompute_lin_psi(nnfft_plan *ths_plan)
create a lookup table
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)
fftw_complex * y
right hand side, samples
NFFT_INT N_total
Total number of Fourier coefficients.
Header file for the nfft3 library.
void nnfft_init_guru(nnfft_plan *ths_plan, int d, int N_total, int M_total, int *N, int *N1, int m, unsigned nnfft_flags)
data structure for an inverse NFFT plan with double precision
void nnfft_finalize(nnfft_plan *ths_plan)
double * w_hat
damping factors
fftw_complex * f_hat_iter
iterative solution