13 #define MIN(a,b) ((a) < (b) ? (a) : (b))
22 for (k = 1; k <= n; k++){
25 p1 = ( (alpha + 2.0 * k - 1.0 - z) * p2 - (alpha + k - 1.0) * p3 ) / k;
36 for (k = 1; k <= n; k++){
39 p1 = ( (alpha + 2.0 * k - 1.0 - z) * p2 - (alpha + k - 1.0) * p3 ) / k;
47 for(i = 1; i <= n; i++)
55 for(i = min; i <= max; i++)
64 const int NITERMAX = 2000;
65 const int MAXIT = 250;
69 double h = 1.0 / (double) N;
70 double vinf, vsup, p1, p2, pp, z = 0.0, z1, temp;
76 for (n = 0; n < N; n++)
88 while( vinf * vsup >= 0 && niter < NITERMAX ){
95 while( vinf * vsup < 0 && niter < NITERMAX ){
104 z = infbound - vinf * (supbound-infbound) / (vsup-vinf);
112 for (i = 1; i <= MAXIT; i++)
117 pp = (N * p1 - N * p2) / z;
122 if( cabs(z - z1) < 1e-16 ){
130 weights[n] = (facalpha / pow(N+1, 2.0)) * z * pow( (exp(z / 4.0) / normfac) * (exp(z / 4.0) /
eval_laguerre_rescaled(z, N+1, alpha, normfac)) , 2.0);
136 if( N == 2 && alpha == 2){
139 weights[0] = 2.770896037098993835 * pow(roots[0],2.0);
140 weights[1] = 5.603177687399098925 * pow(roots[1],2.0);
144 for (n = 1; n < N-1; n++)
145 if( roots[n] <= roots[n-1] )
146 printf(
"Problem with %ith root! : %f < %f < %f\n",
147 n, roots[n-1], roots[n], roots[n+1]);
163 const int alpha =
ALPHA;
177 double *roots = (
double*)calloc(N,
sizeof(
double));
178 double *weights = (
double*)calloc(N,
sizeof(
double));
186 double infbound, supbound = 3.95 * N + 10;
187 double vinf, vsup, p1, p2, pp, taubis;
188 double h = (double)N/1000;
189 const int MAXIT = 250;
199 while( vinf * vsup >= 0 && infbound > 0 ){
204 while( vinf * vsup < 0 && supbound > 0 ){
212 R = infbound - vinf * (supbound-infbound) / (vsup-vinf);
214 for (i = 1; i <= MAXIT; i++)
219 pp = (N * p1 - N * p2) / R;
223 if( cabs(taubis - R) < 1e-16 ){
240 const int alpha =
ALPHA;
256 *nodes = (
double*)calloc(N,
sizeof(
double));
257 *weights = (
double*)calloc(N,
sizeof(
double));
258 assert(nodes != NULL);
259 assert(weights != NULL);
266 const int alpha =
ALPHA;
268 double r, factor, lagu0, lagu1, lagu2;
273 factor = weights[i] * f[i] * exp(-r/2.0) ;
280 for (n = 1; n < N; n++)
284 (alpha + 2 * n - 1 - r) * lagu1 -
285 (alpha + n - 1) * lagu0
308 complex
double factor, lagu0, lagu1, lagu2, r;
310 for (i = 0; i < Nnodes; i++)
313 factor = exp(-r/2.0);
320 for (n = 1; n < N; n++)
324 (alpha + 2 * n - 1 - r) * lagu1 -
325 (alpha + n - 1) * lagu0
328 f[i] += factor * pow(
factorial_range(n+1, n+alpha), -0.5) * lagu2 * fn[n];
341 int i, n, l, offset_i, offset_n;
342 double factor, lagu0, lagu1, lagu2, r;
343 const int alpha =
ALPHA;
345 double *temp = (
double*)calloc(N,
sizeof(
double));
352 factor = weights[i] * exp(-r/4.0);
355 lagu1 = 1.0 * exp(-r/4.0);
359 for (n = 1; n < N; n++)
363 (alpha + 2 * n - 1 - r) * lagu1 -
364 (alpha + n - 1) * lagu0
373 offset_i = i * mapsize;
374 for (n = 0; n < N; n++)
376 offset_n = n * mapsize;
377 for(l=0; l<mapsize; l++)
379 fn[l+offset_n] += f[l+offset_i] * temp[n];
394 int i, n, l, offset_n, offset_i;
395 const int alpha =
ALPHA;
398 double factor, lagu0, lagu1, lagu2;
399 double *temp = (
double*)calloc(N,
sizeof(
double));
401 for (i = 0; i < Nnodes; i++)
404 factor = exp(-r/4.0);
408 lagu1 = 1.0 * exp(-r/4.0);
412 for (n = 1; n < N; n++)
416 (alpha + 2 * n - 1 - r) * lagu1 -
417 (alpha + n - 1) * lagu0
427 offset_i = i * mapsize;
428 for (n = 0; n < N; n++)
430 offset_n = n * mapsize;
431 for(l=0; l<mapsize; l++)
433 f[l+offset_i] += temp[n] * fn[l+offset_n];
448 const int alpha =
ALPHA;
449 double factor, lagu0, lagu1, lagu2, r;
451 for (i = 0; i < Nnodes; i++)
454 factor = exp(-r/2.0);
463 for (n = 1; n < N; n++)
465 lagu2 = ( (alpha + 2 * n - 1 - r) * lagu1 -
466 (alpha + n - 1) * lagu0 ) / n;
469 KN[ i * N + n ] = factor * pow(
factorial_range(n+1, n+alpha), -0.5) * lagu2;
483 const int alpha =
ALPHA;
486 double tau = R / nodes[N-1];
long factorial_range(int min, int max)
void flag_spherlaguerre_synthesis_gen(double *f, const double *fn, const double *nodes, int Nnodes, double tau, int N, int alpha)
void flag_spherlaguerre_mapped_synthesis(complex double *f, const complex double *fn, const double *nodes, int Nnodes, double tau, int N, int mapsize)
void flag_spherbessel_sampling(double *nodes, double *weights, double R, int N)
double eval_laguerre(double z, int n, int alpha)
double flag_spherlaguerre_Rmax(int N)
void flag_spherlaguerre_allocate_sampling(double **nodes, double **weights, int N)
void flag_spherlaguerre_basis(double *KN, const int N, const double *nodes, int Nnodes, double tau)
double flag_spherlaguerre_tau(double R, int N)
double eval_laguerre_rescaled(double z, int n, int alpha, double normfac)
void flag_spherlaguerre_mapped_analysis(complex double *fn, const complex double *f, const double *nodes, const double *weights, double tau, int N, int mapsize)
void flag_spherlaguerre_sampling(double *nodes, double *weights, double tau, int N)
void flag_spherlaguerre_quadrature(double *roots, double *weights, int N, int alpha)
void flag_spherlaguerre_synthesis(double *f, const double *fn, const double *nodes, int Nnodes, double tau, int N)
void flag_spherlaguerre_analysis(double *fn, const double *f, const double *nodes, const double *weights, double tau, int N)