scipy.linalg.
expm#
- scipy.linalg.expm(A)[source]#
計算陣列的矩陣指數。
- 參數:
- Andarray
輸入,後兩個維度為方形
(..., n, n)
。
- 回傳值:
- eAndarray
結果矩陣指數,與
A
具有相同的形狀
註解
實作 [1] 中給出的演算法,本質上是 Pade 逼近,其階數可變,並根據陣列資料決定。
對於大小為
n
的輸入,最壞情況下的記憶體使用量級為8*(n**2)
。如果輸入資料不是實數和複數 dtype 的單精度和雙精度,則會複製到一個新陣列。對於
n >= 400
的情況,精確的 1-範數計算成本與 1-範數估計相當,從那時起,使用 [2] 中給出的估計方案來決定逼近階數。參考文獻
[1]Awad H. Al-Mohy and Nicholas J. Higham, (2009), “A New Scaling and Squaring Algorithm for the Matrix Exponential”, SIAM J. Matrix Anal. Appl. 31(3):970-989, DOI:10.1137/09074721X
[2]Nicholas J. Higham and Francoise Tisseur (2000), “A Block Algorithm for Matrix 1-Norm Estimation, with an Application to 1-Norm Pseudospectra.” SIAM J. Matrix Anal. Appl. 21(4):1185-1201, DOI:10.1137/S0895479899356080
範例
>>> import numpy as np >>> from scipy.linalg import expm, sinm, cosm
公式 exp(0) = 1 的矩陣版本
>>> expm(np.zeros((3, 2, 2))) array([[[1., 0.], [0., 1.]], [[1., 0.], [0., 1.]], [[1., 0.], [0., 1.]]])
應用於矩陣的尤拉恆等式 (exp(i*theta) = cos(theta) + i*sin(theta))
>>> a = np.array([[1.0, 2.0], [-1.0, 3.0]]) >>> expm(1j*a) array([[ 0.42645930+1.89217551j, -2.13721484-0.97811252j], [ 1.06860742+0.48905626j, -1.71075555+0.91406299j]]) >>> cosm(a) + 1j*sinm(a) array([[ 0.42645930+1.89217551j, -2.13721484-0.97811252j], [ 1.06860742+0.48905626j, -1.71075555+0.91406299j]])