fn
det
→Tensordet(x: Tensor)Compute the determinant of a square matrix.
For a square matrix returns the scalar . The determinant is the signed volume of the parallelepiped spanned by the rows (or columns) of ; it is non-zero if and only if is invertible.
Parameters
xTensorSquare matrix of shape
(*, n, n).Returns
TensorDeterminant of shape (*,) (one scalar per batch entry).
Notes
Computed as the product of the diagonal of from together with the sign of the row-permutation . Cost is .
For numerically large matrices can overflow or
underflow easily — prefer slogdet which returns
and is stable across scales.
Examples
>>> import lucid
>>> from lucid.linalg import det
>>> det(lucid.tensor([[1.0, 2.0], [3.0, 4.0]]))
Tensor(-2.0)