dpnp.gradient

dpnp.gradient(x1, *varargs, **kwargs)[source]

Return the gradient of an array.

For full documentation refer to numpy.gradient.

Limitations

Parameter y1 is supported as dpnp.ndarray. Argument varargs[0] is supported as int. Keyword argument kwargs is currently unsupported. Otherwise the function will be executed sequentially on CPU. Input array data types are limited by supported DPNP Available array data types.

See also

dpnp.diff

Calculate the n-th discrete difference along the given axis.

Examples

>>> import dpnp as np
>>> y = np.array([1, 2, 4, 7, 11, 16], dtype=float)
>>> result = np.gradient(y)
>>> [x for x in result]
[1.0, 1.5, 2.5, 3.5, 4.5, 5.0]
>>> result = np.gradient(y, 2)
>>> [x for x in result]
[0.5, 0.75, 1.25, 1.75, 2.25, 2.5]