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
Ais 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])