|
template<typename Result, typename Fetch, typename Reduction, typename Index, typename Output> |
static void | reduce (Result identity, Fetch fetch, Reduction reduction, Index size, int m, int n, Output hostResult) |
| Performs reduction on a 3D dataset into a 2D output.
|
◆ reduce()
template<typename Result, typename Fetch, typename Reduction, typename Index, typename Output>
Performs reduction on a 3D dataset into a 2D output.
This function applies a reduction operation across all elements along the first dimension of a 3D dataset, combining values for each position in the second and third dimensions. 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 3D 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, k) yields a value from the 3D dataset given by i ranging from 0 to size-1, j from 0 to m-1, and k 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 3D dataset. |
m | [in] Number of elements in the second dimension of the 3D dataset. |
n | [in] Number of elements in the third dimension of the 3D dataset. |
hostResult | [out] Callable object returning a modifiable reference to the output array. Used as result(j, k) = value for j=0, ..., m-1 and k=0, ..., n-1. For example, a 2D NDArrayView of size m × n. Note that the output array must be allocated on Host. |
The documentation for this struct was generated from the following files:
- src/TNL/Algorithms/Reduction3D.h
- src/TNL/Algorithms/Reduction3D.hpp