torch.linalg.ldl_factor_ex — PyTorch 2.7 documentation (original) (raw)
torch.linalg.ldl_factor_ex(A, *, hermitian=False, check_errors=False, out=None)¶
This is a version of ldl_factor() that does not perform error checks unless check_errors
= True. It also returns the info
tensor returned by LAPACK’s sytrf.info
stores integer error codes from the backend library. A positive integer indicates the diagonal element of DD that is zero. Division by 0 will occur if the result is used for solving a system of linear equations.info
filled with zeros indicates that the factorization was successful. If check_errors=True
and info
contains positive integers, then a RuntimeError is thrown.
Note
When the inputs are on a CUDA device, this function synchronizes only when check_errors
= True.
Warning
This function is “experimental” and it may change in a future PyTorch release.
Parameters
A (Tensor) – tensor of shape (*, n, n) where * is zero or more batch dimensions consisting of symmetric or Hermitian matrices.
Keyword Arguments
- hermitian (bool, optional) – whether to consider the input to be Hermitian or symmetric. For real-valued matrices, this switch has no effect. Default: False.
- check_errors (bool, optional) – controls whether to check the content of
info
and raise an error if it is non-zero. Default: False. - out (tuple, optional) – tuple of three tensors to write the output to. Ignored if None. Default: None.
Returns
A named tuple (LD, pivots, info).
Examples:
A = torch.randn(3, 3) A = A @ A.mT # make symmetric A tensor([[7.2079, 4.2414, 1.9428], [4.2414, 3.4554, 0.3264], [1.9428, 0.3264, 1.3823]]) LD, pivots, info = torch.linalg.ldl_factor_ex(A) LD tensor([[ 7.2079, 0.0000, 0.0000], [ 0.5884, 0.9595, 0.0000], [ 0.2695, -0.8513, 0.1633]]) pivots tensor([1, 2, 3], dtype=torch.int32) info tensor(0, dtype=torch.int32)