# sklearn.utils.extmath.fast_logdet¶

sklearn.utils.extmath.fast_logdet(A)[source]

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.

Parameters:
Aarray_like of shape (n, n)

The square matrix.

Returns:
logdetfloat

When det(A) is strictly positive, log(det(A)) is returned. When det(A) is non-positive or not defined, then -inf is returned.

numpy.linalg.slogdet
>>> import numpy as np