matrix_square_root

Function matrix_square_root 

Source
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 DMatrix to 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 is M, then matrix approx M * M.transpose().
  • None if the matrix is not square or another fundamental issue prevents computation (though this implementation tries to be robust for positive semi-definite cases).