There is only one class for creating a Linear Operator. Its constructor takes in the shape of the operator if it were a matrix (or equivalently the dimensions of the input and output of the function) and a forward function. An adjoint function is not defined by default, but they are required for many algorithms.
To test if a LinearOperator is correctly implemented (that the adjoint and forward functions are correct), it is helpful to use the adjointTest() and toMatrix() functions defined in PyOp.
The following operators are defined on Linear Operators A and B.
The following are all valid ways to call/apply the operator on an input x.
LinearOperators also define the string method, and can be directly used with str.
LinearOperators for performing transformations without matrices.
| Parameters: | shape : tuple
forward : function
adjoint : function, optional
|
|---|
Examples
>>> from numpy import array
>>> identity = LinearOperator((4,4), lambda x: x)
>>> identity(array([1,2,3,4]))
array([1, 2, 3, 4])
>>> identity = LinearOperator((4,4), lambda x: x, lambda x: x)
>>> identity.T(array([1,2,3,4]))
array([1, 2, 3, 4])
Attributes
| shape | (int, int) a pair representing the rows/columns of this transformation, if it were in matrix form. |
Methods
Provides the transpose of the current operator.
| Returns: | LinearOperator
|
|---|---|
| Raises: | MissingAdjoint
|
Performs the application of a LinearOperator to an input.
For a LinearOperator A, the following are the same:
A(x)
A.dot(x)
The reason for having two calling conventions is that arrays have the dot function, but not __call__ (or at least not with the same intentions). Having dot allows for functions to be written that are agnostic to their input, such that the input could be either a LinearOperator or an array.