Symeig - Symmetrical eigenvalue routines for NumPy
The symeig module contains a Python
wrapper for the LAPACK functions to solve the standard and generalized eigenvalue problems for
symmetric (hermitian) positive definite matrices. Those
specialized algorithms give an important speed-up with respect to the
generic LAPACK eigenvalue problem solver used by
NumPy
(linalg.eig
and linalg.eigh).
The wrapper function symeig automatically selects the
appropriate LAPACK routine. It is also possible to request only a
subset of all eigenvalues, which consumes less memory and
results sometimes in an additional speed-up, especially for large matrices.
Update for SciPy ≥ 0.5.2:
some of the routines used in symeig
are now included in SciPy as well. They are available
under scipy.lib.lapack.flapack and can be accessed
with the function scipy.lib.lapack.get_lapack_funcs.
Some of them are still missing, though. symeig
uses its own wrappers and offers a unified interface to all the
relevant LAPACK routines.
Installation
- Requirements:
- Download: Download symeig at SourceForge
- Installation:
Unpack the archive file and enter the project directory.
To build the module type:
python setup.py build
To install it:
python setup.py install
If you want to use symeig without installing it on the system Python path:
python setup.py install --prefix=/some_dir_in_your_PYTHONPATH/ - Testing:
Check your installation in a Python shell as follows:
>>> import symeig >>> symeig.test()
Mantainers
symeig has been written by Pietro Berkes and Tiziano Zito at the Institute for Theoretical Biology of the Humboldt University, Berlin.For comments, patches, feature requests, support requests, and bug reports please send a message to the MDP users mailing list.
Documentation
- symeig docstring:
"""Solve standard and generalized eigenvalue problem for symmetric (hermitian) definite positive matrices. Syntax: w,Z = symeig(A) w = symeig(A,eigenvectors=0) w,Z = symeig(A,range=(lo,hi)) w,Z = symeig(A,B,range=(lo,hi)) Inputs: A -- An N x N matrix. B -- An N x N matrix. eigenvectors -- if set return eigenvalues and eigenvectors, otherwise only eigenvalues turbo -- (only for generalized eigenvalue problem and if range=None) if turbo = "on", use divide and conquer algorithm (faster but expensive in memory) range -- the tuple (lo,hi) represent the indexes of the smallest and largest (in ascending order) eigenvalues to be returned. 1 <= lo < hi <= N if range = None, returns all eigenvalues and eigenvectors. type -- (only for generalized eigenvalue problem) Specifies the problem type to be solved: type = 1: A*x = (lambda)*B*x = 2: A*B*x = (lambda)*x = 3: B*A*x = (lambda)*x overwrite -- if 'overwrite' is set, computations are done inplace, A and B are overwritten during calculation (you save memory but loose the matrices). If matrices are complex this argument is ignored. Outputs: w -- (selected) eigenvalues in ascending order. Z -- if range = None, Z contains the matrix of eigenvectors, normalized as follows: Z^H * A * Z = lambda and - type = 1 or 2: Z^H * B * Z = I - type = 3 : Z^H * B^(-1) * Z = I where ^H means conjugate transpose. if range, an N x M matrix containing the orthonormal eigenvectors of the matrix A corresponding to the selected eigenvalues, with the i-th column of Z holding the eigenvector associated with w[i]. The eigenvectors are normalized as above. """ - Benchmark results:
Standard eigenproblem
(sec/100)Generalized eigenproblem
(sec/100)Matrix dimension
symeig
numpy
symeig
numpy
16x16
0.04 0.14 0.06 >0.06 32x32 0.07 0.16 0.11 0.26 64x64 0.23 0.86 0.39 1.33 128x128 1.19 5.92 2.01 8.92 256x256 6.49 40.42 10.71 86.40 512x512 60.04 540.57 65.31 2233.41 1024x1024 338.93 4883.13 345.84 14802.98 2048x2048 1952.03 69594.75 2020.79 97749.95 - Wrapped LAPACK functions:
symeig wraps the following LAPACK functions for standard and generalized symmetric eigenvalue problems:EVR routines ssyevr.fdsyevr.fcheevr.fzheevr.fGV routines ssygv.fdsygv.fchegv.fzhegv.fGVD routines ssygvd.fdsygvd.fchegvd.fzhegvd.fGVX routines ssygvx.fdsygvx.fchegvx.fzhegvx.f
