Rank and Moore–Penrose pseudoinverse of a symmetric PSD penalty matrix via
its eigendecomposition, keeping eigenpairs whose eigenvalue exceeds a
relative tolerance. Returns (rank, pinv).
Weighted ridge (penalized least-squares) solve for a multi-output Gaussian
response. Forms the weighted normal equations XᵀWX (+ λ·penalty) β = XᵀWY
(row weights W = diag(weights)), factorizes the symmetric system via the
Cholesky-with-fallback path, solves for the coefficients (p, d), and
returns (coefficients, fitted = Xβ). Single source of truth shared by the
gaussian_weighted_ridge FFI shim and any core consumer.
Batched gaussian_weighted_ridge: solve one independent weighted-ridge fit
per leading-axis slice of the padded (K, N_max, p) design / (K, N_max, d)
response, honoring optional per-batch active row_counts. Runs the
per-batch solves in parallel and scatters results back into dense
(K, p, d) coefficients and (K, N_max, d) fitted arrays (padding rows
left zero).
Solve a symmetric dense block system H x = rhs (single right-hand side)
via the Cholesky-with-fallback factorization, returning the solution vector.
context labels errors.
Write-into variant of solve_spd_pcg_with_info that takes an apply closure
of the form Fn(&Array1<f64>, &mut Array1<f64>) so the matvec can write into
a caller-owned buffer. This eliminates the per-iteration Array1::<f64>
allocation for the matvec result that the legacy closure-returning variant
forces. See commit 83369abb for the analogous penalty-vector elimination.
Solve a symmetric (possibly indefinite/ill-conditioned) linear system via
eigendecomposition with a spectral floor: eigenvalues below the floor are
clamped (preserving sign) before inversion, stabilizing the solve.