Performs a reduce over a parameter pack, writing over each element with the current value of the reduce.
template <typename T, typename BinaryOp, typename... Elements>
void partial_reduce(T init, BinaryOp&& reduce_fn, Elements&&... elements);
init
is the initial value used in the reduction.
reduce_fn
should take two parameters and return a type convertible to T
. The
first parameter is the value of the reduction so far(of type T
), the second
parameter will be an element from the passed in parameter pack.
Each type in the parameter pack needs to be assignable from a T
.
✔️ hal::reverse::partial_reduce(...)
✔️ Modifying Algorithm
Convinience function where reduce_fn
of partial_reduce(...)
is
std::plus<>
, T
is the type of the first element, and init
is 0
.
template <typename... Elements>
void partial_sum(Elements&&... elements);
✔️ hal::reverse::partial_sum(...)
✔️ Modifying Algorithm
Convinience function where reduce_fn
of partial_reduce(...)
is
std::minus<>
, T
is the type of the first element, and init
is 0
.
template <typename... Elements>
void partial_difference(Elements&&... elements);
✔️ hal::reverse::partial_difference(...)
✔️ Modifying Algorithm
Convinience function where reduce_fn
of partial_reduce(...)
is
std::multiplies<>
, T
is the type of the first element, and init
is 1
.
template <typename... Elements>
void partial_product(Elements&&... elements);
✔️ hal::reverse::partial_product(...)
✔️ Modifying Algorithm
Convinience function where reduce_fn
of partial_reduce(...)
is
std::divides<>
, T
is the type of the first element, and init
is 1
.
template <typename... Elements>
void partial_quotient(Elements&&... elements)
✔️ hal::reverse::partial_quotient(...)
✔️ Modifying Algorithm