Method
NumCosmoMathSBesselOdeOperatorsolve_endpoints
Declaration [src]
void
ncm_sbessel_ode_operator_solve_endpoints (
NcmSBesselOdeOperator* op,
GArray* rhs,
GArray** endpoints
)
Description [src]
Efficiently computes only the endpoint derivatives u’(a) and u’(b) without building the full solution vector. This is much more efficient when only endpoint information is needed (e.g., for integral computations via Green’s identity).
For an operator with n_ell angular momentum values (ell_min to ell_max), the output array contains n_ell triplets. Each triplet at index i (where i = 0 to n_ell-1) corresponds to ell = ell_min + i, with elements: - endpoints[3i + 0] = u’(a) for ell_min + i - endpoints[3i + 1] = u’(b) for ell_min + i - endpoints[3*i + 2] = error estimate for ell_min + i
The function first diagonalizes the operator using adaptive QR decomposition, then performs back-substitution while accumulating the contributions to the endpoint derivatives on-the-fly, avoiding the memory allocation and computation cost of the full solution.
The endpoints parameter supports two usage patterns:
-
Python/convenience usage: Pass
endpointspointing to NULL (*endpoints == NULL). A newGArraywill be allocated and returned. The(out callee-allocates)annotation ensures Python bindings automatically use this mode. -
C optimization: Pass
endpointspointing to a pre-allocatedGArray(*endpoints != NULL). The existing array will be reused (cleared and refilled), avoiding repeated allocation/deallocation in performance-critical loops.
Parameters
rhs-
Type: An array of
doubleRight-hand side vector (Chebyshev coefficients of f(x)).
The data is owned by the caller of the method. endpoints-
Type: An array of
doubleArray with 3*n_ell elements storing [u’(a), u’(b), error] for each ell value.
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.