Scipy and Numpy have between them three different functions for finding eigenvectors for a given square matrix, these are:
Focusing specifically on the situation that all the optional arguments I’ve left off the last two are left at their defaults and that a/A is real-valued, I am curious about the differences among these three which are ambiguous from the documentation – especially:
- Why does (3) have a note that it can’t find all eigenvectors?
- Why must the other two compute all solutions – why don’t they take a
kargument? - (1) has a note saying that the eigenvalues are returned in no particular order; (3) has an optional argument to control the order. Does (2) make any guarantees about this?
- Does (3) assume that
Ais sparse? (mathematically speaking, rather than being represented as a scipy sparse matrix) Can it be inefficient, or even give wrong results, if this assumption doesn’t hold? - Are there other factors I should consider when choosing among these?
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.eigsays 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):
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.