Python eigenvectors: differences among numpy.linalg, scipy.linalg and scipy.sparse.linalg

后端 未结 2 2040
半阙折子戏
半阙折子戏 2021-02-04 02:48

Scipy and Numpy have between them three different functions for finding eigenvectors for a given square matrix, these are:

  1. numpy.linalg.eig(a)
  2. scipy.linalg
2条回答
  •  情深已故
    2021-02-04 02:51

    The special behaviour of the third one has to do with the Lanczos algorithm, which works very well with sparse matrices. The documentation of scipy.sparse.linalg.eig says it uses a wrapper for ARPACK, which in turn uses "the Implicitly Restarted Arnoldi Method (IRAM) or, in the case of symmetric matrices, the corresponding variant of the Lanczos algorithm." (1).

    Now, the Lanczos algorithm has the property that it works better for large eigenvalues (in fact, it uses the maximum eigenvalue):

    In practice, this simple algorithm does not work very well for computing very many of the eigenvectors because any round-off error will tend to introduce slight components of the more significant eigenvectors back into the computation, degrading the accuracy of the computation. (2)

    So, whereas the Lanczos algorithm is only an approximation, I guess the other two methods use algos to find the exact eigenvalues -- and seemingly all of them, which probably depends on the algorithms used, too.

提交回复
热议问题