Compute logarithm of determinant of a square matrix.
The (natural) logarithm of the determinant of a square matrix is returned if det(A) is non-negative and well defined. If the determinant is zero or negative returns -Inf.
Equivalent to : np.log(np.det(A)) but more robust.
The square matrix.
When det(A) is strictly positive, log(det(A)) is returned. When det(A) is non-positive or not defined, then -inf is returned.
See also
numpy.linalg.slogdetCompute the sign and (natural) logarithm of the determinant of an array.
>>> import numpy as np >>> from sklearn.utils.extmath import fast_logdet >>> a = np.array([[5, 1], [2, 8]]) >>> fast_logdet(a) np.float64(3.6375861597263857)
© 2007–2025 The scikit-learn developers
Licensed under the 3-clause BSD License.
https://scikit-learn.org/1.6/modules/generated/sklearn.utils.extmath.fast_logdet.html