Table of Contents
Shortcuts

# 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 `A` is 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).

    sign will have the same dtype as `A`.

    logabsdet will always be real-valued, even when `A` is 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))

## Docs

Access comprehensive developer documentation for PyTorch

View Docs

## Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

## Resources

Find development resources and get your questions answered

View Resources

To analyze traffic and optimize your experience, we serve cookies on this site. By clicking or navigating, you agree to allow our usage of cookies. As the current maintainers of this site, Facebook’s Cookies Policy applies. Learn more, including about available controls: Cookies Policy.