pylops.Gradient

pylops.Gradient(dims, sampling=1, edge=False, dtype='float64')[source]

Gradient.

Apply gradient operator to a multi-dimensional array (at least 2 dimensions are required).

Parameters:
dims : tuple

Number of samples for each dimension.

sampling : tuple, optional

Sampling steps for each direction.

edge : bool, optional

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

dtype : str, optional

Type of elements in input array.

Returns:
l2op : pylops.LinearOperator

Gradient linear operator

Notes

The Gradient operator applies a first-order derivative to each dimension of a multi-dimensional array in forward mode.

For simplicity, given a three dimensional array, the Gradient in forward mode is:

\[\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}\]

which is discretized as follows:

\[\begin{split}\mathbf{g} = \begin{bmatrix} \mathbf{df_1} \\ \mathbf{df_2} \\ \mathbf{df_3} \end{bmatrix}\end{split}\]

In adjoint mode, the adjoints of the first derivatives along different axes are instead summed together.

Examples using pylops.Gradient