Accumulating functions¶
xtensor provides the following accumulating functions for xexpressions:
Defined in xtensor/xmath.hpp
-
template<class T = void, class E>
inline auto xt::cumsum(E &&e, std::ptrdiff_t axis)¶ Cumulative sum.
Returns the accumulated sum for the elements over given axis (or flattened).
- Parameters
e – an xexpression
axis – the axes along which the cumulative sum is computed (optional)
- Template Parameters
T – the value type used for internal computation. The default is
E::value_type
.T
is also used for determining the value type of the result, which is the type ofT() + E::value_type()
. You can passbig_promote_value_type_t<E>
to avoid overflow in computation.- Returns
an xarray<T>
-
template<class T = void, class E>
inline auto xt::cumprod(E &&e, std::ptrdiff_t axis)¶ Cumulative product.
Returns the accumulated product for the elements over given axis (or flattened).
- Parameters
e – an xexpression
axis – the axes along which the cumulative product is computed (optional)
- Template Parameters
T – the value type used for internal computation. The default is
E::value_type
.T
is also used for determining the value type of the result, which is the type ofT() * E::value_type()
. You can passbig_promote_value_type_t<E>
to avoid overflow in computation.- Returns
an xarray<T>