29 #include "../../utilities/container_utils.hpp"
34 class array_selection;
91 typedef typename storage_type::iterator
iterator;
122 std::fill(m._shape.begin(),m._shape.end(),0);
141 explicit index_map(
const storage_type &s):_shape(s) {}
160 explicit index_map(storage_type &&s):_shape(
std::move(s)) {}
173 if(
this == &m)
return *
this;
188 if(
this == &m)
return *
this;
189 _shape = std::move(m._shape);
190 std::fill(m._shape.begin(),m._shape.end(),0);
207 if(_shape.size() == 0)
return 0;
209 return std::accumulate(_shape.begin(),_shape.end(),1,
210 std::multiplies<size_t>());
222 size_t rank()
const {
return _shape.size(); }
255 typename std::remove_reference<CTYPE>::type
261 return implementation_type::template
offset(_shape,index);
280 template<
typename CTYPE,
288 typename std::remove_reference<CTYPE>::type
294 return implementation_type::template
offset(s,_shape,index);
310 template<
typename CTYPE> CTYPE
index(
size_t offset)
const
317 implementation_type::template
index(_shape,index,offset);
326 iterator
begin() {
return _shape.begin(); }
332 iterator
end() {
return _shape.end(); }
338 const_iterator
begin()
const {
return _shape.begin(); }
344 const_iterator
end()
const {
return _shape.end(); }
static container_type create(size_t n, value_type default_value=value_type())
create container of given size
Definition: container_utils.hpp:85
storage_type::const_iterator const_iterator
constant iterator over the map
Definition: index_map.hpp:93
index_map(map_type &&m)
move constructor
Definition: index_map.hpp:120
size_t rank() const
get number of dimensions
Definition: index_map.hpp:222
dynamic general index map template
Definition: index_map.hpp:80
storage_type::iterator iterator
read write iterator
Definition: index_map.hpp:91
selection from a multidimensional array
Definition: array_selection.hpp:72
map_type & operator=(const map_type &m)
copy assignment operator
Definition: index_map.hpp:171
index_map< storage_type, implementation_type > map_type
map type
Definition: index_map.hpp:95
storage_type _shape
storage for shape information
Definition: index_map.hpp:98
Definition: add_op.hpp:29
MAP_IMP implementation_type
policy type
Definition: index_map.hpp:89
invoke< std::enable_if< C::value >> enable_if
shortcut for std::enable_if
Definition: sfinae_macros.hpp:108
CTYPE index(size_t offset) const
compute index
Definition: index_map.hpp:314
map_type & operator=(map_type &&m)
move assignment operator
Definition: index_map.hpp:186
iterator end()
return iterator to last+1 element
Definition: index_map.hpp:332
size_t size() const
get number of dimensions
Definition: index_map.hpp:233
SHAPE_STORE storage_type
storage type
Definition: index_map.hpp:85
size_t max_elements() const
get number of elements
Definition: index_map.hpp:205
storage_type::value_type value_type
index type
Definition: index_map.hpp:87
index_map(const map_type &m)
copy constructor
Definition: index_map.hpp:112
index_map()
default constructor
Definition: index_map.hpp:104
type erasure for POD data
Definition: value.hpp:46
const_iterator end() const
return const iterator to last+1 element
Definition: index_map.hpp:344
const_iterator begin() const
return const iterator to first element
Definition: index_map.hpp:338
size_t offset(const CTYPE &index) const
compute the offset
Definition: index_map.hpp:259
iterator begin()
return iterator to first element
Definition: index_map.hpp:326
size_t offset(const array_selection &s, const CTYPE &index)
compute offset with selection
Definition: index_map.hpp:292