fn
slogdet
→Tensorslogdet(A: Tensor)Sign and natural log of the absolute determinant.
Returns the pair such that
Numerically stable for matrices whose determinant would overflow or underflow if computed directly — for instance, large covariance matrices in log-likelihood calculations.
Parameters
ATensorSquare matrix of shape
(*, n, n).Returns
Tensor (or for singular matrices), shape
(*,).
Notes
Computed via LU as with the sign accumulated from row swaps. Cost is .
Examples
>>> import lucid
>>> from lucid.linalg import slogdet
>>> sign, logabs = slogdet(lucid.tensor([[1.0, 2.0], [3.0, 4.0]]))
>>> sign, logabs
(Tensor(-1.0), Tensor(0.6931))