Is there an optimized package or method that estimates the Perron-Frobenius eigenvalue of a real, square, non-negative matrix? This could be significantly faster (especially for large and/or sparse matrices) than an exact calculation -- given that the Perron-Frobenius eigenvalue can be arrived at by iterating the matrix. I am hoping an optimized package exists which does this.
If A
is a square matrix, possibly in a sparse format, then you can get its largest magnitude (LM) eigenvalue, i.e. its Perron-Frobenius eigenvalue, and the corresponding eigenvector using SciPy’s eigs
and eigsh
functions:
from scipy.sparse.linalg import eigs
val, vec = eigs(a, k=1, which='LM')
SciPy has solvers for sparse eigenvalue problems of various forms that use the ARPACK library. You can read more in SciPy’s ARPACK tutorial.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With