<em>Mac</em>Book项目 2009年学校开始实施<em>Mac</em>Book项目,所有师生配备一本<em>Mac</em>Book,并同步更新了校园无线网络。学校每周进行电脑技术更新,每月发送技术支持资料,极大改变了教学及学习方式。因此2011
2021-06-01 09:32:01
np.linalg.eig(a)
Compute the eigenvalues and right eigenvectors of a square array.
求方陣(n x n
)的特徵值與右特徵向量
a : (…, M, M) array
Matrices for which the eigenvalues and right eigenvectors will be computed
a是一個矩陣Matrix
的陣列。每個矩陣M
都會被計算其特徵值與特徵向量。
w : (…, M) array
The eigenvalues, each repeated according to its multiplicity.
The eigenvalues are not necessarily ordered. The resulting array will be of complex type, unless the imaginary part is zero in which case it will be cast to a real type. Whena
is real the resulting eigenvalues will be real (0 imaginary part) or occur in conjugate pairs
返回的w
是其特徵值。特徵值不會特意進行排序。返回的array一般都是複數形式,除非虛部為0,會被cast為實數。當a
是實數型別時,返回的就是實數。
v : (…, M, M) array
The normalized (unit “length”) eigenvectors, such that the column
v[:,i]
is the eigenvector corresponding to the eigenvaluew[i]
.
返回的v
是歸一化後的特徵向量(length
為1)。特徵向量v[:,i]
對應特徵值w[i]
。
LinAlgError
If the eigenvalue computation does not converge.
See Also
eigvals : eigenvalues of a non-symmetric array.
eigh : eigenvalues and eigenvectors of a real symmetric or complex Hermitian (conjugate symmetric) array.
eigvalsh : eigenvalues of a real symmetric or complex Hermitian (conjugate symmetric) array.
scipy.linalg.eig : Similar function in SciPy that also solves the generalized eigenvalue problem.
scipy.linalg.schur : Best choice for unitary and other non-Hermitian normal matrices.
相關的函數有:
eigvals
:計算非對稱矩陣的特徵值eigh
:實對稱矩陣或者複共軛對稱矩陣(Hermitian
)的特徵值與特徵向量eigvalsh
: 實對稱矩陣或者複共軛對稱矩陣(Hermitian
)的特徵值與特徵向量scipy.linalg.eig
scipy.linalg.schur
… versionadded:: 1.8.0
Broadcasting rules apply, see the
numpy.linalg
documentation for details.This is implemented using the
_geev
LAPACK routines which compute the eigenvalues and eigenvectors of general square arrays.The number
w
is an eigenvalue ofa
if there exists a vectorv
such thata @ v = w * v
. Thus, the arraysa
,w
, andv
satisfy the equationsa @ v[:,i] = w[i] * v[:,i]
for :math:i \in \{0,...,M-1\}
.The array
v
of eigenvectors may not be of maximum rank, that is, some of the columns may be linearly dependent, although round-off error may obscure that fact. If the eigenvalues are all different, then theoretically the eigenvectors are linearly independent anda
can be diagonalized by a similarity transformation usingv
, i.e,inv(v) @ a @ v
is diagonal.For non-Hermitian normal matrices the SciPy function
scipy.linalg.schur
is preferred because the matrixv
is guaranteed to be unitary, which is not the case when usingeig
. The Schur factorization produces an upper triangular matrix rather than a diagonal matrix, but for normal matrices only the diagonal of the upper triangular matrix is needed, the rest is roundoff error.Finally, it is emphasized that
Referencesv
consists of the right (as in right-hand side) eigenvectors ofa
. A vectory
satisfyingy.T @ a = z * y.T
for some numberz
is called a left eigenvector ofa
, and, in general, the left and right eigenvectors of a matrix are not necessarily the (perhaps conjugate) transposes of each other.G. Strang, Linear Algebra and Its Applications, 2nd Ed., Orlando, FL,
Academic Press, Inc., 1980, Various pp.
需要說明的是,特徵向量之間可能存線上性相關關係,即返回的v可能不是滿秩的。但如果特徵值都不同的話,理論上來說,所有特徵向量都是線性無關的。
此時可以利用inv(v)@ a @ v
來計算特徵值的對角矩陣(對角線上的元素是特徵值,其餘元素為0),同時可以用v @ diag(w) @ inv(v)
來恢復a。
同時需要說明的是,這裡得到的特徵向量都是右特徵向量。
即 Ax=λx
>>> from numpy import linalg as LA (Almost) trivial example with real e-values and e-vectors. >>> w, v = LA.eig(np.diag((1, 2, 3))) >>> w; v array([1., 2., 3.]) array([[1., 0., 0.], [0., 1., 0.], [0., 0., 1.]]) Real matrix possessing complex e-values and e-vectors; note that the e-values are complex conjugates of each other. >>> w, v = LA.eig(np.array([[1, -1], [1, 1]])) >>> w; v array([1.+1.j, 1.-1.j]) array([[0.70710678+0.j , 0.70710678-0.j ], [0. -0.70710678j, 0. +0.70710678j]]) Complex-valued matrix with real e-values (but complex-valued e-vectors); note that ``a.conj().T == a``, i.e., `a` is Hermitian. >>> a = np.array([[1, 1j], [-1j, 1]]) >>> w, v = LA.eig(a) >>> w; v array([2.+0.j, 0.+0.j]) array([[ 0. +0.70710678j, 0.70710678+0.j ], # may vary [ 0.70710678+0.j , -0. +0.70710678j]]) Be careful about round-off error! >>> a = np.array([[1 + 1e-9, 0], [0, 1 - 1e-9]]) >>> # Theor. e-values are 1 +/- 1e-9 >>> w, v = LA.eig(a) >>> w; v array([1., 1.]) array([[1., 0.], [0., 1.]])
以上為個人經驗,希望能給大家一個參考,也希望大家多多支援it145.com。
相關文章
<em>Mac</em>Book项目 2009年学校开始实施<em>Mac</em>Book项目,所有师生配备一本<em>Mac</em>Book,并同步更新了校园无线网络。学校每周进行电脑技术更新,每月发送技术支持资料,极大改变了教学及学习方式。因此2011
2021-06-01 09:32:01
综合看Anker超能充系列的性价比很高,并且与不仅和iPhone12/苹果<em>Mac</em>Book很配,而且适合多设备充电需求的日常使用或差旅场景,不管是安卓还是Switch同样也能用得上它,希望这次分享能给准备购入充电器的小伙伴们有所
2021-06-01 09:31:42
除了L4WUDU与吴亦凡已经多次共事,成为了明面上的厂牌成员,吴亦凡还曾带领20XXCLUB全队参加2020年的一场音乐节,这也是20XXCLUB首次全员合照,王嗣尧Turbo、陈彦希Regi、<em>Mac</em> Ova Seas、林渝植等人全部出场。然而让
2021-06-01 09:31:34
目前应用IPFS的机构:1 谷歌<em>浏览器</em>支持IPFS分布式协议 2 万维网 (历史档案博物馆)数据库 3 火狐<em>浏览器</em>支持 IPFS分布式协议 4 EOS 等数字货币数据存储 5 美国国会图书馆,历史资料永久保存在 IPFS 6 加
2021-06-01 09:31:24
开拓者的车机是兼容苹果和<em>安卓</em>,虽然我不怎么用,但确实兼顾了我家人的很多需求:副驾的门板还配有解锁开关,有的时候老婆开车,下车的时候偶尔会忘记解锁,我在副驾驶可以自己开门:第二排设计很好,不仅配置了一个很大的
2021-06-01 09:30:48
不仅是<em>安卓</em>手机,苹果手机的降价力度也是前所未有了,iPhone12也“跳水价”了,发布价是6799元,如今已经跌至5308元,降价幅度超过1400元,最新定价确认了。iPhone12是苹果首款5G手机,同时也是全球首款5nm芯片的智能机,它
2021-06-01 09:30:45