Eigen-powered dense and sparse linear algebra for Python, with a NumPy and SciPy native API.

$pip install peigentux

Fundamental solvers

Dense LU, QR, SVD and symmetric eigensolvers; sparse LU, sparse Cholesky and LDLᵀ, and the CG and BiCGSTAB iterative solvers.

Browse the algorithms →

NumPy and SciPy native

Functions take NumPy arrays and any scipy.sparse format, and return arrays and CSC matrices. Your inputs are never modified.

Sparse Cholesky, no SuiteSparse

Factor once, solve many times, and refactorize when only the values change. Log-determinants, diagonal shifts and inertia are built in.

Performant

Compiled Eigen kernels linked against Accelerate or OpenBLAS, with blocked solves for many right-hand sides.

See the benchmarks →

Easy to install

Prebuilt wheels for CPython 3.10–3.15 on Linux (x86_64, aarch64) and macOS (Apple silicon, Intel). No compiler needed.

Open source

MIT licensed and developed in public on GitHub. It bundles Eigen under MPL-2.0.

What pEigen is for

pEigen is a thin, well-tested layer over Eigen for Python users who want its solvers without writing C++. It is most useful when you solve with the same matrix many times, or need a factorization SciPy doesn't expose.

  • PDE and finite-element solvesFactor a sparse SPD stiffness matrix once and reuse it across load cases, or refactorize as values change in time stepping.
  • Gaussian processes and GMRFsExact log-determinants of sparse precision matrices, with a jitter or hyperparameter shift applied without rebuilding the matrix.
  • Constrained optimizationSolve KKT and saddle-point systems with pivoted LDLᵀ, and check the inertia to confirm a minimizer.
  • Graphs and point cloudsGraph Laplacian solves for spectral methods, smoothing and label propagation.
  • Permissively licensed stacksSparse Cholesky without SuiteSparse, in a package that is MIT plus MPL-2.0 end to end.
  • Everyday dense linear algebraSolve, QR, SVD and eigh with NumPy semantics, backed by LAPACK where it is available.

Get started in a minute

Install the wheel. The PyPI package is named peigentux, and you import it as peigen. Add the sparse extra to pull in SciPy for the sparse routines.

bash
pip install "peigentux[sparse]"

Then factor a sparse matrix and reuse the factorization:

More copy-paste examples

python
import numpy as np
import scipy.sparse as sp
from peigen import sparse

# 2D Poisson matrix, 200 x 200 grid
t = sp.diags([-1.0, 2.0, -1.0], [-1, 0, 1], shape=(200, 200))
K = (sp.kron(sp.eye(200), t) + sp.kron(t, sp.eye(200))).tocsc()

fac = sparse.cholesky(K)    # L D L^T, computed once
x = fac.solve(np.ones(K.shape[0]))
X = fac.solve(np.eye(K.shape[0], 32))  # 32 RHS at once
sign, logdet = fac.slogdet()

Performance at a glance

Single-threaded on an Apple M1 Pro, against SciPy's SuperLU and CHOLMOD (via scikit-sparse). CHOLMOD is still faster at factorizing 3D meshes; the benchmarks page has every number, including the cases pEigen loses.

1.8–6×
faster sparse Cholesky factorization than SciPy's default splu on 2D meshes and graphs
3–9×
faster 3D-mesh factorization with mode="multifrontal" than the default simplicial LDLᵀ
1.1–4.4×
faster 32-right-hand-side solves than CHOLMOD's best mode, on every problem tested