/** * Computes the Cholesky decomposition of a symmetric positive semi-definite matrix. * * Given a matrix A, returns a lower triangular matrix L such that A = L * L^T. * Singular (positive semi-definite) matrices are accepted: pivots within a relative * tolerance of zero produce zero columns, as needed for degenerate covariance matrices. * * @param {number[][]} matrix - The symmetric positive (semi-)definite matrix to decompose. * @param {number} [tol=1e-10] - Relative tolerance used to decide that a pivot is zero. * @returns {number[][]} Lower triangular matrix L. * @throws Will throw an error if the matrix is not square, not symmetric or not positive semi-definite. * * References: * - [Cholesky Decomposition](https://en.wikipedia.org/wiki/Cholesky_decomposition) */ export function choleskyDecomposition(matrix: number[][], tol?: number): number[][];