pyoperators 0.13.15
Operators and solvers for highperformance computing.
The PyOperators package defines operators and solvers for highperformance computing. These operators are multidimensional 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 matrixvector 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 nonexplicit 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, elementwise multiplication or composition. Note that the operator * stands for matrix multiplication if the two operators are linear, or for elementwise 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
File  Type  Py Version  Uploaded on  Size  

pyoperators0.13.15.tar.gz (md5)  Source  20170105  177KB  
 Author: Pierre Chanial
 Home Page: http://pchanial.github.com/pyoperators
 Keywords: scientific computing
 License: CeCILLB
 Platform: MacOS X,Linux,Solaris,Unix,Windows

Categories
 Development Status :: 4  Beta
 Intended Audience :: Science/Research
 Operating System :: OS Independent
 Programming Language :: C
 Programming Language :: Cython
 Programming Language :: Python
 Programming Language :: Python :: 2
 Programming Language :: Python :: 2.6
 Programming Language :: Python :: 2.7
 Programming Language :: Python :: 3
 Programming Language :: Python :: 3.3
 Programming Language :: Python :: 3.4
 Topic :: Scientific/Engineering
 Package Index Owner: pchanial
 DOAP record: pyoperators0.13.15.xml