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.

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.


>>> from pylops.basicoperators import FunctionOperator
>>> def forward(v):
...     return np.array([2*v[0], 3*v[1]])
>>> 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.])
shape : tuple

Operator shape \([n \times m]\)

explicit : bool

Operator contains a matrix that can be solved explicitly (True) or not (False)


__init__(self, f, \*args, \*\*kwargs) Initialize this LinearOperator.
adjoint(self) Hermitian adjoint.
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.
rmatvec(self, x) Adjoint matrix-vector multiplication.
transpose(self) Transpose this linear operator.