解决Numpy中的广义特征值问题 [英] Solve Generalized Eigenvalue Problem in Numpy

查看:696
本文介绍了解决Numpy中的广义特征值问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻求解决以下类型的问题:Aw = xBw其中x是标量(特征值),w是特征向量,并且AB是对称的平方小数矩阵尺寸相等.如果ABd 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.

推荐答案

对于对称密集矩阵,可以使用scipy.linalg.eigh()解决此广义特征值问题:

For symmetric dense matrices, you can use scipy.linalg.eigh() to solve this generalized eigenvalue problem:

from scipy.linalg import eigh

eigvals, eigvecs = eigh(A, B, eigvals_only=False)

您会看到eigvecs是复杂的ndarray,所以也许您必须使用eigvecs.real ...

You will see that eigvecs is a complex ndarray, so perhaps you have to use eigvecs.real...

在同一模块中,您有eigvalsh()可能会针对您的情况更快地执行,但不会返回特征向量.

In the same module you have eigvalsh() which would probably perform faster for your case, but it doesn't return the eigenvectors.

这篇关于解决Numpy中的广义特征值问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆