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:
dimsint or tuple

Number of samples for each dimension.

samplingint or tuple, optional

Sampling steps for each direction.

edgebool, optional

Use reduced order derivative at edges (True) or ignore them (False).

kindstr, optional

Derivative kind (forward, centered, or backward).

base_comm: obj:MPI.Comm, optional

MPI Base Communicator. Defaults to mpi4py.MPI.COMM_WORLD.

dtypestr, optional

Type of elements in input array.

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, the pylops.FirstDerivative operator is pushed into the pylops_mpi.basicoperators.MPIBlockDiag operator.

Finally, using the pylops_mpi.basicoperators.MPIStackedVStack we vertically stack the pylops_mpi.basicoperators.MPIFirstDerivative and the pylops_mpi.basicoperators.MPIBlockDiag operators.

For the forward mode, the matrix vector product is performed between the pylops_mpi.basicoperators.MPIStackedVStack and the pylops_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 the pylops_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