gromo.tools.sqrt_inverse_matrix_semi_positive#

gromo.tools.sqrt_inverse_matrix_semi_positive(matrix: Tensor, threshold: float = 1e-05, preferred_linalg_library: None | str = 'magma') Tensor[source]#

Compute the square root of the inverse of a semi-positive definite matrix.

Parameters:
  • matrix (torch.Tensor) – input matrix, square and semi-positive definite

  • threshold (float) – threshold to consider an eigenvalue as zero

  • preferred_linalg_library (None | str in ("magma", "cusolver")) – linalg library to use, “cusolver” may failed for non positive definite matrix if CUDA < 12.1 is used see: https://pytorch.org/docs/stable/generated/torch.linalg.eigh.html

Returns:

square root of the inverse of the input matrix

Return type:

torch.Tensor