Rate this Page

torch.linalg.ldl_solve#

torch.linalg.ldl_solve(LD,pivots,B,*,hermitian=False,out=None)Tensor#

Computes the solution of a system of linear equations using the LDL factorization.

LD andpivots are the compact representation of the LDL factorization andare expected to be computed bytorch.linalg.ldl_factor_ex().hermitian argument to this function should be the sameas the corresponding arguments intorch.linalg.ldl_factor_ex().

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

Warning

This function is “experimental” and it may change in a future PyTorch release.

Parameters
  • LD (Tensor) – then times n matrix or the batch of such matrices of size(*, n, n) where* is one or more batch dimensions.

  • pivots (Tensor) – the pivots corresponding to the LDL factorization ofLD.

  • B (Tensor) – right-hand side tensor of shape(*, n, k).

Keyword Arguments
  • hermitian (bool,optional) – whether to consider the decomposed matrix to be Hermitian or symmetric.For real-valued matrices, this switch has no effect. Default:False.

  • out (tuple,optional) – output tensor.B may be passed asout and the result is computed in-place onB.Ignored ifNone. Default:None.

Examples:

>>>A=torch.randn(2,3,3)>>>A=A@A.mT# make symmetric>>>LD,pivots,info=torch.linalg.ldl_factor_ex(A)>>>B=torch.randn(2,3,4)>>>X=torch.linalg.ldl_solve(LD,pivots,B)>>>torch.linalg.norm(A@X-B)>>>tensor(0.0001)