pylops.Block¶
- class pylops.Block(ops, nproc=1, forceflat=None, parallel_kind='multiproc', dtype=None)[source]¶
Block operator.
Create a block operator from N lists of M linear operators each. Note that in case one or more operators are filled with zeros, it is recommended to use the
pylops.Zerooperator instead of e.g.,pylops.MatrixMultwith a matrix of zeros, as the former will be simply by-passed both in the forward and adjoint steps.- Parameters:
- ops
list List of lists of operators to be combined in block fashion. Alternatively,
numpy.ndarrayorscipy.sparsematrices can be passed in place of one or more operators.- nproc
int, optional Number of processes/threads used to evaluate the N operators in parallel using
multiprocessing/concurrent.futures. Ifnproc=1, work in serial mode.- forceflat
bool, optional Added in version 2.2.0.
Force an array to be flattened after rmatvec.
- parallel_kind
str, optional Added in version 2.6.0.
Parallelism kind when
nproc>1. Can bemultiproc(usingmultiprocessing) ormultithread(usingconcurrent.futures.ThreadPoolExecutor). Defaults tomultiproc.- dtype
str, optional Type of elements in input array.
- ops
- Attributes:
- pool
multiprocessing.Poolorconcurrent.futures.ThreadPoolExecutororNone Pool of workers used to evaluate the N operators in parallel. When
nproc=1, no pool is created (i.e.,pool=None).- shape
tuple Operator shape.
- pool
Notes
In mathematics, a block or a partitioned matrix is a matrix that is interpreted as being broken into sections called blocks or submatrices. Similarly a block operator is composed of N sets of M linear operators each such that its application in forward mode leads to
\[\begin{split}\begin{bmatrix} \mathbf{L}_{1,1} & \mathbf{L}_{1,2} & \ldots & \mathbf{L}_{1,M} \\ \mathbf{L}_{2,1} & \mathbf{L}_{2,2} & \ldots & \mathbf{L}_{2,M} \\ \vdots & \vdots & \ddots & \vdots \\ \mathbf{L}_{N,1} & \mathbf{L}_{N,2} & \ldots & \mathbf{L}_{N,M} \end{bmatrix} \begin{bmatrix} \mathbf{x}_{1} \\ \mathbf{x}_{2} \\ \vdots \\ \mathbf{x}_{M} \end{bmatrix} = \begin{bmatrix} \mathbf{L}_{1,1} \mathbf{x}_{1} + \mathbf{L}_{1,2} \mathbf{x}_{2} + \mathbf{L}_{1,M} \mathbf{x}_{M} \\ \mathbf{L}_{2,1} \mathbf{x}_{1} + \mathbf{L}_{2,2} \mathbf{x}_{2} + \mathbf{L}_{2,M} \mathbf{x}_{M} \\ \vdots \\ \mathbf{L}_{N,1} \mathbf{x}_{1} + \mathbf{L}_{N,2} \mathbf{x}_{2} + \mathbf{L}_{N,M} \mathbf{x}_{M} \end{bmatrix}\end{split}\]while its application in adjoint mode leads to
\[\begin{split}\begin{bmatrix} \mathbf{L}_{1,1}^H & \mathbf{L}_{2,1}^H & \ldots & \mathbf{L}_{N,1}^H \\ \mathbf{L}_{1,2}^H & \mathbf{L}_{2,2}^H & \ldots & \mathbf{L}_{N,2}^H \\ \vdots & \vdots & \ddots & \vdots \\ \mathbf{L}_{1,M}^H & \mathbf{L}_{2,M}^H & \ldots & \mathbf{L}_{N,M}^H \end{bmatrix} \begin{bmatrix} \mathbf{y}_{1} \\ \mathbf{y}_{2} \\ \vdots \\ \mathbf{y}_{N} \end{bmatrix} = \begin{bmatrix} \mathbf{L}_{1,1}^H \mathbf{y}_{1} + \mathbf{L}_{2,1}^H \mathbf{y}_{2} + \mathbf{L}_{N,1}^H \mathbf{y}_{N} \\ \mathbf{L}_{1,2}^H \mathbf{y}_{1} + \mathbf{L}_{2,2}^H \mathbf{y}_{2} + \mathbf{L}_{N,2}^H \mathbf{y}_{N} \\ \vdots \\ \mathbf{L}_{1,M}^H \mathbf{y}_{1} + \mathbf{L}_{2,M}^H \mathbf{y}_{2} + \mathbf{L}_{N,M}^H \mathbf{y}_{N} \end{bmatrix}\end{split}\]Methods
__init__(ops[, nproc, forceflat, ...])adjoint()apply_columns(cols)Apply subset of columns of operator
cond([uselobpcg])Condition number of linear operator.
conj()Complex conjugate operator
div(y[, niter, densesolver])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.
reset_count()Reset counters
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.
trace([neval, method, backend])Trace of linear operator.
transpose()