9#include "ddc/detail/macros.hpp"
10#include "ddc/discrete_domain.hpp"
11#include "ddc/discrete_element.hpp"
18
19
20
21
22
23
24
25
29 class BinaryReductionOp,
30 class UnaryTransformOp,
32T transform_reduce_serial(
34 [[maybe_unused]] T
const neutral,
35 BinaryReductionOp
const& reduce,
36 UnaryTransformOp
const& transform,
37 DCoords
const&... dcoords)
noexcept
39 DDC_IF_NVCC_THEN_PUSH_AND_SUPPRESS(implicit_return_from_non_void_function)
40 if constexpr (
sizeof...(DCoords) ==
sizeof...(DDims)) {
41 return transform(DiscreteElement<DDims...>(dcoords...));
43 using CurrentDDim = type_seq_element_t<
sizeof...(DCoords), detail::TypeSeq<DDims...>>;
45 for (DiscreteElement<CurrentDDim>
const ii : select<CurrentDDim>(domain)) {
48 transform_reduce_serial(domain, neutral, reduce, transform, dcoords..., ii));
58
59
60
61
62
63
64
65template <
class... DDims,
class T,
class BinaryReductionOp,
class UnaryTransformOp>
69 BinaryReductionOp&& reduce,
70 UnaryTransformOp&& transform)
noexcept
72 return detail::transform_reduce_serial(
75 std::forward<BinaryReductionOp>(reduce),
76 std::forward<UnaryTransformOp>(transform));
friend class DiscreteDomain
The top-level namespace of DDC.
T transform_reduce(DiscreteDomain< DDims... > const &domain, T neutral, BinaryReductionOp &&reduce, UnaryTransformOp &&transform) noexcept
A reduction over a nD domain in serial.