Skip to main content

primme is a Python interface to PRIMME, a high-performance library for computing a few eigenvalues/eigenvectors, and singular values/vectors. PRIMME is especially optimized for large, difficult problems. Real symmetric and complex Hermitian problems, standard \(A x = \lambda x\) and generalized \(A x = \lambda B x\), are supported. It can find largest, smallest, or interior singular/eigenvalues, and can use preconditioning to accelerate convergence.

The main contributors to PRIMME are James R. McCombs, Eloy Romero Alcalde, Andreas Stathopoulos and Lingfei Wu.

Install

You can install the latest version with pip:

pip install numpy   # if numpy is not installed yet
pip install scipy   # if scipy is not installed yet
conda install mkl-devel # if using Anaconda Python distribution
pip install primme

Optionally for building the development version do:

git clone https://github.com/primme/primme
cd primme
make python_install

Usage

The following examples compute a few eigenvalues and eigenvectors from a real symmetric matrix:

>>> import Primme, scipy.sparse
>>> A = scipy.sparse.spdiags(range(100), [0], 100, 100) # sparse diag. matrix
>>> evals, evecs = Primme.eigsh(A, 3, tol=1e-6, which='LA')
>>> evals # the three largest eigenvalues of A
array([ 99.,  98.,  97.])

>>> new_evals, new_evecs = Primme.eigsh(A, 3, tol=1e-6, which='LA', ortho=evecs)
>>> new_evals # the next three largest eigenvalues
array([ 96.,  95.,  94.])

>>> evals, evecs = primme.eigsh(A, 3, tol=1e-6, which=50.1)
>>> evals # the three closest eigenvalues to 50.1
array([ 50.,  51.,  49.])

The following examples compute a few eigenvalues and eigenvectors from a generalized Hermitian problem, without factorizing or inverting \(B\):

>>> import Primme, scipy.sparse
>>> A = scipy.sparse.spdiags(range(100), [0], 100, 100) # sparse diag. matrix
>>> M = scipy.sparse.spdiags(np.asarray(range(99,-1,-1)), [0], 100, 100)
>>> evals, evecs = primme.eigsh(A, 3, M=M, tol=1e-6, which='SA')
>>> evals
array([1.0035e-07, 1.0204e-02, 2.0618e-02])

The following examples compute a few singular values and vectors:

>>> import Primme, scipy.sparse
>>> A = scipy.sparse.spdiags(range(1, 11), [0], 100, 10) # sparse diag. rect. matrix
>>> svecs_left, svals, svecs_right = Primme.svds(A, 3, tol=1e-6, which='SM')
>>> svals # the three smallest singular values of A
array([ 1.,  2.,  3.])

>>> A = scipy.sparse.rand(10000, 100, random_state=10)
>>> prec = scipy.sparse.spdiags(np.reciprocal(A.multiply(A).sum(axis=0)),
...           [0], 100, 100) # square diag. preconditioner
>>> svecs_left, svals, svecs_right = Primme.svds(A, 3, which=6.0, tol=1e-6,
...           precAHA=prec)
>>> ["%.5f" % x for x in svals.flat] # the three closest singular values of A to 0.5
['5.99871', '5.99057', '6.01065']

Further examples.

Documentation of eigsh and svds.

Citing this code

Please cite (bibtex):

  • A. Stathopoulos and J. R. McCombs PRIMME: PReconditioned Iterative MultiMethod Eigensolver: Methods and software description, ACM Transaction on Mathematical Software Vol. 37, No. 2, (2010), 21:1-21:30.

  • L. Wu, E. Romero and A. Stathopoulos, PRIMME_SVDS: A High-Performance Preconditioned SVD Solver for Accurate Large-Scale Computations, J. Sci. Comput., Vol. 39, No. 5, (2017), S248–S271.

License Information

PRIMME and this interface is licensed under the 3-clause license BSD.

Contact Information

For reporting bugs or questions about functionality contact Andreas Stathopoulos by email, andreas at cs.wm.edu. See further information in the webpage http://www.cs.wm.edu/~andreas/software.

Release files for primme 3.2.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for primme 3.2.3
File Size Uploaded
primme-3.2.3.tar.gz 626.8 kB Details

Release files / primme-3.2.3.tar.gz

Download URL primme-3.2.3.tar.gz
Size 626.8 kB
Tags Source
SHA-256 checksum
How to use checksums
adc241c41a01adbf34d9975b2c14f58374de001f8b155a573628e99c11f67b47
BLAKE2b-256 checksum
How to use checksums
4a1340d8cd724a35c5557b293c0ee7659496c9a0d54fedf6dc23adaae927db9d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.3

Release history Release notifications | RSS feed

This release

3.2.3 This release

1 release file

3.2.2

1 release file

3.2.1

1 release file

3.2.0

1 release file

3.1.0

1 release file

3.0.3

1 release file

3.0.2

1 release file

3.0.1

1 release file

2.1.5

1 release file

2.1.4

1 release file

2.1.3

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page