pylops_mpi.basicoperators.MPIGradient#
- class pylops_mpi.basicoperators.MPIGradient(dims, sampling=1, edge=False, kind='centered', base_comm=<mpi4py.MPI.Intracomm object>, dtype='float64')[source]#
MPI Gradient
Apply gradient operator to a multi-dimensional distributed array.
Note
At least 2 dimensions are required, use
pylops_mpi.MPIFirstDerivative
for 1d arrays.- Parameters:
- dims
int
ortuple
Number of samples for each dimension.
- sampling
int
ortuple
, optional Sampling steps for each direction.
- edge
bool
, optional Use reduced order derivative at edges (
True
) or ignore them (False
).- kind
str
, optional Derivative kind (
forward
,centered
, orbackward
).- base_comm: obj:MPI.Comm, optional
MPI Base Communicator. Defaults to
mpi4py.MPI.COMM_WORLD
.- dtype
str
, optional Type of elements in input array.
- dims
Notes
The MPIGradient operator applies a first-order derivative to each dimension of a multi-dimensional distributed array in forward mode.
We utilize the
pylops_mpi.basicoperators.MPIFirstDerivative
to calculate the first derivative along the first direction (i.e., axis=0). For all remaining axes, thepylops.FirstDerivative
operator is pushed into thepylops_mpi.basicoperators.MPIBlockDiag
operator.Finally, using the
pylops_mpi.basicoperators.MPIStackedVStack
we vertically stack thepylops_mpi.basicoperators.MPIFirstDerivative
and thepylops_mpi.basicoperators.MPIBlockDiag
operators.For the forward mode, the matrix vector product is performed between the
pylops_mpi.basicoperators.MPIStackedVStack
and thepylops_mpi.DistributedArray
.For simplicity, given a three-dimensional array, the MPIGradient in forward mode using a centered stencil can be expressed as:
\[\mathbf{g}_{i, j, k} = (f_{i+1, j, k} - f_{i-1, j, k}) / d_1 \mathbf{i_1} + (f_{i, j+1, k} - f_{i, j-1, k}) / d_2 \mathbf{i_2} + (f_{i, j, k+1} - f_{i, j, k-1}) / d_3 \mathbf{i_3}\]In adjoint mode, the adjoint matrix vector product is performed between the
pylops_mpi.basicoperators.MPIStackedVStack
and thepylops_mpi.StackedDistributedArray
.Methods
__init__
(dims[, sampling, edge, kind, ...])adjoint
()Adjoint MPIStackedLinearOperator
conj
()Complex conjugate operator
dot
(x)Matrix Vector Multiplication
matvec
(x)Matrix-vector multiplication.
rmatvec
(x)Adjoint Matrix-vector multiplication.
transpose
()Transposition of MPIStackedLinearOperator