26 #include <boost/mpl/arithmetic.hpp>
27 #include <boost/mpl/times.hpp>
28 #include <boost/mpl/vector.hpp>
29 #include <boost/mpl/size_t.hpp>
30 #include <boost/lexical_cast.hpp>
32 #include "../utilities/container_utils.hpp"
57 typedef typename array_type::map_type
map_type;
81 template<
typename STYPE>
88 static array_type
create(
const STYPE &s,
94 std::fill(storage.begin(),storage.end(),def_val);
96 return array_type(std::move(map),std::move(storage));
120 template<
typename STYPE,
132 static array_type
create(
const STYPE &s,
const DTYPE &data)
135 if(map.max_elements() != data.size())
137 "Total number of elements from map ("
138 +boost::lexical_cast<string>(map.max_elements())+
139 ") does not match data size ("
140 +boost::lexical_cast<string>(data.size())+
")!");
143 std::copy(data.begin(),data.end(),storage.begin());
144 return array_type(std::move(map),std::move(storage));
174 static array_type
create(std::initializer_list<IT> shape,
175 std::initializer_list<DT> data)
178 if(map.max_elements() != data.size())
180 "Total number of elements from map ("
181 +boost::lexical_cast<string>(map.max_elements())+
182 "does not match data size ("
183 +boost::lexical_cast<string>(data.size())+
")!");
186 std::copy(data.begin(),data.end(),storage.begin());
187 return array_type(std::move(map),std::move(storage));
static container_type create(size_t n, value_type default_value=value_type())
create container of given size
Definition: container_utils.hpp:85
ATYPE array_type
shortcut for the array type
Definition: array_factory.hpp:53
Size mismatch error.
Definition: exceptions.hpp:399
#define EXCEPTION_RECORD
macro creating an instance of ExceptionRecord
Definition: exceptions.hpp:48
static array_type create(std::initializer_list< IT > shape, std::initializer_list< DT > data)
construct from initializer list
Definition: array_factory.hpp:174
array_type::map_type map_type
map type of the array
Definition: array_factory.hpp:57
array_type::value_type value_type
value type of the array
Definition: array_factory.hpp:55
static MAPT create(const CTYPE &c)
create map from container
Definition: index_maps.hpp:129
Definition: add_op.hpp:29
static array_type create(const STYPE &s, value_type def_val=value_type())
create array from shape
Definition: array_factory.hpp:88
array factory
Definition: array_factory.hpp:50
array_type::storage_type storage_type
storage type of the array
Definition: array_factory.hpp:59
static array_type create(const STYPE &s, const DTYPE &data)
create array from shape and data
Definition: array_factory.hpp:132