Shortcuts

torch.cholesky_solve

torch.cholesky_solve(B, L, upper=False, *, out=None) Tensor

Computes the solution of a system of linear equations with complex Hermitian or real symmetric positive-definite lhs given its Cholesky decomposition.

Let AA be a complex Hermitian or real symmetric positive-definite matrix, and LL its Cholesky decomposition such that:

A=LLHA = LL^{\text{H}}

where LHL^{\text{H}} is the conjugate transpose when LL is complex, and the transpose when LL is real-valued.

Returns the solution XX of the following linear system:

AX=BAX = B

Supports inputs of float, double, cfloat and cdouble dtypes. Also supports batches of matrices, and if AA or BB is a batch of matrices then the output has the same batch dimensions.

Parameters
  • B (Tensor) – right-hand side tensor of shape (*, n, k) where * is zero or more batch dimensions

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

  • upper (bool, optional) – flag that indicates whether LL is lower triangular or upper triangular. Default: False.

Keyword Arguments

out (Tensor, optional) – output tensor. Ignored if None. 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
>>> B = torch.randn(3, 2)
>>> torch.cholesky_solve(B, L)
tensor([[ -8.1625,  19.6097],
        [ -5.8398,  14.2387],
        [ -4.3771,  10.4173]])
>>> A.inverse() @  B
tensor([[ -8.1626,  19.6097],
        [ -5.8398,  14.2387],
        [ -4.3771,  10.4173]])

>>> 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)
>>> B = torch.randn(2, 1, dtype=torch.complex64)
>>> X = torch.cholesky_solve(B, L)
>>> torch.dist(X, A.inverse() @ B)
tensor(1.6881e-5)

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy