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
26template <
class Support,
class T,
class BinaryReductionOp,
class UnaryTransformOp,
class... DCoords>
27T transform_reduce_serial(
28 Support
const& domain,
29 [[maybe_unused]] T
const neutral,
30 BinaryReductionOp
const& reduce,
31 UnaryTransformOp
const& transform,
32 DCoords
const&... dcoords)
noexcept
34 DDC_IF_NVCC_THEN_PUSH_AND_SUPPRESS(implicit_return_from_non_void_function)
35 if constexpr (
sizeof...(DCoords) == Support::rank()) {
36 return transform(
typename Support::discrete_element_type(dcoords...));
38 using CurrentDDim = type_seq_element_t<
sizeof...(DCoords), to_type_seq_t<Support>>;
40 for (DiscreteElement<CurrentDDim>
const ii :
DiscreteDomain<CurrentDDim>(domain)) {
43 transform_reduce_serial(domain, neutral, reduce, transform, dcoords..., ii));
53
54
55
56
57
58
59
60template <
class Support,
class T,
class BinaryReductionOp,
class UnaryTransformOp>
62 Support
const& domain,
64 BinaryReductionOp&& reduce,
65 UnaryTransformOp&& transform)
noexcept
67 return detail::transform_reduce_serial(
70 std::forward<BinaryReductionOp>(reduce),
71 std::forward<UnaryTransformOp>(transform));
friend class DiscreteDomain
The top-level namespace of DDC.
T transform_reduce(Support const &domain, T neutral, BinaryReductionOp &&reduce, UnaryTransformOp &&transform) noexcept
A reduction over a nD domain in serial.