dpnp.linalg.slogdet

dpnp.linalg.slogdet(a)[source]

Compute the sign and (natural) logarithm of the determinant of an array.

For full documentation refer to numpy.linalg.slogdet.

Parameters:

a ((..., M, M) {dpnp.ndarray, usm_ndarray}) -- Input array, has to be a square 2-D array.

Returns:

  • sign ((...) dpnp.ndarray) -- A number representing the sign of the determinant. For a real matrix, this is 1, 0, or -1. For a complex matrix, this is a complex number with absolute value 1 (i.e., it is on the unit circle), or else 0.

  • logabsdet ((...) dpnp.ndarray) -- The natural log of the absolute value of the determinant.

See also

dpnp.det

Returns the determinant of an array.

Examples

The determinant of a 2-D array [[a, b], [c, d]] is ad - bc:

>>> import dpnp as dp
>>> a = dp.array([[1, 2], [3, 4]])
>>> (sign, logabsdet) = dp.linalg.slogdet(a)
>>> (sign, logabsdet)
(array(-1.), array(0.69314718))
>>> sign * dp.exp(logabsdet)
array(-2.)

Computing log-determinants for a stack of matrices:

>>> a = dp.array([ [[1, 2], [3, 4]], [[1, 2], [2, 1]], [[1, 3], [3, 1]] ])
>>> a.shape
(3, 2, 2)
>>> sign, logabsdet = dp.linalg.slogdet(a)
>>> (sign, logabsdet)
(array([-1., -1., -1.]), array([0.69314718, 1.09861229, 2.07944154]))
>>> sign * dp.exp(logabsdet)
array([-2., -3., -8.])