當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Python SciPy linalg.expm用法及代碼示例

本文簡要介紹 python 語言中 scipy.sparse.linalg.expm 的用法。

用法:

scipy.sparse.linalg.expm(A)#

使用 Pade 近似計算矩陣 index 。

參數

A (M,M) 數組 或稀疏矩陣

要取冪的二維數組或矩陣(稀疏或密集)

返回

expA (M,M) 數組

A的矩陣 index

注意

這是算法(6.1),它是算法(5.1)的簡化。

參考

[1]

Awad H. Al-Mohy 和 Nicholas J. Higham (2009) “矩陣 index 的新縮放和平方算法”。 SIAM 矩陣分析和應用雜誌。 31(3)。第 970-989 頁。 ISSN 1095-7162

例子

>>> from scipy.sparse import csc_matrix
>>> from scipy.sparse.linalg import expm
>>> A = csc_matrix([[1, 0, 0], [0, 2, 0], [0, 0, 3]])
>>> A.toarray()
array([[1, 0, 0],
       [0, 2, 0],
       [0, 0, 3]], dtype=int64)
>>> Aexp = expm(A)
>>> Aexp
<3x3 sparse matrix of type '<class 'numpy.float64'>'
    with 3 stored elements in Compressed Sparse Column format>
>>> Aexp.toarray()
array([[  2.71828183,   0.        ,   0.        ],
       [  0.        ,   7.3890561 ,   0.        ],
       [  0.        ,   0.        ,  20.08553692]])

相關用法


注:本文由純淨天空篩選整理自scipy.org大神的英文原創作品 scipy.sparse.linalg.expm。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。