# pylops.FunctionOperator¶

class pylops.FunctionOperator(f, *args, **kwargs)[source]

Function Operator.

Simple wrapper to functions for forward f and adjoint fc multiplication.

Functions $$f$$ and $$fc$$ are such that $$f:\mathbb{F}^m \to \mathbb{F}^n$$ and $$fc:\mathbb{F}^n \to \mathbb{F}^m$$ where $$\mathbb{F}$$ is the appropriate underlying type (e.g., $$\mathbb{R}$$ for real or $$\mathbb{C}$$ for complex)

FunctionOperator can be called in the following ways: FunctionOperator(f, n), FunctionOperator(f, n, m), FunctionOperator(f, fc, n), and FunctionOperator(f, fc, n, m).

The first two methods can only be used for forward modelling and will return NotImplementedError if the adjoint is called. The first and third method assume the matrix (or matrices) to be square. All methods can be called with the dtype keyword argument.

Parameters: f : callable Function for forward multiplication. fc : callable, optional Function for adjoint multiplication. n : int, optional Number of rows (length of data vector). m : int, optional Number of columns (length of model vector). dtype : str, optional Type of elements in input array.

Examples

>>> from pylops.basicoperators import FunctionOperator
>>> def forward(v):
...     return np.array([2*v, 3*v])
...
>>> A = FunctionOperator(forward, 2)
>>> A
<2x2 FunctionOperator with dtype=float64>
>>> A.matvec(np.ones(2))
array([2.,  3.])
>>> A @ np.ones(2)
array([2.,  3.])

Attributes: shape : tuple Operator shape $$[n \times m]$$ explicit : bool Operator contains a matrix that can be solved explicitly (True) or not (False)

Methods

 __init__(self, f, \*args, \*\*kwargs) Initialize this LinearOperator. adjoint(self) Hermitian adjoint. apply_columns(self, cols) Apply subset of columns of operator cond(self, \*\*kwargs_eig) Condition number of linear operator. conj(self) Complex conjugate operator div(self, y[, niter]) Solve the linear problem $$\mathbf{y}=\mathbf{A}\mathbf{x}$$. dot(self, x) Matrix-matrix or matrix-vector multiplication. eigs(self[, neigs, symmetric, niter]) Most significant eigenvalues of linear operator. matmat(self, X) Matrix-matrix multiplication. matvec(self, x) Matrix-vector multiplication. rmatmat(self, X) Adjoint matrix-matrix multiplication. rmatvec(self, x) Adjoint matrix-vector multiplication. todense(self) Return dense matrix. transpose(self) Transpose this linear operator.