Operators and solvers for high-performance computing.
Project description
PyOperators
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.
Documentaion
https://pchanial.github.io/pyoperators
Installation
pip install pyoperators[fft,wavelets]
On some platforms, it might be more convenient to install pyfftw through Conda beforehand to use the FFTOperator
:
conda install pyfftw
For MPI communication, an MPI library needs to be installed, for example on Ubuntu:
sudo apt install libopenmpi-dev
pip install pyoperators[fft,wavelets,mpi]
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 DiagonalOperator
, the FFTOperator
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
- python 3.8
Optional requirements:
- PyWavelets: wavelet transforms
- pyfftw: Fast Fourier transforms
- mpi4py: For MPI communication
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.16.2-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3c978bc03a1412ae98cd9c026d771b084992eee4df92831482a61b7ce2a3653d |
|
MD5 | 58d32af6f286cfe42f206b862dd9fde2 |
|
BLAKE2b-256 | 8eb87c70dc89b601863a352fedaa2903d92af0b06699d48579d9f7d0de6f007d |
Hashes for pyoperators-0.16.2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ecff1094df49c6cf5906835dc6b91861c714947f5225c0a67e7769bf1113e514 |
|
MD5 | 9137612a202f3c35e14580c0378d6480 |
|
BLAKE2b-256 | f6df16940943cc73de11343b09edb054baa23c692d04a590b6225a6ff973f551 |
Hashes for pyoperators-0.16.2-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 63fe48bdf44839c44ffb4507367e1dbd4736ee71856bb08019589636a5e5d850 |
|
MD5 | cfa8752f8d4fa7f40f2e31afa34d3775 |
|
BLAKE2b-256 | 2219efd5e835787aa48f042b60d858be52fa3a59532226b6a51656250cb1af3c |
Hashes for pyoperators-0.16.2-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e692354d64f003efe0319a9a5c8932071366e36366d88db7124c2cd5789e30ae |
|
MD5 | 735bf6dc6da52deda54790cb4951b4c4 |
|
BLAKE2b-256 | be6609382f27a0fd201364e48336399552cdec39d765c15c113a9a9c7fb923af |
Hashes for pyoperators-0.16.2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4a5b1cb2d8ea028ef07c47a7a5a5b55397dc4a6c7926e541fc27b0fd1e518fff |
|
MD5 | 873770724dda207c9398e9c4d7c77d93 |
|
BLAKE2b-256 | 2efe499e7f6d0cc078805503fa9b42671ef78bf2484b6eb9f38473e9b72ac3d9 |
Hashes for pyoperators-0.16.2-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7768be7e79b4f7373eaade907baf29b091659f65b073a3dcb7bf3c7b9c8f3d27 |
|
MD5 | 0d14156a5c913eb86dd9c37b78e782c6 |
|
BLAKE2b-256 | e74e1f1fdba75bdc463c8f5041cde6124d5c79896e3dfb636d2db294719a257c |
Hashes for pyoperators-0.16.2-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7c79a3b0e4565f5edc766a32cbd8e1bb189f6bcab5e930bef5363c8da5cb1548 |
|
MD5 | 3993ab253ae2bd87cfaa72fb83ff2f89 |
|
BLAKE2b-256 | 573260016855848f4829eaea862c3588211c6976cccd4e3e383d1c79341443b7 |
Hashes for pyoperators-0.16.2-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4e0ecc07068bf5d6496b4a7087c044e949373fb4f3947d157a34c8aff5cfddf5 |
|
MD5 | db4b3ba2961964687257a714485c1e89 |
|
BLAKE2b-256 | fde731a43ebbe44c7ea23ab5191acdb8935d3905a4ff62ad7acf335f9a917111 |
Hashes for pyoperators-0.16.2-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b24c7ef984aebc32738f2c837d60bb5a69e10043f3b556f5f30bf632343e9f65 |
|
MD5 | ef4168068aaabd6b6b76413cec30c161 |
|
BLAKE2b-256 | 8243cf93aeb8b3424d9890acb4441b6479eb9d1fa90a3fdd5c340d70f9b0ea0a |
Hashes for pyoperators-0.16.2-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8b7462af25d328743fa9a897df2d2577f41b5a0113825edc2d10b2fff3771df6 |
|
MD5 | b6bd8734305e434127a74b1bf8b04974 |
|
BLAKE2b-256 | d24cfdb87724e3564d885db8571dbf15ed2871a6964ed62ca4a2807c712e9428 |
Hashes for pyoperators-0.16.2-cp38-cp38-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ee895fb3486d90f3354e22610226f4d916d5ffab0b6bf8dd92a6c277b8c8cadc |
|
MD5 | df7bb3145675ee55f4235eac94c0c914 |
|
BLAKE2b-256 | 28f909fbb6eaecce2ff63b93cb20efa6dd8c7d6316a26f28d8ffd753ee83cab9 |
Hashes for pyoperators-0.16.2-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 16fdec247bb12088a6eecea3610db9bd4e22fd81d0ebe056125cf487f09f1d29 |
|
MD5 | 4a96c29a20d78ac465b408149157ec24 |
|
BLAKE2b-256 | 3bf710f32b1020bcd076f7c92532f369345b0d9948521c533d1acdcb9bcf0763 |