flopscope.

flopscope.numpy.linalg.det

Compute the determinant of an array.

Adapted from NumPy docs np.linalg.det

Arealinalg
Typecustom
NumPy Refnp.linalg.det
Cost
n3n^3
Flopscope Context

Determinant. Cost: $n^3$.

Parameters

a:(..., M, M) array_like

Input array to compute determinants for.

Returns

det:(...) array_like

Determinant of a.

See also

Notes

Broadcasting rules apply, see the flops.linalg documentation for details.

The determinant is computed via LU factorization using the LAPACK routine z/dgetrf.

Examples

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

>>> import flopscope.numpy as fnp
>>> a = flops.array([[1, 2], [3, 4]])
>>> flops.linalg.det(a)
-2.0 # may vary

Computing determinants for a stack of matrices:

>>> a = flops.array([ [[1, 2], [3, 4]], [[1, 2], [2, 1]], [[1, 3], [3, 1]] ])
>>> a.shape
(3, 2, 2)
>>> flops.linalg.det(a)
array([-2., -3., -8.])