Rate this Page

torch.cholesky_inverse#

torch.cholesky_inverse(L,upper=False,*,out=None)Tensor#

Computes the inverse of a complex Hermitian or real symmetricpositive-definite matrix given its Cholesky decomposition.

LetAA be a complex Hermitian or real symmetric positive-definite matrix,andLL its Cholesky decomposition such that:

whereLHL^{\text{H}} is the conjugate transpose whenLL is complex,and the transpose whenLL is real-valued.

Computes the inverse matrixA1A^{-1}.

Supports input of float, double, cfloat and cdouble dtypes.Also supports batches of matrices, and ifAA is a batch of matricesthen the output has the same batch dimensions.

Parameters:
  • L (Tensor) – tensor of shape(*, n, n) where* is zero or more batch dimensionsconsisting of lower or upper triangular Cholesky decompositions ofsymmetric or Hermitian positive-definite matrices.

  • upper (bool,optional) – flag that indicates whetherLL is lower triangularor upper triangular. Default:False

Keyword Arguments:

out (Tensor,optional) – output tensor. Ignored ifNone. Default:None.

Example:

>>>A=torch.randn(3,3)>>>A=A@A.T+torch.eye(3)*1e-3# Creates a symmetric positive-definite matrix>>>L=torch.linalg.cholesky(A)# Extract Cholesky decomposition>>>torch.cholesky_inverse(L)tensor([[ 1.9314,  1.2251, -0.0889],        [ 1.2251,  2.4439,  0.2122],        [-0.0889,  0.2122,  0.1412]])>>>A.inverse()tensor([[ 1.9314,  1.2251, -0.0889],        [ 1.2251,  2.4439,  0.2122],        [-0.0889,  0.2122,  0.1412]])>>>A=torch.randn(3,2,2,dtype=torch.complex64)>>>A=A@A.mH+torch.eye(2)*1e-3# Batch of Hermitian positive-definite matrices>>>L=torch.linalg.cholesky(A)>>>torch.dist(torch.inverse(A),torch.cholesky_inverse(L))tensor(5.6358e-7)