scicpp::diff

Defined in header <scicpp/core.hpp>

The n-th discrete difference between consecutive elements of an array.


template<int n = 1, typename T, std::size_t N>
std::array<T, max(N - n, 0)> diff(const std::array<T, N> &a)

template<typename T>
std::vector<T> diff(const std::vector<T> &a, int n = 1)
template<typename T>
std::vector<T> diff(std::vector<T> &&a, int n = 1)

Return a std::vector of size max(a.size() - n, 0).


See also
Scipy documentation