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 details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

Details for the file krylov-0.1.0.tar.gz.

File metadata

  • Download URL: krylov-0.1.0.tar.gz
  • Upload date:
  • Size: 31.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1

File hashes

Hashes for krylov-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4f2d5d8327c57c0f06509fcacf2e235ea0a11b9041b357f03ae93f22cc267f86
MD5 0b8dac872e3147c2549dfae6f6cdf5e5
BLAKE2b-256 4f1284681992bcd7113d090d5c1f9a34e6c8e4c00799577183cce3df5fe87a84

See more details on using hashes here.

File details

Details for the file krylov-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: krylov-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 43.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1

File hashes

Hashes for krylov-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b6b4d04fbbcb42a6385f653160fcf67c0f3dd14e39ca3c0a5af78102ae3d50d7
MD5 5325b944e09a04e0826ff80185d56c5d
BLAKE2b-256 874c5561b235519b2de6671deb6978066e59f57a2fcd00b019a240dc7f567f26

See more details on using hashes here.

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