|
template<typename Result, typename Fetch, typename Reduction, typename Index, typename Output> |
void constexpr | reduce (Result identity, Fetch fetch, Reduction reduction, Index size, int n, Output result) |
|
template<typename Result, typename Fetch, typename Reduction, typename Index, typename Output> |
static constexpr void | reduce (Result identity, Fetch fetch, Reduction reduction, Index size, int n, Output result) |
| Performs reduction on a 2D dataset into a 1D output.
|
◆ reduce()
template<typename Result, typename Fetch, typename Reduction, typename Index, typename Output>
Performs reduction on a 2D dataset into a 1D output.
This function applies a reduction operation across all elements along the first dimension of a 2D dataset, combining values for each position in the second dimension. The reduction starts with an identity element and aggregates all values along the first dimension.
- Template Parameters
-
Result | Type representing the identity element and result values. |
Fetch | Callable type used to fetch values from the 2D dataset. |
Reduction | Callable type representing the reduction operation. |
Index | Integral type used for the first dimension's size. |
Output | Callable type used to store the resulting values. |
- Parameters
-
identity | [in] The identity element for the reduction operation. This value does not affect the result of the reduction. |
fetch | [in] Callable object such that fetch(i, j) yields a value from the 2D dataset given by i ranging from 0 to size-1 and j from 0 to n-1. |
reduction | [in] Callable object representing the reduction operation. Examples include instances of std::plus, std::logical_and, std::logical_or, etc. |
size | [in] The size of the first dimension (reduction axis) of the 2D dataset. |
n | [in] Number of elements in the second dimension of the 2D dataset. |
result | [out] Callable object returning a modifiable reference to the output array. Used as result(j) = value for j from 0 to n-1. For example, an ArrayView of size n. |
The documentation for this struct was generated from the following files:
- src/TNL/Algorithms/Reduction2D.h
- src/TNL/Algorithms/Reduction2D.hpp