On this page
torch.linalg.slogdet
torch.linalg.slogdet(A, *, out=None)-
Computes the sign and natural logarithm of the absolute value of the determinant of a square matrix.
For complex
A, it returns the sign and the natural logarithm of the modulus of the determinant, that is, a logarithmic polar decomposition of the determinant.The determinant can be recovered as
sign * exp(logabsdet). When a matrix has a determinant of zero, it returns(0, -inf).Supports input of float, double, cfloat and cdouble dtypes. Also supports batches of matrices, and if
Ais a batch of matrices then the output has the same batch dimensions.See also
torch.linalg.det()computes the determinant of square matrices.- Parameters
-
A (Tensor) – tensor of shape
(*, n, n)where*is zero or more batch dimensions. - Keyword Arguments
-
out (tuple, optional) – output tuple of two tensors. Ignored if
None. Default:None. - Returns
-
A named tuple
(sign, logabsdet).signwill have the same dtype asA.logabsdetwill always be real-valued, even whenAis complex.
Examples:
>>> A = torch.randn(3, 3) >>> A tensor([[ 0.0032, -0.2239, -1.1219], [-0.6690, 0.1161, 0.4053], [-1.6218, -0.9273, -0.0082]]) >>> torch.linalg.det(A) tensor(-0.7576) >>> torch.logdet(A) tensor(nan) >>> torch.linalg.slogdet(A) torch.return_types.linalg_slogdet(sign=tensor(-1.), logabsdet=tensor(-0.2776))
© 2024, PyTorch Contributors
PyTorch has a BSD-style license, as found in the LICENSE file.
https://pytorch.org/docs/2.1/generated/torch.linalg.slogdet.html