pyrtid.utils.operators.gradient_ffd#

pyrtid.utils.operators.gradient_ffd(param: ndarray[Any, dtype[float64]], dx: float, axis: int = 0) ndarray[Any, dtype[float64]][source]#

Compute the gradient using the first order forward differences.

The returned gradient hence has the same shape as the input array.

Parameters
  • param (np.array) – An N-dimensional array containing samples of a scalar function.

  • dx (float) – Spacing between param values along the axis.

  • axis (int) – Axis on which to compute the gradient (0=x, 1=y)

Returns

grad – The gradient.

Return type

NDArrayFloat