48 fpt_set set = fpt_init(1,lrint(ceil(log2((
double)N))),0U);
51 double *
alpha = malloc((N+2)*
sizeof(
double)),
52 *
beta = malloc((N+2)*
sizeof(
double)),
53 *
gamma = malloc((N+2)*
sizeof(
double));
56 alpha[0] =
beta[0] = 0.0;
63 for (k = 0; k <= N; k++)
65 alpha[k+1] = ((double)(2*k+1))/((
double)(k+1));
67 gamma[k+1] = -((double)(k))/((
double)(k+1));
72 "Computing a fast polynomial transform (FPT) and a fast discrete cosine \n" 73 "transform (DCT) to evaluate\n\n" 74 " f_j = a_0 P_0(x_j) + a_1 P_1(x_j) + ... + a_N P_N(x_j), j=0,1,...,N,\n\n" 75 "with N=%d, x_j = cos(j*pi/N), j=0,1,...N, the Chebyshev nodes, a_k,\n" 76 "k=0,1,...,N, random Fourier coefficients in [-1,1]x[-1,1]*I, and P_k,\n" 77 "k=0,1,...,N, the Legendre polynomials.",N
90 fpt_precompute(
set,0,alpha,
beta,
gamma,0,1000.0);
95 double _Complex *a = malloc((N+1)*
sizeof(
double _Complex));
96 double _Complex *b = malloc((N+1)*
sizeof(
double _Complex));
97 double *f = malloc((N+1)*
sizeof(
double _Complex));
100 const int NP1 = N + 1;
101 fftw_r2r_kind kind = FFTW_REDFT00;
102 fftw_plan p = fftw_plan_many_r2r(1, &NP1, 1, (
double*)b, NULL, 2, 1,
103 (
double*)f, NULL, 1, 1, &kind, 0U);
108 printf(
"\n2) Random Fourier coefficients a_k, k=0,1,...,N:\n");
109 for (k = 0; k <= N; k++)
111 a[k] = 2.0*nfft_drand48() - 1.0;
112 printf(
" a_%-2d = %+5.3lE\n",k,creal(a[k]));
117 fpt_trafo(
set,0,a,b,N,0U);
125 for (j = 1; j < N; j++)
134 printf(
"\n3) Function values f_j, j=1,1,...,M:\n");
135 for (j = 0; j <= N; j++)
136 printf(
" f_%-2d = %+5.3lE\n",j,f[j]);
145 fftw_destroy_plan(p);
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$.
Holds data for a set of cascade summations.
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$.
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$.