/** * construct makes an 2d-nfft for every slice */ static void construct(char * file, int N, int M, int Z, fftw_complex *mem) { int j,z; /* some variables */ double tmp; /* a placeholder */ nfft_plan my_plan; /* plan for the two dimensional nfft */ FILE* fp; /* initialise my_plan */ nfft_init_2d(&my_plan,N,N,M/Z); fp=fopen("knots.dat","r"); for(j=0;j<my_plan.M_total;j++) { fscanf(fp,"%le %le %le",&my_plan.x[2*j+0],&my_plan.x[2*j+1],&tmp); } fclose(fp); fp=fopen(file,"w"); for(z=0;z<Z;z++) { tmp = (double) z; for(j=0;j<N*N;j++) my_plan.f_hat[j] = mem[(z*N*N+N*N*Z/2+j)%(N*N*Z)]; if(my_plan.flags & PRE_PSI) nfft_precompute_psi(&my_plan); nfft_trafo(&my_plan); for(j=0;j<my_plan.M_total;j++) { fprintf(fp,"%le %le %le %le %le\n",my_plan.x[2*j+0],my_plan.x[2*j+1],tmp/Z-0.5, creal(my_plan.f[j]),cimag(my_plan.f[j])); } } fclose(fp); nfft_finalize(&my_plan); }
void // space to frequency mad_cmat_nfft (const cnum_t x[], const num_t x_node[], cnum_t r[], ssz_t m, ssz_t n, ssz_t nr) { assert( x && r ); int precomp = 0; if (m != p_n1 || n != p_n2 || nr != p_m) { nfft_finalize(&p); nfft_init_2d (&p, m, n, nr); p_n1 = m, p_n2 = n, p_m = nr, precomp = 1; } if (x_node || precomp) { for (ssz_t i=0; i < m*n; i++) // adjoint transform needs -x_node p.x[i] = x_node[i] == -0.5 ? 0.4999999999999999 : -x_node[i]; if(p.flags & PRE_ONE_PSI) nfft_precompute_one_psi(&p); } mad_cvec_copy(x, p.f, m*n); const char *error_str = nfft_check(&p); if (error_str) error("%s", error_str); nfft_adjoint(&p); // nfft_adjoint_direct(&p); // mad_cvec_copy(p.f_hat, r, nr); mad_cvec_copy(p.f_hat+nr/2, r, nr/2); // for compatibility with FFTW ?? (TBC) mad_cvec_copy(p.f_hat, r+nr/2, nr/2); }
void // frequency to space mad_cmat_infft (const cnum_t x[], const num_t r_node[], cnum_t r[], ssz_t m, ssz_t n, ssz_t nx) { assert( x && r ); int precomp = 0; if (m != p_n1 || n != p_n2 || nx != p_m) { nfft_finalize(&p); nfft_init_2d (&p, m, n, nx); p_n1 = m, p_n2 = n, p_m = nx, precomp = 1; } if (r_node || precomp) { for (ssz_t i=0; i < m*n; i++) // forward transform needs -r_node p.x[i] = r_node[i] == -0.5 ? 0.4999999999999999 : -r_node[i]; if(p.flags & PRE_ONE_PSI) nfft_precompute_one_psi(&p); } // mad_cvec_copy(x, p.f_hat, nx); mad_cvec_copy(x+nx/2, p.f_hat, nx/2); // for compatibility with FFTW ?? (TBC) mad_cvec_copy(x, p.f_hat+nx/2, nx/2); const char *error_str = nfft_check(&p); if (error_str) error("%s", error_str); nfft_trafo(&p); // nfft_trafo_direct(&p); mad_cvec_copy(p.f, r, m*n); mad_cvec_muln(r, 1.0/(m*n), r, m*n); }
void FC_FUNC(oct_nfft_init_2d,OCT_NFFT_INIT_2D) (nfft_plan *plan, int *N1, int *N2, int *M) { nfft_init_2d(plan, *N1, *N2, *M); }