34 #include "../../error/exceptions.hpp"
35 #include "../../error/exception_utils.hpp"
62 template<
typename IITERT,
64 static size_t offset(IITERT &&index_start,
69 size_t offset = *index_start++,stride=1;
73 while(index_start!=index_stop)
76 stride *= *shape_start++;
78 offset += stride*(*index_start++);
109 static size_t offset(SELITER &&sel_shape_start,
110 SELITER &&sel_shape_end,
111 SELITER &&sel_offset,
112 SELITER &&sel_stride,
116 size_t index = *sel_offset++;
118 if(*sel_shape_start++ != 1) index += (*sel_index++)*(*sel_stride);
126 while(sel_shape_start!=sel_shape_end)
129 index = *sel_offset++;
130 if(*sel_shape_start++ != 1)
131 index += (*sel_index++)*(*sel_stride);
136 dim_stride *= *shape_start++;
138 offset += dim_stride*
index;
163 static void index(SITERT &&shape_start,
165 IITERT &&index_start,
169 size_t stride = std::accumulate(++shape_start,shape_stop,1,
170 std::multiplies<size_t>());
172 *(index_start++) = (offset-t)/stride;
174 while(shape_start != shape_stop)
178 stride /= *shape_start++;
180 *(index_start++) = (offset-t)/stride;
208 return offset(index.rbegin(),index.rend(),shape.rbegin());
232 static size_t offset(
const SELTYPE &sel,
const CSHAPE &shape,
235 return offset(sel.full_shape().rbegin(),
236 sel.full_shape().rend(),
237 sel.offset().rbegin(),
238 sel.stride().rbegin(),
265 index(shape.begin(),shape.end(),idx.begin(),
offset);
291 auto oshape = sel.template full_shape<CTYPE>();
293 auto oiter = oshape.begin();
294 auto siter = shape.begin();
296 for(;siter != shape.end(); ++oiter,++siter)
298 if((*oiter!=1)&&(*oiter!=*siter))
return false;
static size_t offset(IITERT &&index_start, IITERT &&index_stop, SITERT &&shape_start)
compute the offset
Definition: c_index_map_imp.hpp:64
static void index(SITERT &&shape_start, SITERT &&shape_stop, IITERT &&index_start, size_t offset)
compute the index
Definition: c_index_map_imp.hpp:163
Definition: add_op.hpp:29
static bool is_contiguous(const CTYPE &shape, const SELTYPE &sel)
identify a contiguous selection
Definition: c_index_map_imp.hpp:289
C index map implementation.
Definition: c_index_map_imp.hpp:47
static size_t offset(const CSHAPE &shape, const CINDEX &index)
compute the offset
Definition: c_index_map_imp.hpp:205
static size_t offset(const SELTYPE &sel, const CSHAPE &shape, const SINDEX &index)
compute offset for selection
Definition: c_index_map_imp.hpp:232
static void index(const CSHAPE &shape, CINDEX &idx, size_t offset)
compute index
Definition: c_index_map_imp.hpp:262
static size_t offset(SELITER &&sel_shape_start, SELITER &&sel_shape_end, SELITER &&sel_offset, SELITER &&sel_stride, SITER &&shape_start, IITER &&sel_index)
compute selection offset
Definition: c_index_map_imp.hpp:109