Operators and solvers for high-performance computing.
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for pyoperators-0.14.2-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 82e716489a809007d5d603f106aaed7ba9f85b981bf9626d12bf9be629e65ad4 |
|
MD5 | 235bedbe4943614f39c3d17b8d90350d |
|
BLAKE2b-256 | cc9e16f8b6799b6ea16bf457468c059909edba77fbaba6afed217e53aca9b456 |
Hashes for pyoperators-0.14.2-cp310-cp310-macosx_12_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2f123c5e827498e0053eb7504d6ba9f69c04c45c6126085c1f546b0b410adec4 |
|
MD5 | c0d86e1930df1a82d960d7e6078ff276 |
|
BLAKE2b-256 | ee90fa078fedddb32aaa15e1b47d53f8a24f85a2c1d1a6d7c5aed3f3123bf4c3 |
Hashes for pyoperators-0.14.2-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0a4e1e287928c82ed176b82857e321748efde62fd4e0e4d44290759b07c8bde7 |
|
MD5 | ec8dfca0f0adafb056a28b0600b7128f |
|
BLAKE2b-256 | 25d203f9e6c8264b8c197127dc07924f797229e384f1b02d54299d5fb1f60d0c |
Hashes for pyoperators-0.14.2-cp39-cp39-macosx_12_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 54c3df9f843dce08444a68343e120c1e413a9b414f983ba82b038109112118b4 |
|
MD5 | a2e0433cbc2e089bd45cb045c90ac0b1 |
|
BLAKE2b-256 | baf33b70bd8f1495b7a8f9b24c654d22a82132e24bb9f0a92f7a91b17ce2c148 |
Hashes for pyoperators-0.14.2-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 26a1536266960cb27e06e90be636de8cec7f93794e15d6b22d35b7e5a8d49a0d |
|
MD5 | 09cbafcdf7ca033c1324c58ed862074b |
|
BLAKE2b-256 | 24ae7696749f48e6a5627127f5ae0a3507e940acfc1e14d001cab085ed3c0610 |