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__(f, *args, **kwargs) Initialize this LinearOperator.
adjoint() Hermitian adjoint.
apply_columns(cols) Apply subset of columns of operator
cond([uselobpcg]) Condition number of linear operator.
conj() Complex conjugate operator
div(y[, niter]) Solve the linear problem \(\mathbf{y}=\mathbf{A}\mathbf{x}\).
dot(x) Matrix-matrix or matrix-vector multiplication.
eigs([neigs, symmetric, niter, uselobpcg]) Most significant eigenvalues of linear operator.
matmat(X) Matrix-matrix multiplication.
matvec(x) Matrix-vector multiplication.
rmatmat(X) Matrix-matrix multiplication.
rmatvec(x) Adjoint matrix-vector multiplication.
todense([backend]) Return dense matrix.
toimag([forw, adj]) Imag operator
toreal([forw, adj]) Real operator
tosparse() Return sparse matrix.
transpose() Transpose this linear operator.