32 #define MACRO_nndft_init_result_trafo memset(f,0,ths->M_total*sizeof(double _Complex));
33 #define MACRO_nndft_init_result_conjugated MACRO_nndft_init_result_trafo
34 #define MACRO_nndft_init_result_adjoint memset(f_hat,0,ths->N_total*sizeof(double _Complex));
35 #define MACRO_nndft_init_result_transposed MACRO_nndft_init_result_adjoint
37 #define MACRO_nndft_sign_trafo (-2.0*KPI)
38 #define MACRO_nndft_sign_conjugated (+2.0*KPI)
39 #define MACRO_nndft_sign_adjoint (+2.0*KPI)
40 #define MACRO_nndft_sign_transposed (-2.0*KPI)
42 #define MACRO_nndft_compute_trafo (*fj) += (*f_hat_k)*cexp(+ _Complex_I*omega);
44 #define MACRO_nndft_compute_conjugated MACRO_nndft_compute_trafo
46 #define MACRO_nndft_compute_adjoint (*f_hat_k) += (*fj)*cexp(+ _Complex_I*omega);
48 #define MACRO_nndft_compute_transposed MACRO_nndft_compute_adjoint
50 #define MACRO_nndft(which_one) \
51 void nnfft_ ## which_one ## _direct (nnfft_plan *ths) \
56 double _Complex *f_hat, *f; \
57 double _Complex *f_hat_k; \
58 double _Complex *fj; \
61 f_hat=ths->f_hat; f=ths->f; \
63 MACRO_nndft_init_result_ ## which_one \
65 for(j=0, fj=f; j<ths->M_total; j++, fj++) \
67 for(l=0, f_hat_k=f_hat; l<ths->N_total; l++, f_hat_k++) \
70 for(t = 0; t<ths->d; t++) \
71 omega+=ths->v[l*ths->d+t] * ths->x[j*ths->d+t] * ths->N[t]; \
73 omega*= MACRO_nndft_sign_ ## which_one; \
75 MACRO_nndft_compute_ ## which_one \
86 static
void nnfft_uo(
nnfft_plan *ths,
int j,
int *up,
int *op,
int act_dim)
91 c = ths->v[j*ths->d+act_dim] * ths->n[act_dim];
99 u = u - (ths->m); o = o + (ths->m);
107 #define MACRO_nnfft_B_init_result_A memset(f,0,ths->N_total*sizeof(double _Complex));
108 #define MACRO_nnfft_B_init_result_T memset(g,0,ths->aN1_total*sizeof(double _Complex));
110 #define MACRO_nnfft_B_PRE_FULL_PSI_compute_A { \
111 (*fj) += ths->psi[ix] * g[ths->psi_index_g[ix]]; \
114 #define MACRO_nnfft_B_PRE_FULL_PSI_compute_T { \
115 g[ths->psi_index_g[ix]] += ths->psi[ix] * (*fj); \
118 #define MACRO_nnfft_B_compute_A { \
119 (*fj) += phi_prod[ths->d] * g[ll_plain[ths->d]]; \
122 #define MACRO_nnfft_B_compute_T { \
123 g[ll_plain[ths->d]] += phi_prod[ths->d] * (*fj); \
126 #define MACRO_with_PRE_LIN_PSI (ths->psi[(ths->K+1)*t2+y_u[t2]]* \
127 (y_u[t2]+1-y[t2]) + \
128 ths->psi[(ths->K+1)*t2+y_u[t2]+1]* \
130 #define MACRO_with_PRE_PSI ths->psi[(j*ths->d+t2)*(2*ths->m+2)+lj[t2]]
131 #define MACRO_without_PRE_PSI PHI(ths->n[t2], -ths->v[j*ths->d+t2]+ \
132 ((double)l[t2])/ths->N1[t2], t2)
134 #define MACRO_init_uo_l_lj_t { \
135 for(t = ths->d-1; t>=0; t--) \
137 nnfft_uo(ths,j,&u[t],&o[t],t); \
144 #define MACRO_update_with_PRE_PSI_LIN { \
145 for(t2=t; t2<ths->d; t2++) \
147 y[t2] = fabs(((-ths->N1[t2]*ths->v[j*ths->d+t2]+(double)l[t2]) \
148 * ((double)ths->K))/(ths->m+1)); \
149 y_u[t2] = (int)y[t2]; \
153 #define MACRO_update_phi_prod_ll_plain(which_one) { \
154 for(t2=t; t2<ths->d; t2++) \
156 phi_prod[t2+1]=phi_prod[t2]* MACRO_ ## which_one; \
157 ll_plain[t2+1]=ll_plain[t2]*ths->aN1[t2] + \
158 (l[t2]+ths->aN1[t2]*3/2)%ths->aN1[t2]; \
163 #define MACRO_count_uo_l_lj_t { \
164 for(t = ths->d-1; (t>0)&&(l[t]==o[t]); t--) \
174 #define MACRO_nnfft_B(which_one) \
175 static inline void nnfft_B_ ## which_one (nnfft_plan *ths) \
178 int u[ths->d], o[ths->d]; \
184 int ll_plain[ths->d+1]; \
185 double phi_prod[ths->d+1]; \
186 double _Complex *f, *g; \
187 double _Complex *fj; \
191 f=ths->f_hat; g=ths->F; \
193 MACRO_nnfft_B_init_result_ ## which_one \
195 if(ths->nnfft_flags & PRE_FULL_PSI) \
197 for(ix=0, j=0, fj=f; j<ths->N_total; j++,fj++) \
198 for(l_L=0; l_L<ths->psi_index_f[j]; l_L++, ix++) \
199 MACRO_nnfft_B_PRE_FULL_PSI_compute_ ## which_one; \
206 for(t=0,lprod = 1; t<ths->d; t++) \
207 lprod *= (2*ths->m+2); \
209 if(ths->nnfft_flags & PRE_PSI) \
211 for(j=0, fj=f; j<ths->N_total; j++, fj++) \
213 MACRO_init_uo_l_lj_t; \
215 for(l_L=0; l_L<lprod; l_L++) \
217 MACRO_update_phi_prod_ll_plain(with_PRE_PSI); \
219 MACRO_nnfft_B_compute_ ## which_one; \
221 MACRO_count_uo_l_lj_t; \
227 if(ths->nnfft_flags & PRE_LIN_PSI) \
229 for(j=0, fj=f; j<ths->N_total; j++, fj++) \
231 MACRO_init_uo_l_lj_t; \
233 for(l_L=0; l_L<lprod; l_L++) \
235 MACRO_update_with_PRE_PSI_LIN; \
237 MACRO_update_phi_prod_ll_plain(with_PRE_LIN_PSI); \
239 MACRO_nnfft_B_compute_ ## which_one; \
241 MACRO_count_uo_l_lj_t; \
248 for(j=0, fj=f; j<ths->N_total; j++, fj++) \
251 MACRO_init_uo_l_lj_t; \
253 for(l_L=0; l_L<lprod; l_L++) \
255 MACRO_update_phi_prod_ll_plain(without_PRE_PSI); \
257 MACRO_nnfft_B_compute_ ## which_one; \
259 MACRO_count_uo_l_lj_t; \
273 for(j=0; j<ths->M_total; j++)
274 ths->f[j] *= ths->c_phi_inv[j];
278 for(j=0; j<ths->M_total; j++)
282 for(t=0; t<ths->d; t++)
283 tmp*= 1.0 /((PHI_HUT(ths->n[t], ths->x[ths->d*j + t]*((
double)ths->N[t]),t)) );
298 for(t=0;t<ths->
d;t++) {
299 ths->
x[j*ths->
d+t]= ths->
x[j*ths->
d+t] / ((double)ths->
sigma[t]);
310 for(t=0;t<ths->
d;t++) {
311 ths->
x[j*ths->
d+t]= ths->
x[j*ths->
d+t] * ((double)ths->
sigma[t]);
326 for(t=0;t<ths->
d;t++) {
327 ths->
x[j*ths->
d+t]= ths->
x[j*ths->
d+t] / ((double)ths->
sigma[t]);
337 for(t=0;t<ths->
d;t++) {
338 ths->
x[j*ths->
d+t]= ths->
x[j*ths->
d+t] * ((double)ths->
sigma[t]);
358 for(t=0; t<ths->
d; t++)
359 tmp*= 1.0 /(PHI_HUT(ths->
n[t],ths->
x[ths->
d*j + t]*((
double)ths->
N[t]),t));
375 for (t=0; t<ths->
d; t++)
377 step=((double)(ths->
m+1))/(ths->
K*ths->
N1[t]);
378 for(j=0;j<=ths->
K;j++)
380 ths->
psi[(ths->
K+1)*t + j] = PHI(ths->
n[t],j*step,t);
393 for (t=0; t<ths->
d; t++)
396 nnfft_uo(ths,j,&u,&o,t);
398 for(l=u, lj=0; l <= o; l++, lj++)
399 ths->
psi[(j*ths->
d+t)*(2*ths->
m+2)+lj]=
400 (PHI(ths->
n[t],(-ths->
v[j*ths->
d+t]+((
double)l)/((
double)ths->
N1[t])),t));
404 for(t=0;t<ths->
d;t++) {
405 ths->
x[j*ths->
d+t]= ths->
x[j*ths->
d+t] / ((double)ths->
sigma[t]);
412 for(t=0;t<ths->
d;t++) {
413 ths->
x[j*ths->
d+t]= ths->
x[j*ths->
d+t] * ((double)ths->
sigma[t]);
431 int ll_plain[ths->
d+1];
433 int u[ths->
d], o[ths->
d];
435 double phi_prod[ths->
d+1];
440 for(t=0;t<ths->
d;t++) {
441 ths->
x[j*ths->
d+t]= ths->
x[j*ths->
d+t] / ((double)ths->
sigma[t]);
450 for(t=0;t<ths->
d;t++) {
451 ths->
x[j*ths->
d+t]= ths->
x[j*ths->
d+t] * ((double)ths->
sigma[t]);
458 for(t=0,lprod = 1; t<ths->
d; t++)
461 for(j=0,ix=0,ix_old=0; j<ths->N_total; j++)
463 MACRO_init_uo_l_lj_t;
465 for(l_L=0; l_L<lprod; l_L++, ix++)
467 MACRO_update_phi_prod_ll_plain(without_PRE_PSI);
470 ths->
psi[ix]=phi_prod[ths->
d];
472 MACRO_count_uo_l_lj_t;
481 void nnfft_precompute_one_psi(
nnfft_plan *ths)
494 static void nnfft_init_help(
nnfft_plan *ths,
int m2,
unsigned nfft_flags,
unsigned fftw_flags)
510 for(t = 0; t<ths->
d; t++) {
511 ths->
a[t] = 1.0 + (2.0*((double)ths->
m))/((
double)ths->
N1[t]);
512 ths->
aN1[t] = ths->
a[t] * ((double)ths->
N1[t]);
514 if(ths->
aN1[t]%2 != 0)
515 ths->
aN1[t] = ths->
aN1[t] +1;
518 ths->
sigma[t] = ((double) ths->
N1[t] )/((double) ths->
N[t]);;
521 N2[t] = ceil(ths->
sigma[t]*(ths->
aN1[t]));
547 ths->
K=(1U<< 10)*(ths->
m+1);
557 for(t=0,lprod = 1; t<ths->
d; t++)
567 nfft_flags, fftw_flags);
578 int m,
unsigned nnfft_flags)
590 fftw_flags= FFTW_ESTIMATE| FFTW_DESTROY_INPUT;
594 nfft_flags = nfft_flags |
PRE_PSI;
609 nnfft_init_help(ths,m,nfft_flags,fftw_flags);
627 ths->
m=WINDOW_HELP_ESTIMATE_m;
636 ths->
N1[t] = ceil(1.5*ths->
N[t]);
639 if(ths->
N1[t]%2 != 0)
640 ths->
N1[t] = ths->
N1[t] +1;
646 fftw_flags= FFTW_ESTIMATE| FFTW_DESTROY_INPUT;
647 nnfft_init_help(ths,ths->
m,nfft_flags,fftw_flags);
650 void nnfft_init_1d(
nnfft_plan *ths,
int N1,
int M_total)
void nnfft_precompute_psi(nnfft_plan *ths)
fftw_complex * f_hat
Fourier coefficients.
double * psi
precomputed data, matrix B
int * psi_index_g
only for thin B
fftw_complex * f_hat
Fourier coefficients.
unsigned nnfft_flags
flags for precomputation, malloc
int * N
cut-off-frequencies
void nnfft_init(nnfft_plan *ths, int d, int N_total, int M_total, int *N)
void nfft_precompute_lin_psi(nfft_plan *ths)
void nnfft_adjoint(nnfft_plan *ths)
void nfft_precompute_full_psi(nfft_plan *ths)
double * v
nodes (in fourier domain)
void nnfft_trafo(nnfft_plan *ths)
user routines
void nfft_adjoint(nfft_plan *ths)
int * psi_index_f
only for thin B
nfft_plan * direct_plan
plan for the nfft
void nnfft_precompute_phi_hut(nnfft_plan *ths)
initialisation of direct transform
int m
cut-off parameter in time-domain
void nnfft_precompute_full_psi(nnfft_plan *ths)
computes all entries of B explicitly
int aN1_total
aN1_total=aN1[0]* ...
void nnfft_precompute_lin_psi(nnfft_plan *ths)
create a lookup table
void nfft_precompute_psi(nfft_plan *ths)
data structure for an NFFT (nonequispaced fast Fourier transform) plan with double precision ...
NFFT_INT M_total
Total number of samples.
data structure for an NNFFT (nonequispaced in time and frequency fast Fourier transform) plan with do...
int * n
n=N1, for the window function
double * x
nodes (in time/spatial domain)
double * sigma
oversampling-factor
void(* mv_trafo)(void *)
Transform.
void nfft_trafo(nfft_plan *ths)
void * nfft_malloc(size_t n)
void nfft_finalize(nfft_plan *ths)
NFFT_INT N_total
Total number of Fourier coefficients.
Header file for the nfft3 library.
double * x
Nodes in time/spatial domain, size is doubles.
void nnfft_init_guru(nnfft_plan *ths, int d, int N_total, int M_total, int *N, int *N1, int m, unsigned nnfft_flags)
double * c_phi_inv
precomputed data, matrix D
void nnfft_finalize(nnfft_plan *ths)
void(* mv_adjoint)(void *)
Adjoint transform.