R如何选择特征向量?

how does R choose eigenvectors?

当给定一个具有重复特征值但无缺陷的矩阵时,R 函数 eigen 如何选择特征空间的基?例如,如果我在单位矩阵上调用 eigen,它会给我标准基础。它是如何选择该基而不是任何其他正交基的?

它可能使用了很久以前用 FORTRAN 编写的一些算法。

我怀疑在矩阵上执行了一个程序,将其调整为可以轻松确定特征值和特征向量的形式。我还怀疑这个过程不需要对单位矩阵做任何事情就可以把它变成所需的形式,所以特征值和特征向量会立即被读出。

在退化特征值的一般情况下,您得到的答案将取决于该算法的细节。我怀疑是否有任何选择 - 它只是首先吐出的东西。

仍然不是一个完整的答案,但挖掘得更深一点:eigen 的源代码表明,对于真实的对称矩阵,它调用 .Internal(La_rs(x, only.values))

找到La_rs函数here,查看代码发现调用了LAPACK函数dsyevr

dsyevr 函数已记录 here:

DSYEVR first reduces the matrix A to tridiagonal form T with a call to DSYTRD. Then, whenever possible, DSYEVR calls DSTEMR to compute the eigenspectrum using Relatively Robust Representations. DSTEMR computes eigenvalues by the dqds algorithm, while orthogonal eigenvectors are computed from various "good" L D L^T representations (also known as Relatively Robust Representations).

评论提供了 this link,提供了更多说明性细节:

The next task is to compute an eigenvector for $\lambda - s$. For each $\hat{\lambda}$ the algorithm computes, with care, an optimal twisted factorization ... obtained by implementing triangular factorization both from top down and bottom up and joining them at a well chosen index r ...

[强调]。强调的词暗示细节中有些魔鬼;如果你想深入兔子洞,看起来内部 dlarrv function 是特征向量实际计算的地方......

For more details, see DSTEMR's documentation and:

  • Inderjit S. Dhillon and Beresford N. Parlett: "Multiple representations to compute orthogonal eigenvectors of symmetric tridiagonal matrices," Linear Algebra and its Applications, 387(1), pp. 1-28, August 2004.
  • Inderjit Dhillon and Beresford Parlett: "Orthogonal Eigenvectors and Relative Gaps," SIAM Journal on Matrix Analysis and Applications, Vol. 25, 2004. Also LAPACK Working Note 154.
  • Inderjit Dhillon: "A new O(n^2) algorithm for the symmetric tridiagonal eigenvalue/eigenvector problem", Computer Science Division Technical Report No. UCB/CSD-97-971, UC Berkeley, May 1997.