40 static void reconstruct(
char* filename,
int N,
int M,
int Z,
int weight ,fftw_complex *mem)
52 my_N[0]=N; my_n[0]=ceil(N*1.2);
53 my_N[1]=N; my_n[1]=ceil(N*1.2);
54 nfft_init_guru(&my_plan, 2, my_N, M/Z, my_n, 6, PRE_PHI_HUT| PRE_PSI|
55 MALLOC_X| MALLOC_F_HAT| MALLOC_F|
56 FFTW_INIT| FFT_OUT_OF_PLACE,
57 FFTW_MEASURE| FFTW_DESTROY_INPUT);
63 fin=fopen(filename,
"r");
66 fweight=fopen(
"weights.dat",
"r");
69 fscanf(fweight,
"%le ",&weights);
70 fscanf(fin,
"%le %le %le %le %le",
71 &my_plan.
x[2*j+0],&my_plan.
x[2*j+1],&tmp,&real,&imag);
72 my_plan.
f[j] = real + _Complex_I*imag;
74 my_plan.
f[j] = my_plan.
f[j] * weights;
80 nfft_precompute_psi(&my_plan);
84 nfft_precompute_full_psi(&my_plan);
87 nfft_adjoint(&my_plan);
89 for(k=0;k<my_plan.
N_total;k++) {
92 mem[(Z*N*N/2+z*N*N+ k)%(Z*N*N)] = my_plan.
f_hat[k];
97 nfft_finalize(&my_plan);
104 static void print(
int N,
int M,
int Z, fftw_complex *mem)
109 fout_real=fopen(
"output_real.dat",
"w");
110 fout_imag=fopen(
"output_imag.dat",
"w");
113 for (j=0;j<N*N;j++) {
114 fprintf(fout_real,
"%le ",creal(mem[(Z*N*N/2+i*N*N+ j)%(Z*N*N)]) /Z);
115 fprintf(fout_imag,
"%le ",cimag(mem[(Z*N*N/2+i*N*N+ j)%(Z*N*N)]) /Z);
117 fprintf(fout_real,
"\n");
118 fprintf(fout_imag,
"\n");
126 int main(
int argc,
char **argv)
133 printf(
"usage: ./reconstruct_data_gridding FILENAME N M Z ITER WEIGHTS\n");
143 mem = (fftw_complex*)
nfft_malloc(
sizeof(fftw_complex) * atoi(argv[2]) * atoi(argv[2]) * atoi(argv[4]));
146 plan = fftw_plan_many_dft(1, &Z, N*N,
151 FFTW_BACKWARD, FFTW_MEASURE);
154 reconstruct(argv[1],atoi(argv[2]),atoi(argv[3]),atoi(argv[4]),atoi(argv[6]),mem);
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
fftw_complex * f_hat
Vector of Fourier coefficients, size is N_total * sizeof( fftw_complex )
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...
fftw_complex * f
Vector of samples, size is M_total * sizeof( fftw_complex )
static void reconstruct(char *filename, int N, int M, int Z, int weight, fftw_complex *mem)
reconstruct makes an 2d-adjoint-nfft for every slice
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)
double * x
Nodes in time/spatial domain, size is doubles.
int N_total
Total number of Fourier coefficients.