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.MPIFirstDerivativefor 1d arrays.- Parameters:
- dims
intortuple Number of samples for each dimension.
- sampling
intortuple, 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.MPIFirstDerivativeto calculate the first derivative along the first direction (i.e., axis=0). For all remaining axes, thepylops.FirstDerivativeoperator is pushed into thepylops_mpi.basicoperators.MPIBlockDiagoperator.Finally, using the
pylops_mpi.basicoperators.MPIStackedVStackwe vertically stack thepylops_mpi.basicoperators.MPIFirstDerivativeand thepylops_mpi.basicoperators.MPIBlockDiagoperators.For the forward mode, the matrix vector product is performed between the
pylops_mpi.basicoperators.MPIStackedVStackand 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.MPIStackedVStackand 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