Skip to main content

The PyOperators package defines operators and solvers for high-performance computing. These operators are multi-dimensional functions with optimised and controlled memory management. If linear, they behave like matrices with a sparse storage footprint.

More documentation can be found here: http://pchanial.github.io/pyoperators.

Getting started

To define an operator, one needs to define a direct function which will replace the usual matrix-vector operation:

>>> def f(x, out):
...     out[...] = 2 * x

Then, you can instantiate an Operator:

>>> A = pyoperators.Operator(direct=f, flags='symmetric')

An alternative way to define an operator is to define a subclass:

>>> from pyoperators import flags, Operator
... @flags.symmetric
... class MyOperator(Operator):
...     def direct(x, out):
...         out[...] = 2 * x
...
... A = MyOperator()

This operator does not have an explicit shape, it can handle inputs of any shape:

>>> A(np.ones(5))
array([ 2.,  2.,  2.,  2.,  2.])
>>> A(np.ones((2,3)))
array([[ 2.,  2.,  2.],
       [ 2.,  2.,  2.]])

By setting the symmetric flag, we ensure that A’s transpose is A:

>>> A.T is A
True

For non-explicit shape operators, we get the corresponding dense matrix by specifying the input shape:

>>> A.todense(shapein=2)
array([[2, 0],
       [0, 2]])

Operators do not have to be linear. Many operators are already predefined, such as the IdentityOperator, the DiagonalOperator or the nonlinear ClipOperator.

The previous A matrix could be defined more easily like this:

>>> from pyoperators import I
>>> A = 2 * I

where I is the identity operator with no explicit shape.

Operators can be combined together by addition, element-wise multiplication or composition. Note that the operator * stands for matrix multiplication if the two operators are linear, or for element-wise multiplication otherwise:

>>> from pyoperators import I, DiagonalOperator
>>> B = 2 * I + DiagonalOperator(range(3))
>>> B.todense()
array([[2, 0, 0],
       [0, 3, 0],
       [0, 0, 4]])

Algebraic rules can easily be attached to operators. They are used to simplify expressions to speed up their execution. The B Operator has been reduced to:

>>> B
DiagonalOperator(array([2, ..., 4], dtype=int64), broadcast='disabled', dtype=int64, shapein=3, shapeout=3)

Many simplifications are available. For instance:

>>> from pyoperators import Operator
>>> C = Operator(flags='idempotent,linear')
>>> C * C is C
True
>>> D = Operator(flags='involutary')
>>> D(D)
IdentityOperator()

Requirements

List of requirements:

  • python 2.6

  • numpy >= 1.6

  • scipy >= 0.9

Optional requirements:

  • numexpr (>= 2.0 is better)

  • PyWavelets : wavelet transforms

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyoperators-0.13.13.post04.tar.gz (182.3 kB view details)

Uploaded Source

File details

Details for the file pyoperators-0.13.13.post04.tar.gz.

File metadata

File hashes

Hashes for pyoperators-0.13.13.post04.tar.gz
Algorithm Hash digest
SHA256 513537c3ff8a45ba360ef1745a31b4ca2b6872a0a100f6f39fe632688dfe4567
MD5 d3c12d0bde77e48f8db24cd392ab7157
BLAKE2b-256 a88551fbb261a281b3247b91bde2aa98257eb5ba553bd9040e7b379abc75927c

See more details on using hashes here.

Release history Release notifications | RSS feed

0.16.2

13 files

0.16.1

13 files

0.15.0

10 files

0.14.4

10 files

0.14.2

6 files

0.14.1

4 files

0.14.0

6 files

0.13.18

4 files

0.13.17

4 files

0.13.16

1 file

0.13.15

1 file

0.13.14

1 file

This release

0.13.13.post04 This release

1 file

0.13.13

1 file

0.13.12

1 file

0.13.11

1 file

0.13.10

1 file

0.13.9

1 file

0.13.8

1 file

0.13.7

1 file

0.13.6.post06

1 file

0.13.6.post05

1 file

0.13.6.post04

1 file

0.13.6

1 file

0.13.5

1 file

0.13.4.post01

1 file

0.13.4

1 file

0.13.3

1 file

0.13.2

1 file

0.13.1

1 file

0.13

1 file

0.12.14

1 file

0.12.13

1 file

0.12.12

1 file

0.12.11

1 file

0.12.9

1 file

0.12.8

1 file

0.12.7

1 file

0.12.6

1 file

0.12.5

1 file

0.12.4

1 file

0.12.3

1 file

0.12.2

1 file

0.12.1

1 file

0.12

1 file

0.11.1

1 file

0.11

1 file

0.10.2

1 file

0.10.1

1 file

0.10

1 file

0.9

1 file

0.8.2

1 file

0.7.3

1 file

0.7.2

1 file

0.7.1

1 file

0.7

1 file

0.6.3

1 file

0.6.2

1 file

0.6.1

1 file

0.6

1 file

0.5

1 file

0.4

1 file

0.3

1 file

0.2

1 file

0.1

1 file

0.12.8-dirty

1 file

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page