torch.linalg.ldl_factor_ex#
- 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 unlesscheck_errors= True.It also returns theinfotensor returned byLAPACK’s sytrf.infostores integer error codes from the backend library.A positive integer indicates the diagonal element of that is zero.Division by 0 will occur if the result is used for solving a system of linear equations.infofilled with zeros indicates that the factorization was successful.Ifcheck_errors=Trueandinfocontains positive integers, then aRuntimeError 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 dimensionsconsisting 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
infoand raisean error if it is non-zero. Default:False.out (tuple,optional) – tuple of three tensors to write the output to. Ignored ifNone. Default:None.
- Returns
A named tuple(LD, pivots, info).
Examples:
>>>A=torch.randn(3,3)>>>A=A@A.mT# make symmetric>>>Atensor([[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)>>>LDtensor([[ 7.2079, 0.0000, 0.0000], [ 0.5884, 0.9595, 0.0000], [ 0.2695, -0.8513, 0.1633]])>>>pivotstensor([1, 2, 3], dtype=torch.int32)>>>infotensor(0, dtype=torch.int32)