27 #include <boost/lexical_cast.hpp>
28 #include "index_map.hpp"
29 #include "static_index_map.hpp"
30 #include "c_index_map_imp.hpp"
31 #include "../../utilities/container_utils.hpp"
50 template<
size_t... DIMS>
51 using static_cindex_map = static_index_map<c_index_map_imp,DIMS...>;
61 typedef index_map<std::vector<size_t>,c_index_map_imp> dynamic_cindex_map;
80 template<
size_t NDIMS>
81 using fixed_dim_cindex_map = index_map<std::array<size_t,NDIMS>,c_index_map_imp>;
129 template<
typename CTYPE>
static MAPT
create(
const CTYPE &c)
131 storage_type storage;
140 std::stringstream ss;
141 ss<<
"The map supports only a fixed number of dimensions ("
142 <<storage.size()<<
")! However, the container you are "
143 <<
"passing has ("<<c.size()<<
") elements!"<<std::endl;
146 std::copy(c.begin(),c.end(),storage.begin());
147 return MAPT(std::move(storage));
159 template<
typename IT>
160 static MAPT
create(std::initializer_list<IT> shape)
162 storage_type storage;
171 "Rank of user shape ("
172 +boost::lexical_cast<string>(shape.size())+
173 ") does not match the map rank ("
174 +boost::lexical_cast<string>(
map_type().rank())+
")!");
176 std::copy(shape.begin(),shape.end(),storage.begin());
177 return MAPT(std::move(storage));
193 template<
typename POLTYPE,
size_t...DIMS>
212 if(c.size() != map.
rank())
214 "rank does not match");
216 if(!std::equal(map.
begin(),map.
end(),c.begin()))
218 "Elements counts do not match!");
233 template<
typename IT>
237 if(shape.size() != map.
rank())
239 "rank does not match");
241 if(!std::equal(map.
begin(),map.
end(),shape.begin()))
243 "Elements counts do not match!");
static container_type create(size_t n, value_type default_value=value_type())
create container of given size
Definition: container_utils.hpp:85
Size mismatch error.
Definition: exceptions.hpp:399
#define EXCEPTION_RECORD
macro creating an instance of ExceptionRecord
Definition: exceptions.hpp:48
Shape mismatch error.
Definition: exceptions.hpp:360
static map_type create(const CTYPE &c)
creat map from container
Definition: index_maps.hpp:209
static map_type create(std::initializer_list< IT > shape)
create index map from initializer list
Definition: index_maps.hpp:234
utility class for index maps
Definition: index_maps.hpp:100
static MAPT create(const CTYPE &c)
create map from container
Definition: index_maps.hpp:129
map_type::storage_type storage_type
storage type for MAPT
Definition: index_maps.hpp:105
Definition: add_op.hpp:29
the static general index map template
Definition: static_index_map.hpp:63
MAPT map_type
index map type
Definition: index_maps.hpp:103
static MAPT create(std::initializer_list< IT > shape)
create map from initializer list
Definition: index_maps.hpp:160
static_index_map< POLTYPE, DIMS...> map_type
index map type
Definition: index_maps.hpp:197
const_iterator begin() const
get a const iterator to the first element
Definition: static_index_map.hpp:211
constexpr size_t rank() const
get number of dimensions
Definition: static_index_map.hpp:105
const_iterator end() const
get a const iterator to the last+1 element
Definition: static_index_map.hpp:217