32 #define DEFAULT_NFFT_CUTOFF 6
33 #define FPT_THRESHOLD 1000
35 static fpt_set SO3_fpt_init(
int l,
unsigned int flags,
int kappa);
44 unsigned int nfsoft_flags)
48 DEFAULT_NFFT_CUTOFF, FPT_THRESHOLD);
52 unsigned int nfsoft_flags,
unsigned int nfft_flags,
int nfft_cutoff,
55 nfsoft_init_guru_advanced(plan, B, M, nfsoft_flags, nfft_flags, nfft_cutoff, fpt_kappa, 8* B);
58 void nfsoft_init_guru_advanced(
nfsoft_plan *plan,
int B,
int M,
59 unsigned int nfsoft_flags,
unsigned int nfft_flags,
int nfft_cutoff,
60 int fpt_kappa,
int nn_oversampled)
69 n[0] = nn_oversampled ;
70 n[1] = nn_oversampled ;
71 n[2] = nn_oversampled ;
73 nfft_init_guru(&plan->
p_nfft, 3, N, M, n, nfft_cutoff, nfft_flags,
74 FFTW_ESTIMATE | FFTW_DESTROY_INPUT);
83 plan->fpt_kappa = fpt_kappa;
84 plan->
flags = nfsoft_flags;
89 if (plan->
f_hat == NULL ) printf(
"Allocation failed!\n");
95 if (plan->
x == NULL ) printf(
"Allocation failed!\n");
100 if (plan->
f == NULL ) printf(
"Allocation failed!\n");
107 if (plan->
wig_coeffs == NULL ) printf(
"Allocation failed!\n");
108 if (plan->
cheby == NULL ) printf(
"Allocation failed!\n");
109 if (plan->
aux == NULL ) printf(
"Allocation failed!\n");
127 my_plan->
cheby[0]=0.0;
129 for (j=1;j<my_plan->
N_total+1;j++)
138 aux[j]=my_plan->
cheby[j];
145 my_plan->
cheby[0]=(C) (-1.)/(2.*_Complex_I) * aux[1];
148 my_plan->
cheby[j]=(1./(2.*_Complex_I)*(aux[j+1]-aux[j-1]));
157 static fpt_set SO3_fpt_init(
int l,
unsigned int flags,
int kappa)
160 int N, t, k_start, k_end, k, m;
172 t = (int) log2(
X(next_power_of_2)(N));
181 N =
X(next_power_of_2)(l);
198 set =
fpt_init((2* N + 1) * (2* N + 1), t, 0U);
201 for (k = -N; k <= N; k++)
202 for (m = -N; m <= N; m++)
205 k_start = (ABS(k) >= ABS(m)) ? ABS(k) : ABS(m);
226 static fpt_set SO3_single_fpt_init(
int l,
int k,
int m,
unsigned int flags,
int kappa)
228 int N, t, k_start, k_end;
233 if (flags & NFSOFT_USE_DPT)
240 t = (int) log2(
X(next_power_of_2)(N));
249 N =
X(next_power_of_2)(l);
261 unsigned int fptflags = 0U
268 k_start = (ABS(k) >= ABS(m)) ? ABS(k) : ABS(m);
293 void SO3_fpt(C *coeffs,
fpt_set set,
int l,
int k,
int m,
unsigned int flags)
302 int k_start, k_end, j;
303 int function_values = 0;
306 if (flags & NFSOFT_USE_DPT)
317 N =
X(next_power_of_2)(l);
321 k_start = (ABS(k) >= ABS(m)) ? ABS(k) : ABS(m);
323 trafo_nr = (N + k) * (2* N + 1) + (m + N);
328 for (j = 0; j <= k_end; j++)
332 for (j = 0; j <= l - k_start; j++)
334 x[j + k_start] = coeffs[j];
336 for (j = l - k_start + 1; j <= k_end - k_start; j++)
338 x[j + k_start] = K(0.0);
344 if (flags & NFSOFT_USE_DPT)
346 fpt_trafo_direct(set, trafo_nr, &x[k_start], y, k_end, 0U
351 fpt_trafo(set, trafo_nr, &x[k_start], y, k_end, 0U
356 for (j = 0; j <= l; j++)
369 void SO3_fpt_transposed(C *coeffs,
fpt_set set,
int l,
int k,
int m,
372 int N, k_start, k_end, j;
374 int function_values = 0;
382 if (flags & NFSOFT_USE_DPT)
393 N =
X(next_power_of_2)(l);
397 k_start = (ABS(k) >= ABS(m)) ? ABS(k) : ABS(m);
399 trafo_nr = (N + k) * (2* N + 1) + (m + N);
406 for (j = 0; j <= l; j++)
410 for (j = l + 1; j <= k_end; j++)
415 if (flags & NFSOFT_USE_DPT)
417 fpt_transposed_direct(set, trafo_nr, &x[k_start], y, k_end, 0U
426 for (j = 0; j <= l; j++)
446 for (j = 0; j < M; j++)
448 plan3D->
p_nfft.
x[3* j ] = plan3D->
x[3* j + 2];
449 plan3D->
p_nfft.
x[3* j + 1] = plan3D->
x[3* j ];
450 plan3D->
p_nfft.
x[3* j + 2] = plan3D->
x[3* j + 1];
471 int i, j, m, k, max, glo1, glo2;
483 for (j = 0; j < M; j++)
484 plan3D->
f[j] = plan3D->
f_hat[0];
491 for (k = -N; k <= N; k++)
493 for (m = -N; m <= N; m++)
496 max = (ABS(m) > ABS(k) ? ABS(m) : ABS(k));
498 for (j = 0; j <= N - max; j++)
505 * SQRT(0.5 * (2. * (max + j) + 1.));
510 if ((k < 0) && (k % 2))
514 if ((m < 0) && (m % 2))
525 for (j = N - max + 1; j <
X(next_power_of_2)(N) + 1; j++)
530 c2e(plan3D, ABS((k + m) % 2));
532 for (i = 1; i <= 2* plan3D ->
N_total + 2; i++)
535 = plan3D->
cheby[i - 1];
545 nfft_trafo_direct(&(plan3D->
p_nfft));
552 for (j = 0; j < plan3D->
M_total; j++)
570 my_plan->
aux[0]= 1/(2*_Complex_I)*my_plan->
cheby[1];
574 my_plan->
aux[j]=1/(2*_Complex_I)*(my_plan->
cheby[j+1]-my_plan->
cheby[j-1]);
576 my_plan->
aux[N-1]=1/(2*_Complex_I)*(-my_plan->
cheby[j-1]);
587 for(j=1;j<=my_plan->
N_total;j++)
600 int i, j, m, k, max, glo1, glo2;
613 for (j = 0; j < M; j++)
614 plan3D->
f_hat[0] += plan3D->
f[j];
618 for (j = 0; j < M; j++)
625 nfft_adjoint_direct(&(plan3D->
p_nfft));
636 for (k = -N; k <= N; k++)
638 for (m = -N; m <= N; m++)
641 max = (ABS(m) > ABS(k) ? ABS(m) : ABS(k));
643 for (i = 1; i < 2* plan3D ->
N_total + 3; i++)
651 e2c(plan3D, ABS((k + m) % 2));
660 for (j = max; j <= N; j++)
664 if ((k < 0) && (k % 2))
668 if ((m < 0) && (m % 2))
680 plan3D->
f_hat[glo1] = plan3D->
f_hat[glo1] * (1 / (2. * KPI)) * SQRT(
681 0.5 * (2. * (j) + 1.));
723 int posN(
int n,
int m,
int B)
728 pos = posN(n - 1, m, B) + B + 1 - MAX(ABS(m), ABS(n - 1));
static void c2e(nfsft_plan *plan)
Converts coefficients with , from a linear combination of Chebyshev polynomials to coefficients m...
void nfsoft_init_advanced(nfsoft_plan *plan, int N, int M, unsigned int nfsoft_flags)
double * gamma
Precomputed recursion coefficients /f$^n/f$ for /f$k = 0,/ldots, N_{{max}}; n=-k,/ldots,k/f$ of associated Legendre-functions /f$P_k^n/f$.
fftw_complex * f_hat
Fourier coefficients.
#define NFSOFT_NO_STABILIZATION
fftw_complex * aux
used when converting Chebychev to Fourier coeffcients
fftw_complex * f_hat
Fourier coefficients.
void nfsoft_init(nfsoft_plan *plan, int N, int M)
#define NFSOFT_NORMALIZED
void SO3_gamma_row(double *gamma, int N, int m, int n)
Compute three-term-recurrence coefficients of Wigner-d functions for all degrees ...
void fpt_transposed(fpt_set set, const int m, double _Complex *x, double _Complex *y, const int k_end, const unsigned int flags)
void nfft_precompute_lin_psi(nfft_plan *ths)
fpt_set set
Structure for discrete polynomial transform (DPT)
#define NFSOFT_INDEX(m, n, l, B)
fftw_complex * wig_coeffs
contains a set of SO(3) Fourier coefficients for fixed orders m and n
void SO3_beta_row(double *beta, int N, int m, int n)
Compute three-term-recurrence coefficients of Wigner-d functions for all degrees ...
#define NFSOFT_MALLOC_F_HAT
NFFT_INT M_total
Total number of samples.
#define FPT_NO_STABILIZATION
If set, no stabilization will be used.
void nfft_adjoint(nfft_plan *ths)
void fpt_precompute(fpt_set set, const int m, double *alpha, double *beta, double *gam, int k_start, const double threshold)
#define FPT_FUNCTION_VALUES
If set, the output are function values at Chebyshev nodes rather than Chebyshev coefficients.
Holds data for a set of cascade summations.
void(* mv_adjoint)(void *)
Adjoint transform.
void nfsoft_precompute(nfsoft_plan *plan3D)
void SO3_alpha_row(double *alpha, int N, int m, int n)
Compute three-term-recurrence coefficients of Wigner-d functions for all degrees ...
NFFT_INT N_total
Total number of Fourier coefficients.
void(* mv_trafo)(void *)
Transform.
fpt_set internal_fpt_set
the internal FPT plan
fftw_complex * cheby
contains a set of Chebychev coefficients for fixed orders m and n
NFFT_INT N_total
Total number of Fourier coefficients.
#define FPT_NO_FAST_ALGORITHM
If set, TODO complete comment.
NFFT_INT M_total
Total number of samples.
#define X(name)
Include header for C99 complex datatype.
void nfft_trafo(nfft_plan *ths)
void nfsoft_finalize(nfsoft_plan *plan)
void * nfft_malloc(size_t n)
double * alpha
Precomputed recursion coefficients /f$^n/f$ for /f$k = 0,/ldots, N_{{max}}; n=-k,/ldots,k/f$ of associated Legendre-functions /f$P_k^n/f$.
void nfft_finalize(nfft_plan *ths)
void nfsoft_trafo(nfsoft_plan *plan3D)
void nfft_precompute_one_psi(nfft_plan *ths)
void nfsoft_init_guru(nfsoft_plan *plan, int B, int M, unsigned int nfsoft_flags, unsigned int nfft_flags, int nfft_cutoff, int fpt_kappa)
fpt_set fpt_init(const int M, const int t, const unsigned int flags)
void nfsoft_adjoint(nfsoft_plan *plan3D)
double * beta
Precomputed recursion coefficients /f$^n/f$ for /f$k = 0,/ldots, N_{{max}}; n=-k,/ldots,k/f$ of associated Legendre-functions /f$P_k^n/f$.
Header file for functions related to Wigner-d/D functions.
Header file for the nfft3 library.
double * x
Nodes in time/spatial domain, size is doubles.
#define FPT_NO_DIRECT_ALGORITHM
If set, TODO complete comment.
nfft_plan p_nfft
the internal NFFT plan
unsigned int flags
the planner flags