在 Numpy 中解决广义特征值问题 [英] Solve Generalized Eigenvalue Problem in Numpy
问题描述
我希望解决以下类型的问题:Aw = xBw
其中 x
是标量(特征值),w
是特征向量,A
和 B
是对称的等维方形 numpy 矩阵.如果 A
和 B
是 d x d
,我应该能够找到 d
x/w 对.我将如何在 numpy 中解决这个问题?我正在查看 Scipy 文档,但没有找到我想要的任何内容.
I am looking to solve a problem of the type: Aw = xBw
where x
is a scalar (eigenvalue), w
is an eigenvector, and A
and B
are symmetric, square numpy matrices of equal dimension. I should be able to find d
x/w pairs if A
and B
are d x d
. How would I solve this in numpy? I was looking in the Scipy docs and not finding anything like what I wanted.
推荐答案
对于实对称或复 Hermitian 稠密矩阵,可以使用 scipy.linalg.eigh()
解决广义特征值问题.为了避免提取所有特征值,您可以使用 subset_by_index
仅指定所需的特征值:
For real symmetric or complex Hermitian dense matrices, you can use scipy.linalg.eigh()
to solve a generalized eigenvalue problem. To avoid extracting all the eigenvalues you can specify only the desired ones by using subset_by_index
:
from scipy.linalg import eigh
eigvals, eigvecs = eigh(A, B, eigvals_only=False, subset_by_index=[0, 1, 2])
可以使用 eigvals_only=True
来仅获取特征值.
One could use eigvals_only=True
to obtain only the eigenvalues.
这篇关于在 Numpy 中解决广义特征值问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!