torch.cholesky_solve
-
torch.cholesky_solve(input, input2, upper=False, *, out=None) → Tensor
-
Solves a linear system of equations with a positive semidefinite matrix to be inverted given its Cholesky factor matrix .
If
upper
isFalse
, is and lower triangular andc
is returned such that:If
upper
isTrue
or not provided, is upper triangular andc
is returned such that:torch.cholesky_solve(b, u)
can take in 2D inputsb, u
or inputs that are batches of 2D matrices. If the inputs are batches, then returns batched outputsc
Supports real-valued and complex-valued inputs. For the complex-valued inputs the transpose operator above is the conjugate transpose.
- Parameters
-
- input (Tensor) – input matrix of size , where is zero or more batch dimensions
- input2 (Tensor) – input matrix of size , where is zero of more batch dimensions composed of upper or lower triangular Cholesky factor
-
upper (bool, optional) – whether to consider the Cholesky factor as a lower or upper triangular matrix. Default:
False
.
- Keyword Arguments
-
out (Tensor, optional) – the output tensor for
c
Example:
>>> a = torch.randn(3, 3) >>> a = torch.mm(a, a.t()) # make symmetric positive definite >>> u = torch.cholesky(a) >>> a tensor([[ 0.7747, -1.9549, 1.3086], [-1.9549, 6.7546, -5.4114], [ 1.3086, -5.4114, 4.8733]]) >>> b = torch.randn(3, 2) >>> b tensor([[-0.6355, 0.9891], [ 0.1974, 1.4706], [-0.4115, -0.6225]]) >>> torch.cholesky_solve(b, u) tensor([[ -8.1625, 19.6097], [ -5.8398, 14.2387], [ -4.3771, 10.4173]]) >>> torch.mm(a.inverse(), b) tensor([[ -8.1626, 19.6097], [ -5.8398, 14.2387], [ -4.3771, 10.4173]])
© 2019 Torch Contributors
Licensed under the 3-clause BSD License.
https://pytorch.org/docs/1.8.0/generated/torch.cholesky_solve.html