9#include "detail/macros.hpp"
11#include "discrete_domain.hpp"
12#include "discrete_element.hpp"
19
20
21
22
23
24
25
26
27template <
class Support,
class T,
class BinaryReductionOp,
class UnaryTransformOp,
class... DCoords>
28T transform_reduce_serial(
29 Support
const& domain,
30 [[maybe_unused]] T
const neutral,
31 BinaryReductionOp
const& reduce,
32 UnaryTransformOp
const& transform,
33 DCoords
const&... dcoords)
noexcept
35 DDC_IF_NVCC_THEN_PUSH_AND_SUPPRESS(implicit_return_from_non_void_function)
36 if constexpr (
sizeof...(DCoords) == Support::rank()) {
37 return transform(
typename Support::discrete_element_type(dcoords...));
39 using CurrentDDim = type_seq_element_t<
sizeof...(DCoords), to_type_seq_t<Support>>;
41 for (DiscreteElement<CurrentDDim>
const ii :
DiscreteDomain<CurrentDDim>(domain)) {
44 transform_reduce_serial(domain, neutral, reduce, transform, dcoords..., ii));
54
55
56
57
58
59
60
61template <
class Support,
class T,
class BinaryReductionOp,
class UnaryTransformOp>
63 Support
const& domain,
65 BinaryReductionOp&& reduce,
66 UnaryTransformOp&& transform)
noexcept
68 return detail::transform_reduce_serial(
71 std::forward<BinaryReductionOp>(reduce),
72 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.