Algorithms

Every routine pEigen exposes, which Eigen class or LAPACK routine runs it, and what it expects from your matrix.

Which solver should I use?

Your matrixUseWhy
Dense, squarelinalg.solve(A, b)LU with partial pivoting (LAPACK dgesv).
Dense, tall (least squares)decomp.QR(A).solve(b) or decomp.SVD(A).solve(b)QR for full column rank; SVD for rank-deficient problems or the minimum-norm solution.
Sparse, symmetric positive definitesparse.cholesky(A)Simplicial LDLᵀ with AMD ordering. Reusable, with refactorize, slogdet and shift.
Sparse SPD with lots of fill (3D meshes)sparse.cholesky(A, mode="multifrontal")Dense frontal matrices and level-3 BLAS: 3–9× faster than simplicial on 3D meshes.
Sparse, symmetric indefinite (KKT, saddle point)sparse.cholesky(A, mode="multifrontal")Pivoted LDLᵀ with 1×1 and 2×2 pivots; also reports the inertia.
Sparse, nonsymmetricsparse.factorize(A)Eigen SparseLU (supernodal LU with partial pivoting).
Sparse SPD, too large to factorsparse.solve(A, b, method="cg")Conjugate gradient, optionally with a Jacobi preconditioner.
Sparse nonsymmetric, too large to factorsparse.solve(A, b, method="bicgstab")BiCGSTAB with Eigen's default diagonal preconditioner.

Dense linear algebra: peigen.linalg

The functions follow NumPy's conventions: a 1D right-hand side returns a 1D solution, and shapes match numpy.linalg. Where both are available, method="auto" picks LAPACK; the release wheels always link it.

FunctionComputesBackends (method=)Notes
matmul(a, b)a @ bEigen GEMM, which calls BLAS dgemm when linkedReturns a new C-ordered array.
solve(a, b)x with a x = blapack: dgesv · eigen: PartialPivLURaises ValueError for singular or numerically singular a.
qr(a, mode="reduced")Q, R with a = Q REigen HouseholderQRmode="complete" returns the full m×m Q.
svd(a, full_matrices=False)U, s, Vtlapack: dgesdd · bdcsvd: Eigen BDCSVDSingular values in descending order, as in NumPy.
eigh(a, lower=True)w, V for symmetric alapack: dsyevd · eigen: SelfAdjointEigenSolverOnly the chosen triangle is read. Eigenvalues ascending.
eighvals(a, lower=True)was eighSkips the eigenvectors.
norm(a, ord=None, axis=None)Frobenius norm (default)Eigen reductionOther ord/axis combinations defer to numpy.linalg.norm.

Sparse Cholesky: sparse.cholesky

sparse.cholesky(a, mode="ldlt", ordering="amd", lower=True, shift=0.0) factors P (A + shift·I) Pᵀ once and returns a reusable SparseCholesky. Only one triangle of A is read, so you can pass just that triangle. It needs no SuiteSparse.

ModeFactorizationEigen classUse it for
"ldlt" (default)L D Lᵀ, no square rootsSimplicialLDLTSPD matrices with low fill: 2D meshes, graph Laplacians, banded systems. Solves with many right-hand sides use a blocked kernel.
"llt"L LᵀSimplicialLLTClassic Cholesky. Raises if the matrix isn't positive definite, so it doubles as a definiteness test.
"multifrontal" experimentalPivoted L D Lᵀ, with D made of 1×1 and 2×2 blocksMultifrontalLDLTHigh-fill problems (3D meshes) and symmetric indefinite matrices. Solves with several right-hand sides use a supernodal blocked kernel.

Orderings

ordering="amd" (approximate minimum degree) reduces fill-in and is the right choice almost always. ordering="natural" keeps the input order, which is only useful for banded matrices or debugging.

What a factorization can do

MemberDoes
solve(b)Solves for a 1D or 2D b. Releases the GIL, so threads can share one factorization.
refactorize(a, shift=None)New values with the same sparsity pattern: reruns only the numeric phase. Raises ValueError if the pattern differs.
slogdet() / logdet()(sign, log|det|) as in numpy.linalg.slogdet, without overflow. logdet() requires a positive determinant.
inertia(positive, negative, zero) eigenvalue counts, read off the pivots of D (Sylvester's law of inertia).
shift, mode, ordering, shape, factor_nnzSettings, and the number of stored nonzeros in L (a measure of fill-in).

Indefinite matrices: use mode="multifrontal". "ldlt" doesn't pivot for stability, so it can be inaccurate or fail on them. Multifrontal's threshold pivoting doesn't rescale the matrix, so equilibrate badly scaled input first.

One-shot use: sparse.solve(A, b, method="cholesky") is the same as sparse.cholesky(A).solve(b).

Sparse LU: sparse.factorize

sparse.factorize(A) wraps Eigen's SparseLU: a supernodal LU with partial pivoting and a COLAMD column ordering, for general square matrices. It returns a SparseFactorized object whose solve(b) accepts 1D or 2D right-hand sides. sparse.solve(A, b) (method="auto" or "lu") does the same in one call.

Iterative solvers: sparse.solve

method=MatrixEigen classPreconditioners
"cg"Symmetric positive definiteConjugateGradient"none", "jacobi" (diagonal), "ilu" (IncompleteLUT)
"bicgstab"General squareBiCGSTABDiagonal (Eigen's default)

tol is the relative residual ‖Ax − b‖ / ‖b‖ (default 1e-8), and maxiter defaults to 2n. The solvers raise RuntimeError if they don't converge. sparse.solve_stats(A, b, method="cg", ...) returns the iteration count and estimated error, for comparing preconditioners.

ILU with CG: IncompleteLUT is not a symmetric preconditioner, and CG assumes one. With the default ilu_fill_factor=10 it can fail to converge even on a 2D Laplacian. Raise ilu_fill_factor (for example to 40), use "jacobi", or factor the matrix with sparse.cholesky instead.

Sparse products and helpers

FunctionComputesReturns
spmm(a, b)sparse @ denseNumPy array
spspmm(a, b)sparse @ sparsescipy.sparse CSC matrix, pruned
to_dense(a)sparse to denseNumPy array
from_coo(data, row, col, shape)build from triplets (duplicates summed)scipy.sparse CSC matrix

For plain products, SciPy's own @ is currently faster; see the benchmarks. These functions are mainly here for API completeness.

Reusable decompositions: peigen.decomp

ClassHoldssolve
SVD(a, full_matrices=False)U, s, VtMinimum-norm least squares; singular values <= rcond · max(s) count as zero (rcond is relative, as in numpy.linalg.lstsq).
QR(a, mode="reduced")Q, RSquare or tall a with full column rank: exact or least-squares solution, from either mode.
SparseFactorized(a)Sparse LUSame as sparse.factorize.
SparseCholesky(a, ...)Sparse Cholesky / LDLᵀSame as sparse.cholesky.

Conventions

  • Real double precision. Everything runs in float64. Integer and float32 inputs are converted; complex inputs raise TypeError rather than silently dropping the imaginary part.
  • Any SciPy sparse format. *_matrix or *_array, int32 or int64 indices. Unsorted or duplicate entries are canonicalized on a copy; your matrix is never modified.
  • Size limit. Sparse dimensions and nonzero counts must fit in 32-bit indices; larger matrices raise ValueError.
  • Errors. ValueError for bad shapes or arguments, numpy.linalg.LinAlgError when a Cholesky factorization breaks down, RuntimeError when an iterative solver doesn't converge or a sparse LU fails.
  • Licensing. pEigen is MIT. It compiles Eigen with EIGEN_MPL2_ONLY, so the wheels contain only MPL-2.0 Eigen code.