Shortcuts

torch.linalg.det

torch.linalg.det(A, *, out=None)Tensor

Computes the determinant of a square matrix.

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.

Note

This function is computed using torch.lu(). When inputs are on a CUDA device, this function synchronizes that device with the CPU.

See also

torch.linalg.slogdet() computes the sign (resp. angle) and natural logarithm of the absolute value (resp. modulus) of the determinant of real-valued (resp. complex) square matrices.

Parameters

A (Tensor) – tensor of shape (*, n, n) where * is zero or more batch dimensions.

Keyword Arguments

out (Tensor, optional) – output tensor. Ignored if None. Default: None.

Examples:

>>> A = torch.randn(3, 3)
>>> torch.linalg.det(A)
tensor(0.0934)

>>> A = torch.randn(3, 2, 2)
>>> torch.linalg.det(A)
tensor([1.1990, 0.4099, 0.7386])

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