Skip to main content

Convenience wrapper for KryPy

Project description

pykry

CircleCI codecov Code style: black PyPi Version GitHub stars

pykry is a thin wrapper around KryPy that makes using Krylov subspace methods in Python a little more convenient. Simply create the matrix and the right-hand side, then fire it up:

import numpy
import pykry

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

# out = pykry.cg(A, b)
# out = pykry.minres(A, b)
out = pykry.gmres(A, b)

# out.xk contains the last iterate (ideally the solution),
# out.resnorms the relative residual norms;
# there's plenty more

convergence

Owing to KryPy, pykry has a plethora of extra parameters to hand to either one of the methods.

Getting more fancy with linear operators is as easy as defining a matrix-vector multiplication:

import numpy
import pykry

n = 100
A = numpy.diag([1.0e-3] + list(range(2, n + 1)))

def dot(x):
  return A.dot(x)

linear_operator = pykry.LinearOperator((n, n), float, dot=lambda x: dot, dot_adj=dot)
b = numpy.ones(n)
out = pykry.cg(linear_operator, b)

Installation

pykry is available from the Python Package Index, so simply type

pip install -U pykry

to install or upgrade.

Testing

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

pytest

Distribution

To create a new release

  1. bump the __version__ number,

  2. publish to PyPi and GitHub:

    make publish
    

License

pykry 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.

Filename, size & hash SHA256 hash help File type Python version Upload date
pykry-0.1.5-py2.py3-none-any.whl (7.0 kB) Copy SHA256 hash SHA256 Wheel py2.py3
pykry-0.1.5.tar.gz (5.0 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page