在NumPy中,我們可以借助numpy.linalg.eig()計算給定方陣的特征值和右特征向量。它將一個正方形數組作為參數,它將返回兩個值,第一個是數組的特征值,第二個是給定正方形數組的右特征向量。
用法:numpy.linalg.eig()
參數:方陣。
Return:它將返回兩個值,第一個是特征值,第二個是特征向量。
範例1:
Python
import numpy as np
mat = np.mat("1 -2;1 3")
# Original matrix
print(mat)
print("")
evalue, evect = np.linalg.eig(mat)
# Eigenvalues of the said matrix"
print(evalue)
print("")
# Eigenvectors of the said matrix
print(evect)
輸出:
[[ 1 -2] [ 1 3]] [2.+1.j 2.-1.j] [[ 0.81649658+0.j 0.81649658-0.j ] [-0.40824829-0.40824829j -0.40824829+0.40824829j]]
範例2:
Python
import numpy as np
mat = np.mat("1 2 3;1 3 4;3 2 1")
# Original matrix
print(mat)
print("")
evalue, evect = np.linalg.eig(mat)
# Eigenvalues of the said matrix"
print(evalue)
print("")
# Eigenvectors of the said matrix
print(evect)
輸出:
[[1 2 3] [1 3 4] [3 2 1]] [ 6.70156212 0.29843788 -2. ] [[-0.5113361 -0.42932334 -0.40482045] [-0.69070311 0.7945835 -0.52048344] [-0.5113361 -0.42932334 0.75180941]]
相關用法
- Python numpy.ma.ids()用法及代碼示例
- Python Numpy np.fft()用法及代碼示例
- Python Numpy np.hermevander2d()用法及代碼示例
- Python Numpy np.hermevander3d()用法及代碼示例
- Python Numpy np.hermefromroots()用法及代碼示例
- Python Numpy np.hermemul()用法及代碼示例
- Python Numpy np.hermezero()用法及代碼示例
- Python Numpy np.hermeder()用法及代碼示例
- Python Numpy np.hermemulx()用法及代碼示例
- Python Numpy np.legdomain()用法及代碼示例
- Python Numpy np.hermeint()用法及代碼示例
- Python Numpy np.hermesub()用法及代碼示例
- Python Numpy np.hermeadd()用法及代碼示例
- Python Numpy np.hermecompanion()用法及代碼示例
- Python Numpy np.hermeweight()用法及代碼示例
- Python Numpy np.hermegauss()用法及代碼示例
- Python Numpy np.hermepow()用法及代碼示例
- Python Numpy np.hermediv()用法及代碼示例
- Python Numpy np.hermcompanion()用法及代碼示例
- Python Numpy np.hermdiv()用法及代碼示例
注:本文由純淨天空篩選整理自vipinyadav15799大神的英文原創作品 numpy.linalg.eig() Method in Python。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。