pub fn matrix_square_root(matrix: &DMatrix<f64>) -> DMatrix<f64>Expand description
Compute a robust symmetric square root S such that approximately matrix ≈ S * Sᵀ.
Attempts Cholesky decomposition first (yielding L such that matrix = L * L^T). If Cholesky fails (e.g., matrix is not positive definite), it attempts to compute the square root using eigenvalue decomposition (S = V * sqrt(D) * V^T).
§Arguments
matrix- The DMatrixto find the square root of. It’s assumed to be symmetric and square.
§Returns
Some(DMatrix<f64>)containing a matrix square root. The result from Cholesky is lower triangular. The result from eigenvalue decomposition is symmetric. In both cases, if the result isM, thenmatrixapproxM * M.transpose().Noneif the matrix is not square or another fundamental issue prevents computation (though this implementation tries to be robust for positive semi-definite cases).