bundles / scipy latest / scipy / linalg / _basic / det
function
scipy.linalg._basic:det
source: /scipy/linalg/_basic.py :1480
Signature
def det ( a , overwrite_a = False , check_finite = True ) Summary
Compute the determinant of a matrix
Extended Summary
The determinant is a scalar that is a function of the associated square matrix coefficients. The determinant value is zero for singular matrices.
Array argument(s) of this function may have additional "batch" dimensions prepended to the core shape. In this case, the array is treated as a batch of lower-dimensional slices; see linalg_batch for details.
Parameters
a: (..., M, M) array_likeInput array to compute determinants for.
overwrite_a: bool, optionalAllow overwriting data in a (may enhance performance).
check_finite: bool, optionalWhether to check that the input matrix contains only finite numbers. Disabling may give a performance gain, but may result in problems (crashes, non-termination) if the inputs do contain infinities or NaNs.
Returns
det: (...) float or complexDeterminant of
a. For stacked arrays, a scalar is returned for each (m, m) slice in the last two dimensions of the input. For example, an input of shape (p, q, m, m) will produce a result of shape (p, q). If all dimensions are 1 a scalar is returned regardless of ndim.
Notes
The determinant is computed by performing an LU factorization of the input with LAPACK routine 'getrf', and then calculating the product of diagonal entries of the U factor.
Even if the input array is single precision (float32 or complex64), the result will be returned in double precision (float64 or complex128) to prevent overflows.
Examples
import numpy as np from scipy import linalg a = np.array([[1,2,3], [4,5,6], [7,8,9]]) # A singular matrix✓
linalg.det(a)
✗b = np.array([[0,2,3], [4,5,6], [7,8,9]])
✓linalg.det(b)
✗c = np.array([[[[1., 2.], [3., 4.]], [[5., 6.], [7., 8.]]], [[[9., 10.], [11., 12.]], [[13., 14.], [15., 16.]]], [[[17., 18.], [19., 20.]], [[21., 22.], [23., 24.]]]]) linalg.det(c) # The resulting shape is (3, 2)✓
linalg.det(c[0, 0]) # Confirm the (0, 0) slice, [[1, 2], [3, 4]]
✗Aliases
-
scipy.linalg.det