Skip to main content

Krylov subspace methods for Python

Project description

krylov

Krylov subspace methods.

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

  • allows arbitrary inner products,
  • return many interesting statistics, e.g., the residual norms,
  • lets the user adjust more parameters, e.g., the orthogonalization method in GMRES, and
  • is fully blocked/vectorized. krylov is written completely 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.cg(A, b)
# sol, info = krylov.minres(A, b)
sol, info = krylov.gmres(A, b)

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

# plot residuals
import matplotlib.pyplot as plt

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

Testing

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

pytest

License

krylov 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.2.tar.gz (28.3 kB view hashes)

Uploaded Source

Built Distribution

krylov-0.0.2-py3-none-any.whl (25.2 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