ClikaRT::ops::diff
function
diff()
Tensor diff(
Tensor x,
int64_t n = 1,
int64_t dim = -1,
OptionalTensor prepend = {},
OptionalTensor append = {}
)
n-th order finite difference along dim.
Each application shortens the axis by one, so the output's dim extent is size(dim) - n. prepend / append are concatenated onto the axis before differencing (they must match x's shape outside dim).
Parameters
x: the input tensor.n: how many times to difference. Default1.dim: the axis. Negative counts from the end. Default-1.prepend: optional tensor concatenated beforexalongdim.append: optional tensor concatenated afterxalongdim.
Throws
ClikaRT::Error: whendimis out of range,nexceeds the (extended) axis length, or a prepend/append shape does not match (code_name()carries the reason).
Returns: dtype of x; dim shortened by n (after any prepend/append extension).
auto d1 = ClikaRT::ops::diff(series); // first difference
auto d2 = ClikaRT::ops::diff(series, 2); // second difference
Declared in ClikaRT/compute/ops.h, line 4862