Skip to main content

Krylov subspace methods for Python

Project description

krylov

Iterative methods for linear equation systems.

PyPi Version PyPI pyversions GitHub stars PyPi downloads

Discord

gh-actions codecov LGTM Code style: black

Forked from André Gaul's KryPy, krylov provides Krylov subspace methods for Python. It is more advanced than SciPy's linalg methods in that it

  • return many interesting statistics, e.g., the residual norms,
  • lets the user adjust more parameters, e.g., the orthogonalization method in GMRES,
  • allows arbitrary inner products, and
  • is fully blocked/vectorized.

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

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.cg(A, b)
# sol, info = krylov.minres(A, b)
sol, info = krylov.gmres(A, b)

# sol is None if no solution has been found
# info.resnorms contains the relative residual norms and some more data

# plot residuals
import matplotlib.pyplot as plt

plt.semilogy(info.resnorms)
plt.show()

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)

Discoveror 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 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 (with Saunders).


Michael Saunders

Discoverer of MINRES, SYMMLQ (with Paige).

Books

Advantages over SciPy

  • Works with SciPy sparse matrices, NumPy arrays, custom LinearOperators
  • Supports custom inner products
  • Returns residual norms and other interesting data
  • Full Python implementation
  • Fully vectorized, can deal with multiple right-hand sides
  • Supports floats and complex data

Testing

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

tox -- --maxfail=1

License

This software is published under the MIT license.

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.0.3.tar.gz (30.2 kB view details)

Uploaded Source

Built Distribution

krylov-0.0.3-py3-none-any.whl (38.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: krylov-0.0.3.tar.gz
  • Upload date:
  • Size: 30.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for krylov-0.0.3.tar.gz
Algorithm Hash digest
SHA256 e995605c0d6197fe1db489cd222eac870ff1eacdc50891b0dd75c7b8a9ca57a7
MD5 5c8bb7f8fa80dcc67a2d567974052dd3
BLAKE2b-256 4be9c4ce4157ea476d79e2aea0a69fe15c89fb960e0c5eda78c0d2c3f555497e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: krylov-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 38.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for krylov-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 6b6cc1eb6aa8ea0670d1c93b9db50e28a13eeaf426d67bd39293623de57b8726
MD5 5d110dc4b733b9dc53d55f0bccd86fcc
BLAKE2b-256 1e2d3c0496927040e15705438e021607e4877d369238b153f9e85ba8cd582979

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