29 #include <initializer_list> 33 template <
unsigned int D>
37 std::array<unsigned int, D> m_sizes{};
38 std::array<unsigned int, D> m_totalsizes{};
44 unsigned int m_pos = 0;
45 unsigned int m_end = 0;
48 NDRangeIterator(
const NDRange &p,
unsigned int s,
unsigned int e)
49 : m_parent(p), m_pos(s), m_end(e)
55 return (m_pos >= m_end);
58 unsigned int dim(
unsigned int d)
const 60 unsigned int r = m_pos;
64 r %= m_parent.m_totalsizes[d];
69 r /= m_parent.m_totalsizes[d - 1];
84 m_pos += m_parent.m_sizes[0] - dim(0);
89 unsigned int dim0_max()
const 91 unsigned int offset = std::min(m_end - m_pos, m_parent.m_sizes[0] - dim(0));
101 for(
unsigned int i = 0; i < D; i++)
118 template <
typename... T>
131 NDRangeIterator
iterator(
unsigned int start,
unsigned int end)
const 133 return NDRangeIterator(*
this, start, end);
138 return m_totalsizes[D - 1];
150 template <
unsigned int N>
153 using int_t =
unsigned int;
156 std::array<int_t, N> m_positions{};
161 NDCoordinate(
const std::initializer_list<std::pair<int_t, int_t>> &list)
163 std::array<int_t, N> sizes{};
168 m_positions[i] = p.first;
169 sizes[i++] = p.second;
180 return m_positions[d];
__global uchar * offset(const Image *img, int x, int y)
Get the pointer position of a Image.
NDRangeIterator iterator(unsigned int start, unsigned int end) const
void set_position(int_t d, int_t v)
NDRange< ndrange_max > ndrange_t
int_t get_position(int_t d) const
NDRange(const NDRange &rhs)=default
NDRange & operator=(const NDRange &rhs)=default
void end(TokenStream &in, bool &valid)
NDRange(const std::array< unsigned int, D > &n)
NDCoordinate builds upon a range, but specifies a starting position in addition to a size which it in...
unsigned int total_size() const
NDCoordinate(const std::initializer_list< std::pair< int_t, int_t >> &list)
unsigned int get_size(unsigned int v) const
int_t get_position_end(int_t d) const