# Reduction Operators

`reduce()` | generic batch reduction
`reduce_add()` | sum of each batch element
`reduce_max()` | max of the batch elements
`reduce_min()` | min of the batch elements
`reduce_mul()` | product of the batch elements
`haddp()` | horizontal sum across batches

Also see the batch_bool Reducers.

template<class T, class A>
inline batch<T, A> haddp(batch<T, A> const *row) noexcept

  Parallel horizontal addition: adds the scalars of each batch in the array pointed by `row` and store them in a returned batch.

  Parameters:

    row – an array of `N` batches

  Returns:

    the result of the reduction.

template<class T, class A, class F>
inline T reduce(F &&f, batch<T, A> const &x) noexcept

  Generic reducer using only batch operations.

  Parameters:

    - f – reducing function, accepting `batch ()(batch, batch)`

    - x – batch involved in the reduction

  Returns:

    the result of the reduction, as a scalar.

template<class T, class A>
inline T reduce_add(batch<T, A> const &x) noexcept

  Adds all the scalars of the batch `x`.

  Parameters:

    x – batch involved in the reduction

  Returns:

    the result of the reduction.

template<class T, class A>
inline T reduce_max(batch<T, A> const &x) noexcept

  Max of all the scalars of the batch `x`.

  Parameters:

    x – batch involved in the reduction

  Returns:

    the result of the reduction.

template<class T, class A>
inline T reduce_min(batch<T, A> const &x) noexcept

  Min of all the scalars of the batch `x`.

  Parameters:

    x – batch involved in the reduction

  Returns:

    the result of the reduction.

template<class T, class A>
inline T reduce_mul(batch<T, A> const &x) noexcept

  Multiplies of all the scalars of the batch `x`.

  Parameters:

    x – batch involved in the reduction

  Returns:

    the result of the reduction.