Skip to main content

Convenience wrapper for KryPy

Project description


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 =, 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


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

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


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

pip install -U pykry

to install or upgrade.


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



To create a new release

  1. bump the __version__ number,

  2. publish to PyPi and GitHub:

    make publish


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.

Files for pykry, version 0.1.5
Filename, size File type Python version Upload date Hashes
Filename, size pykry-0.1.5-py2.py3-none-any.whl (7.0 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size pykry-0.1.5.tar.gz (5.0 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page