Linear Operators

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.

  • +A, -A
  • 2*A, A*2
  • A**2
  • A + B, A - B, A * B
  • A == B, A != B

The following are all valid ways to call/apply the operator on an input x.

  • A(x)
  • A.dot(x)
  • A*x

LinearOperators also define the string method, and can be directly used with str.

class LinearOperator(shape, forward, adjoint=None)[source]

LinearOperators for performing transformations without matrices.

Parameters:

shape : tuple

a two element tuple describing the number of rows/columns this operator represents if it were in matrix form.

forward : function

the functional representation of a linear transform.

adjoint : function, optional

the adjoint of a linear transformation in functional form.

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

T[source]

Provides the transpose of the current operator.

Returns:

LinearOperator

the transpose of the current operator.

Raises:

MissingAdjoint

if the transpose function of the original operator was not defined.

dot(other)[source]

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.

Matrix Free Linear Operators

Navigation