11 #ifndef CUBBYFLOW_ITERATION_UTILS_HPP 12 #define CUBBYFLOW_ITERATION_UTILS_HPP 19 template <
typename IndexType,
size_t N,
typename Func>
21 const Vector<IndexType, N>& end,
const Func& func);
23 template <
typename IndexType,
typename Func>
25 const Vector<IndexType, 1>& end,
const Func& func);
27 template <
typename IndexType,
typename Func>
28 void ForEachIndex(IndexType begin, IndexType end,
const Func& func);
30 template <
typename IndexType,
size_t N,
typename Func>
31 void ForEachIndex(
const Vector<IndexType, N>& size,
const Func& func);
33 template <
typename IndexType,
typename Func>
34 void ForEachIndex(
const Vector<IndexType, 1>& size,
const Func& func);
36 template <
typename IndexType,
typename Func>
39 template <
typename IndexType,
size_t N,
typename Func>
41 const Vector<IndexType, N>& end,
const Func& func,
44 template <
typename IndexType,
typename Func>
46 const Vector<IndexType, 1>& end,
const Func& func,
49 template <
typename IndexType,
typename Func>
53 template <
typename IndexType,
size_t N,
typename Func>
57 template <
typename IndexType,
typename Func>
61 template <
typename IndexType,
typename Func>
66 template <
typename ReturnType>
67 std::function<ReturnType(size_t)>
Unroll1(
68 const std::function<ReturnType(
const Vector1UZ&)>& func)
70 return [func](
size_t i) {
return func(
Vector1UZ{ i }); };
74 template <
typename ReturnType>
75 std::function<ReturnType(size_t, size_t)>
Unroll2(
76 const std::function<ReturnType(
const Vector2UZ&)>& func)
78 return [func](
size_t i,
size_t j) {
return func(
Vector2UZ{ i, j }); };
82 template <
typename ReturnType>
83 std::function<ReturnType(size_t, size_t, size_t)>
Unroll3(
84 const std::function<ReturnType(
const Vector3UZ&)>& func)
86 return [func](
size_t i,
size_t j,
size_t k) {
91 template <
typename ReturnType,
size_t N>
97 template <
typename ReturnType>
100 static std::function<ReturnType(size_t)>
Unroll(
101 const std::function<ReturnType(
const Vector1UZ&)>& func)
103 return [func](
size_t i) {
return func(
Vector1UZ{ i }); };
110 static std::function<void(size_t)>
Unroll(
111 const std::function<
void(
const Vector1UZ&)>& func)
113 return [func](
size_t i) { func(
Vector1UZ{ i }); };
117 template <
typename ReturnType>
120 static std::function<ReturnType(size_t, size_t)>
Unroll(
121 const std::function<ReturnType(
const Vector2UZ&)>& func)
123 return [func](
size_t i,
size_t j) {
return func(
Vector2UZ{ i, j }); };
130 static std::function<void(size_t, size_t)>
Unroll(
131 const std::function<
void(
const Vector2UZ&)>& func)
133 return [func](
size_t i,
size_t j) { func(
Vector2UZ{ i, j }); };
137 template <
typename ReturnType>
140 static std::function<ReturnType(size_t, size_t, size_t)>
Unroll(
141 const std::function<ReturnType(
const Vector3UZ&)>& func)
143 return [func](
size_t i,
size_t j,
size_t k) {
152 static std::function<void(size_t, size_t, size_t)>
Unroll(
153 const std::function<
void(
const Vector3UZ&)>& func)
155 return [func](
size_t i,
size_t j,
size_t k) {
static std::function< ReturnType(size_t, size_t, size_t)> Unroll(const std::function< ReturnType(const Vector3UZ &)> &func)
Definition: IterationUtils.hpp:140
static std::function< ReturnType(size_t, size_t)> Unroll(const std::function< ReturnType(const Vector2UZ &)> &func)
Definition: IterationUtils.hpp:120
static std::function< void(size_t, size_t, size_t)> Unroll(const std::function< void(const Vector3UZ &)> &func)
Definition: IterationUtils.hpp:152
std::function< ReturnType(size_t, size_t, size_t)> Unroll3(const std::function< ReturnType(const Vector3UZ &)> &func)
Unrolls vector-based DataPositionFunc indexing to size_t-based function.
Definition: IterationUtils.hpp:83
Definition: IterationUtils.hpp:92
Definition: Matrix.hpp:27
Definition: pybind11Utils.hpp:20
std::function< ReturnType(size_t)> Unroll1(const std::function< ReturnType(const Vector1UZ &)> &func)
Unrolls vector-based indexing to size_t-based function.
Definition: IterationUtils.hpp:67
void ParallelForEachIndex(const Vector< IndexType, N > &begin, const Vector< IndexType, N > &end, const Func &func, ExecutionPolicy policy)
Definition: IterationUtils-Impl.hpp:98
std::function< ReturnType(size_t, size_t)> Unroll2(const std::function< ReturnType(const Vector2UZ &)> &func)
Unrolls vector-based indexing to size_t-based function.
Definition: IterationUtils.hpp:75
static std::function< ReturnType(size_t)> Unroll(const std::function< ReturnType(const Vector1UZ &)> &func)
Definition: IterationUtils.hpp:100
ExecutionPolicy
Execution policy tag.
Definition: Parallel.hpp:17
static std::function< void(size_t)> Unroll(const std::function< void(const Vector1UZ &)> &func)
Definition: IterationUtils.hpp:110
void ForEachIndex(const Vector< IndexType, N > &begin, const Vector< IndexType, N > &end, const Func &func)
Definition: IterationUtils-Impl.hpp:51
static std::function< void(size_t, size_t)> Unroll(const std::function< void(const Vector2UZ &)> &func)
Definition: IterationUtils.hpp:130