Skip to main content

Krylov subspace methods for Python

Project description

krylov

Iterative methods for linear equation systems.

PyPi Version PyPI pyversions GitHub stars Downloads

Discord

gh-actions codecov LGTM Code style: black

krylov provides Krylov subspace methods for the solution of linear systems in Python. Install with

pip install krylov

and use as

import numpy
import krylov

A = numpy.diag([1.0e-3] + list(range(2, 101)))
b = numpy.ones(100)

sol, info = krylov.gmres(A, b)

# sol is None if no solution has been found
info.success  # Boolean
info.xk  # the last iterate; equal to sol if success
info.numsteps  # number of iterations
info.resnorms  # relative residual norms
info.nresnorms  # resnorms of the normalized equations ||A.H (b - Ax)||
info.acond  # estimate of cond(A)
info.anorm  # estimate of the Frobenius norm of A
info.xnorm  # estimate of norm(x)
info.reason  # if not successful, reason

krylov provides the following Krylov subspace methods for solving linear equation systems:

BiCG, BiCGSTAB, CG, CGNE, CGNR, CGR, CGS, Chebyshev, GCR, GMRES, MINRES, QMR, SYMMLQ, TFQMR.

For solving least-squares problems, krylov has

CGLS, LSMR, LSQR

Craig's method solves the minimization problem

\text{Minimize } \|x\| \text{s.t.} Ax=b.

Additionally, krylov provides the stationary methods

Gauss-Seidel, Jacobi, Richardson, SOR, SSOR.

All methods

  • return many interesting statistics, e.g., the residual norms,
  • are fully blocked/vectorized, can deal with multiple right-hand sides,
  • have callback for retrieving/manipulating internal solver data,
  • support real and complex data,
  • work with SciPy sparse matrices, NumPy arrays, custom LinearOperators,
  • allow arbitrary inner products, and
  • let the user adjust various parameters, e.g., the orthogonalization method in GMRES.

krylov is written completely in Python, so methods can be easily adapted.

Other Krylov software

Team Krylov

Some important figures in Krylov subspace method, ordered by date of birth.

Aleksey N. Krylov (1863–1945)

Алексе́й Никола́евич Крыло́в, Russian naval engineer, applied mathematician and memoirist. Krylov wrote about 300 papers and books. They span a wide range of topics, including shipbuilding, magnetism, artillery, mathematics, astronomy, and geodesy. In 1904 he built the first machine in Russia for integrating Ordinary differential equations. In 1931 (aged 68) he published a paper on what is now called the Krylov subspace and Krylov subspace methods.

Cornelius Lanczos (1893–1974)

Extensive contributions all over numerical analysis and physics. For example, Lanczos pioneered FFT, introduced Chebyshev polynomials to numerics, and devised the Lanczos algorithm for eigenvalue computations.

Assistant to Einstein in Berlin. Later one of the "Martians", a group of Hungarian scientists who emigrated to the US in the first half the 20th century.

In 1972, aged 79, Lanczos gave two extensive interviews which are recorded on video and can be watched on YouTube:


Alston Scott Householder (1904–1993)

Discoverer of the Householder transformation and of Householder's method. SIAM and ACM president, organizer of the Gatlinburg conferences, now named Householder Symposia.


Magnus Hestenes (1906–1991)

Best known for his contributions to calculus of variations and optimal control, pioneer in in computer science. Co-discoverer (with Lanczos and Stiefel) of the conjugate gradient method (CG).

AMS vice president.

Eduard Stiefel (1909–1978)

Ground-breaking contributions in the fields of algebraic topology. Co-discoverer (with Lanczos and Hestenes) of CG.

Also active as a military officer, rising to the rank of colonel (Oberst der Artillerie) in the Swiss army during World War II.

J. Wallace Givens (1910–1993)

Pioneer in computer science. Director of the Division of Applied Mathematics at the Argonne National Labs. SIAM president. Givens rotations are named after him.

Walter Edwin Arnoldi (1917–1995)

American engineer, mainly known for the discovery of the Arnoldi iteration which for Hermitian matrices, reduces to the Lanczos algorithm.


Henk van der Vorst (1944–)

Various important contributions in Krylov subspace methods and related topics. Discoverer of the BiCGSTAB method and the Jacobi-Davidson method.

Since 2006, van der Vorst works as an artist.

YouTube: Galerie Laimböck -- Henk van der Vorst ‘Geometrische Origami’ (Dutch)

Yousef Saad (1950–)

Various important contributions in Krylov subspace methods and related topics. Discoverer of GCR and GMRES (with Martin H. Schultz).

YouTube: Filtering techniques for eigenvalue problems, Saad

Christopher Paige

Discoverer of MINRES, SYMMLQ, and LSQR (with Saunders).

Michael Saunders

Discoverer of MINRES, SYMMLQ, LSQR (with Paige), and LSMR (with Fong).

Books

Testing

To run the krylov unit tests, check out this repository and type, e.g.,

tox -- --maxfail=1

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

krylov-0.1.0.tar.gz (31.9 kB view hashes)

Uploaded Source

Built Distribution

krylov-0.1.0-py3-none-any.whl (43.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page