Skip to content
fn

det

→Tensor
det(A: Tensor)

Implementing kernel

C++ engine symbols that back this Python API.

Compute the determinant of a square matrix.

For a square matrix A∈Rn×nA \in \mathbb{R}^{n \times n} returns the scalar det⁡(A)\det(A). The determinant is the signed volume of the parallelepiped spanned by the rows (or columns) of AA; it is non-zero if and only if AA is invertible.

Parameters

Square matrix of shape (*, n, n).

Returns

Tensor

Determinant of shape (*,) (one scalar per batch entry).

Notes

Computed as the product of the diagonal of UU from PA=LUPA = LU together with the sign of the row-permutation PP. Cost is O(n3)O(n^3).

For numerically large matrices det⁡(A)\det(A) can overflow or underflow easily — prefer slogdet which returns (sign, log⁡∣det⁡A∣)(\mathrm{sign},\,\log|\det A|) 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.)

Used by 1