本文簡要介紹 python 語言中 scipy.linalg.det
的用法。
用法:
scipy.linalg.det(a, overwrite_a=False, check_finite=True)#
計算矩陣的行列式
行列式是一個標量,它是相關方陣係數的函數。對於奇異矩陣,行列式值為零。
- a: (…, M, M) 數組
用於計算行列式的輸入數組。
- overwrite_a: 布爾型,可選
允許覆蓋 a 中的數據(可能會提高性能)。
- check_finite: 布爾型,可選
是否檢查輸入矩陣是否僅包含有限數。禁用可能會提高性能,但如果輸入確實包含無窮大或 NaN,則可能會導致問題(崩潰、非終止)。
- det: (…) 浮點數或複數
a 的行列式。對於堆疊數組,為輸入的最後兩個維度中的每個 (m, m) 切片返回一個標量。例如,形狀為 (p, q, m, m) 的輸入將產生形狀為 (p, q) 的結果。如果所有維度均為 1,則無論 ndim 為何,都會返回標量。
參數 ::
返回 ::
注意:
行列式的計算方法是使用 LAPACK 例程 ‘getrf’ 對輸入執行 LU 分解,然後計算 U 因子的對角線項的乘積。
即使輸入數組是單精度(float32或complex64),結果也會以雙精度(float64或complex128)返回,以防止溢出。
例子:
>>> 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) 0.0 >>> b = np.array([[0,2,3], [4,5,6], [7,8,9]]) >>> linalg.det(b) 3.0 >>> # An array with the shape (3, 2, 2, 2) >>> 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) array([[-2., -2.], [-2., -2.], [-2., -2.]]) >>> linalg.det(c[0, 0]) # Confirm the (0, 0) slice, [[1, 2], [3, 4]] -2.0
相關用法
- Python SciPy linalg.diagsvd用法及代碼示例
- Python SciPy linalg.dft用法及代碼示例
- Python SciPy linalg.eigvalsh_tridiagonal用法及代碼示例
- Python SciPy linalg.cdf2rdf用法及代碼示例
- Python SciPy linalg.LaplacianNd用法及代碼示例
- Python SciPy linalg.solve_circulant用法及代碼示例
- Python SciPy linalg.polar用法及代碼示例
- Python SciPy linalg.clarkson_woodruff_transform用法及代碼示例
- Python SciPy linalg.rsf2csf用法及代碼示例
- Python SciPy linalg.hessenberg用法及代碼示例
- Python SciPy linalg.tril用法及代碼示例
- Python SciPy linalg.triu用法及代碼示例
- Python SciPy linalg.svd用法及代碼示例
- Python SciPy linalg.ishermitian用法及代碼示例
- Python SciPy linalg.invhilbert用法及代碼示例
- Python SciPy linalg.factorized用法及代碼示例
- Python SciPy linalg.lu_factor用法及代碼示例
- Python SciPy linalg.SuperLU用法及代碼示例
- Python SciPy linalg.lsqr用法及代碼示例
- Python SciPy linalg.cho_factor用法及代碼示例
- Python SciPy linalg.fractional_matrix_power用法及代碼示例
- Python SciPy linalg.eig_banded用法及代碼示例
- Python SciPy linalg.tanhm用法及代碼示例
- Python SciPy linalg.orthogonal_procrustes用法及代碼示例
- Python SciPy linalg.use_solver用法及代碼示例
注:本文由純淨天空篩選整理自scipy.org大神的英文原創作品 scipy.linalg.det。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。