Skip to main content

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


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.15.0.tar.gz (210.1 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pyoperators-0.15.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (255.3 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64manylinux: glibc 2.5+ x86-64

pyoperators-0.15.0-cp310-cp310-macosx_11_0_arm64.whl (153.3 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

pyoperators-0.15.0-cp310-cp310-macosx_10_9_x86_64.whl (157.7 kB view details)

Uploaded CPython 3.10macOS 10.9+ x86-64

pyoperators-0.15.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (254.5 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64manylinux: glibc 2.5+ x86-64

pyoperators-0.15.0-cp39-cp39-macosx_11_0_arm64.whl (152.9 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

pyoperators-0.15.0-cp39-cp39-macosx_10_9_x86_64.whl (157.1 kB view details)

Uploaded CPython 3.9macOS 10.9+ x86-64

pyoperators-0.15.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (256.8 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64manylinux: glibc 2.5+ x86-64

pyoperators-0.15.0-cp38-cp38-macosx_11_0_arm64.whl (153.4 kB view details)

Uploaded CPython 3.8macOS 11.0+ ARM64

pyoperators-0.15.0-cp38-cp38-macosx_10_9_x86_64.whl (157.9 kB view details)

Uploaded CPython 3.8macOS 10.9+ x86-64

File details

Details for the file pyoperators-0.15.0.tar.gz.

File metadata

  • Download URL: pyoperators-0.15.0.tar.gz
  • Upload date:
  • Size: 210.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for pyoperators-0.15.0.tar.gz
Algorithm Hash digest
SHA256 ba7f718768e7cb8dc75e4ce5c7dd38d048df144bc967108d7719b18e12f12a97
MD5 6715321fed2699deb82f28023975e16b
BLAKE2b-256 0cdf89d08cc6013fcc17d684e5aa00534c14d4648da3482848092179e725826c

See more details on using hashes here.

File details

Details for the file pyoperators-0.15.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyoperators-0.15.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8cf116d17e072d4ebad1f594cf413bb13c0b6a15ad05232944ba023eb6d60a8c
MD5 bb11d6d7f37adf39882768611d4a58db
BLAKE2b-256 74ee131fc33ca094d886533cfbb90d450372bad9a0613946834c16032f0ee167

See more details on using hashes here.

File details

Details for the file pyoperators-0.15.0-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyoperators-0.15.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5ee54f0e4002e72de014631bd3b37d8825f739f3930f6f527514913fd325f6f6
MD5 5cf948d7e0145f671bfef13aa382b21c
BLAKE2b-256 6cec4407a85a75c89e2f0abe97e83710b89f8e0a329a268a3eb29e87a04d2862

See more details on using hashes here.

File details

Details for the file pyoperators-0.15.0-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for pyoperators-0.15.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 5222dee2038f8f5de69e63c4fa3ece767dc451db054dd22cc2055e5be4a75303
MD5 bee2481e7fdd3e97f5b1e9c407aabd31
BLAKE2b-256 f6a47b4083e6b440a6519e21287e0740e034fd0cda37cb917ac05dfd09456971

See more details on using hashes here.

File details

Details for the file pyoperators-0.15.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyoperators-0.15.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6416690179a65a162b0641a64dfae4aa302124d226e3bedaa6c976b546cdebaf
MD5 da5ce39f8922970cdd52cac8e026513d
BLAKE2b-256 a5fa416f0e5f698ab34630fc8d88cab1122765eee4face4c1657f583a38d40be

See more details on using hashes here.

File details

Details for the file pyoperators-0.15.0-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyoperators-0.15.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f3973c36072fa74b0ae8d9c9f888b101f87ca18d14b506dd1bb1efdb2c3b1f0c
MD5 a3141f72584fbcfe0b6bd37e30a929ad
BLAKE2b-256 af2118b56b3ed385a468237ca982a96daf6f9906a4824be7d7b019fea041b96f

See more details on using hashes here.

File details

Details for the file pyoperators-0.15.0-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for pyoperators-0.15.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 488e7216f79d023128dc9be007d843fe176674a9ddc6c1a7b45d9ba200fb3b42
MD5 14922e45b7e5c4c74bb73b790d33cbaf
BLAKE2b-256 9b516264d935f1c21434109feebaa9e079ede336820007b9940d2b822fcc138d

See more details on using hashes here.

File details

Details for the file pyoperators-0.15.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyoperators-0.15.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 000df2bcfd7bf60cbc68c23c0096af104474e1f2cf80709fbb9f2f0472e1769f
MD5 6225f6a1a2d0143e2a30f1bac63c40c6
BLAKE2b-256 34d0e59064c1ab0e8200a1fad822d67fca2d97648262c351e7bef063b3eebb52

See more details on using hashes here.

File details

Details for the file pyoperators-0.15.0-cp38-cp38-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyoperators-0.15.0-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 811d73c2bd64f206e4480e2db81ccda9820a65fb36a3e1d75c950c223bc0c92c
MD5 aea5e8ecec30aa6b0d562f82971eb590
BLAKE2b-256 36baded36596ec043b77e6647d0ee11b8179813b3b6e32730955aee8d4cb3a72

See more details on using hashes here.

File details

Details for the file pyoperators-0.15.0-cp38-cp38-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for pyoperators-0.15.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 41049510751413a3284d8324aa20fa9ee1fe6495adeda0a13ad23af27451a926
MD5 8d62fa0ef7c1f0693bea954aa313eec8
BLAKE2b-256 cf6d556f223293be69566b7334d1f5d199a412a00bf05af09ff3871c5ff0884f

See more details on using hashes here.

Supported by

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