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.1-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | de8c85ec297f4bedd950e3a4d25b9169d764cb5b4fbb0bb4b10a9fb3b3e3557a |
|
MD5 | c3f921bb5a0e8267bba800cb74e6eeab |
|
BLAKE2b-256 | 9c100e5108550537713eb6c13ffef4f125e715a4d2a3261f90f094f4a6315b35 |
Hashes for pyoperators-0.16.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 234c5291537cd75dad42c051e4d4e01e446a230a43c769033dca85220cfa90cd |
|
MD5 | 32874369ca37ed7cc138079886375556 |
|
BLAKE2b-256 | 20b9d0446db3c297016cfd4afb5bec9bc98742ba20651b081f146ebca3ff2cf2 |
Hashes for pyoperators-0.16.1-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3cd109c40dfc4cd17db18dd08f3970b74e7a4c08f66aa841e394d9fc2abefeb0 |
|
MD5 | 7443cc5e8116a5a9d48e6c5499204655 |
|
BLAKE2b-256 | 44c7abe332a45a698c531ce2886102baf2afde097b4726fce48fd50f38b52088 |
Hashes for pyoperators-0.16.1-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9794b39338fb81b00c40b02c6f9731539b548e664eb9532f010e770965707afe |
|
MD5 | 05a63afcaa092e403b39d2ef1e95f21d |
|
BLAKE2b-256 | 372953b10f34fc769678f19b81b70deedda5f501d333803821bc7e8c1f456d4b |
Hashes for pyoperators-0.16.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b3a01bc1576297052c70f280c3ca7766a22d6e40eb6e5c8c3e7ec3e8a4cd21a4 |
|
MD5 | 794eddee1c69020341fb569617965efb |
|
BLAKE2b-256 | 4395847257fb6ce8ae833bb87ebcc4fe0337d7df307bde650822764fb26bb5e4 |
Hashes for pyoperators-0.16.1-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8f42d2685d53f47f41370a0c650793a02b1809a3a85c6a52c1f75805362a7595 |
|
MD5 | 45f743464509437074386267ff816bd8 |
|
BLAKE2b-256 | 3020c2517d2d70d01fc5107709abdb7713b8f91a7eb5a57e25c4e0ff04d28df4 |
Hashes for pyoperators-0.16.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c4b256bdcc3e99a073dfd000fbf5964e450d33f4b4ebd189593271045cd50281 |
|
MD5 | 5d64654ee498f7f785eef918da528a5b |
|
BLAKE2b-256 | 0212f2f531b8ece88214434d23100acbba7c55947db989df7fda3d23a7b2e710 |
Hashes for pyoperators-0.16.1-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3c84e3c90aed565e4388b0ed8f24dbfc682f61d484ff1d5e025ecae3101cd089 |
|
MD5 | 1bf51e286bd013709e97cbe59c7f5bfe |
|
BLAKE2b-256 | c4f763000185dd85529af17a468ed27a747401faa5e39576303ac003f9e746ba |
Hashes for pyoperators-0.16.1-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e6dfa07674e6b907acb2c9b397446396281afc4048e4262a3b8f6779f2061bc0 |
|
MD5 | 6b09c6cdfd91db42a30fd91da1e3f4e8 |
|
BLAKE2b-256 | 164abdb63e4d2fda801ceec55d56fc4172be2d92c6521123a2205d5920b0027f |
Hashes for pyoperators-0.16.1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 59e743d9b2257d225b8ef60dee1c9ef9f776dbded01f2bb6b70892a88a56728e |
|
MD5 | 07be6276c76166cd73476a7518cd14dc |
|
BLAKE2b-256 | 45b9b7e351ca057520bd24a374c67812142a186d05982e836965a910d024aa80 |
Hashes for pyoperators-0.16.1-cp38-cp38-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aaccc2e4fcbb63763c95958ab42aa22d88e803bd4bcd9673024cd88edcd56867 |
|
MD5 | 4770bdab276ed18b1def213b1a6d69af |
|
BLAKE2b-256 | ab5477c9840ba1c444629c76f7f30e068a0eacf9e1f2ccf04accc92bb3dea568 |
Hashes for pyoperators-0.16.1-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bf91ef9b9a4b3f16ccda1996c5aff5aff4e3fb7856c76a9774937afb4bdc88b5 |
|
MD5 | 7bb43ee75a73260567aed562a58be273 |
|
BLAKE2b-256 | 8c3e4e0c2d328c4d16c488016c99ad9be1046b94c98cc0f7e0910fdfa2afea71 |