【问题标题】:How does numpy.linalg.eig decide on order in which eigenvalues are returned?numpy.linalg.eig 如何决定返回特征值的顺序?
【发布时间】:2015-05-22 00:13:56
【问题描述】:

当我使用numpy.linalg.eig 时喜欢

eValues, eVectors = numpy.linalg.eig(someMatrix)

返回的 eValues 几乎是按降序排列的。

numpy.linalg.eig 如何决定返回特征值的顺序?

【问题讨论】:

    标签: python numpy linear-algebra eigenvalue


    【解决方案1】:

    Numpy 对此不做任何保证 -

    来自docstring

    Returns
    -------
    w : (..., M) array
        The eigenvalues, each repeated according to its multiplicity.
        The eigenvalues are not necessarily ordered. The resulting
        array will be always be of complex type. When `a` is real
        the resulting eigenvalues will be real (0 imaginary part) or
        occur in conjugate pairs
    

    Numpy 将这个计算委托给 LAPACK,所以如果有任何一致的顺序,你应该考虑它的实现细节而不是依赖它。

    【讨论】:

    • 好吧,我不会依赖它。但是,我很好奇为什么它们看起来几乎是有序的。如果真的没有什么事情可以至少订购它们,那么我会期待更随机的订购。
    • 我猜 lapack 会通过减少行来实现这一点,所以它可能是该算法的副作用?如果您可以阅读 fortran,请在源代码中挖掘 :)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-02
    • 2016-08-12
    • 1970-01-01
    • 1970-01-01
    • 2011-12-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多