Method

NumCosmoMathSpectralcompute_chebyshev_coeffs_adaptive

Declaration [src]

guint
ncm_spectral_compute_chebyshev_coeffs_adaptive (
  NcmSpectral* spectral,
  NcmSpectralF F,
  gdouble a,
  gdouble b,
  guint k_min,
  gdouble tol,
  GArray** coeffs,
  gpointer user_data
)

Description [src]

Computes Chebyshev coefficients adaptively using nested Chebyshev-Lobatto nodes. The function F is evaluated at points x in [a,b]. Starts at level k_min and refines by doubling until spectral convergence is achieved or max_order is reached. Uses nested nodes: only new odd nodes are computed at each refinement level. The Chebyshev expansion is $f(x) = f(t) = \sum_{k=0}^{N-1} a_k T_k(t)$ where $t = (2x - (a+b))/(b-a)$.

If coeffs points to NULL, allocates a new GArray. If coeffs points to an existing GArray, resizes it as needed. Through bindings, coeffs always receives NULL.

Parameters

F

Type: NcmSpectralF

Function to evaluate, receives x in [a,b].

a

Type: gdouble

Left endpoint of the interval.

b

Type: gdouble

Right endpoint of the interval.

k_min

Type: guint

Minimum refinement level (N_min = 2^k_min + 1).

tol

Type: gdouble

Spectral convergence tolerance.

coeffs

Type: An array of double

Output array of coefficients.

The argument will be set by the function.
The caller of the method takes ownership of the returned data, and is responsible for freeing it.
user_data

Type: gpointer

User data for F.

The argument can be NULL.
The data is owned by the caller of the method.

Return value

Type: guint

The final refinement level k used (N = 2^k + 1).