46 #ifndef Shards_ArrayVector_hpp
47 #define Shards_ArrayVector_hpp
51 #include <Shards_Array.hpp>
62 class Tag1 = void ,
class Tag2 = void ,
63 class Tag3 = void ,
class Tag4 = void ,
64 class Tag5 = void ,
class Tag6 = void ,
65 class Tag7 = void ,
class Tag8 =
void >
70 template<
typename Scalar , ArrayOrder Order >
71 class ArrayVector<Scalar,Order,void,void,void,void, void,void,void,void>
72 :
public Array<Scalar,Order,void,void,void,void, void,void,void,void>
75 std::vector<Scalar> m_storage ;
78 Array<Scalar,Order,void,void,void,void, void,void,void,void>
81 ArrayVector(
const ArrayVector & );
82 ArrayVector & operator = (
const ArrayVector & );
84 Scalar * get_ptr() {
return m_storage.empty() ? NULL : & m_storage[0] ; }
88 typedef array_traits::int_t size_type ;
91 : BaseType() , m_storage() {}
95 template<
class Tag1 ,
class Tag2 ,
class Tag3 ,
class Tag4 ,
96 class Tag5 ,
class Tag6 ,
class Tag7 ,
class Tag8 >
97 void resize(
const size_type n1 ,
const size_type n2 ,
98 const size_type n3 ,
const size_type n4 ,
99 const size_type n5 ,
const size_type n6 ,
100 const size_type n7 ,
const size_type n8 )
102 m_storage.resize( n1 * n2 * n3 * n4 * n5 * n6 * n7 * n8 );
103 BaseType::template assign<Tag1,Tag2,Tag3,Tag4,Tag5,Tag6,Tag7,Tag8>
104 ( get_ptr() ,n1,n2,n3,n4,n5,n6,n7,n8);
107 template<
class Tag1 ,
class Tag2 ,
class Tag3 ,
class Tag4 ,
108 class Tag5 ,
class Tag6 ,
class Tag7 >
109 void resize(
const size_type n1 ,
const size_type n2 ,
110 const size_type n3 ,
const size_type n4 ,
111 const size_type n5 ,
const size_type n6 ,
114 m_storage.resize( n1 * n2 * n3 * n4 * n5 * n6 * n7 );
115 BaseType::template assign<Tag1,Tag2,Tag3,Tag4,Tag5,Tag6,Tag7>
116 ( get_ptr() ,n1,n2,n3,n4,n5,n6,n7);
119 template<
class Tag1 ,
class Tag2 ,
class Tag3 ,
class Tag4 ,
120 class Tag5 ,
class Tag6 >
121 void resize(
const size_type n1 ,
const size_type n2 ,
122 const size_type n3 ,
const size_type n4 ,
123 const size_type n5 ,
const size_type n6 )
125 m_storage.resize( n1 * n2 * n3 * n4 * n5 * n6 );
126 BaseType::template assign<Tag1,Tag2,Tag3,Tag4,Tag5,Tag6>
127 ( get_ptr() ,n1,n2,n3,n4,n5,n6);
130 template<
class Tag1 ,
class Tag2 ,
class Tag3 ,
class Tag4 ,
132 void resize(
const size_type n1 ,
const size_type n2 ,
133 const size_type n3 ,
const size_type n4 ,
136 m_storage.resize( n1 * n2 * n3 * n4 * n5 );
137 BaseType::template assign<Tag1,Tag2,Tag3,Tag4,Tag5>
138 ( get_ptr(),n1,n2,n3,n4,n5);
141 template<
class Tag1 ,
class Tag2 ,
class Tag3 ,
class Tag4 >
142 void resize(
const size_type n1 ,
const size_type n2 ,
143 const size_type n3 ,
const size_type n4 )
145 m_storage.resize( n1 * n2 * n3 * n4 );
146 BaseType::template assign<Tag1,Tag2,Tag3,Tag4>
147 ( get_ptr(),n1,n2,n3,n4);
150 template<
class Tag1 ,
class Tag2 ,
class Tag3 >
151 void resize(
const size_type n1 ,
const size_type n2 ,
154 m_storage.resize( n1 * n2 * n3 );
155 BaseType::template assign<Tag1,Tag2,Tag3>
156 ( get_ptr(),n1,n2,n3);
159 template<
class Tag1 ,
class Tag2 >
160 void resize(
const size_type n1 ,
const size_type n2 )
162 m_storage.resize( n1 * n2 );
163 BaseType::template assign<Tag1,Tag2>( get_ptr(),n1,n2);
166 template<
class Tag1 >
167 void resize(
const size_type n1 )
169 m_storage.resize( n1 );
170 BaseType::template assign<Tag1>( get_ptr(),n1);
176 template<
typename Scalar ,
ArrayOrder Order ,
177 class Tag1 ,
class Tag2 ,
class Tag3 ,
class Tag4 ,
178 class Tag5 ,
class Tag6 ,
class Tag7 ,
class Tag8 >
180 :
public Array<Scalar,Order,Tag1,Tag2,Tag3,Tag4,Tag5,Tag6,Tag7,Tag8>
183 std::vector<Scalar> m_storage ;
186 array_traits::Helper<Scalar,Order,Tag1,Tag2,Tag3,Tag4,Tag5,Tag6,Tag7,Tag8>
190 Array<Scalar,Order,Tag1,Tag2,Tag3,Tag4,Tag5,Tag6,Tag7,Tag8>
193 ArrayVector(
const ArrayVector & );
194 ArrayVector & operator = (
const ArrayVector & );
196 Scalar * get_ptr() {
return m_storage.empty() ? NULL : & m_storage[0] ; }
200 typedef array_traits::int_t size_type ;
203 : BaseType() , m_storage() {}
207 void resize(
const size_type *
const dims )
209 help_type::assign( BaseType::m_stride , dims );
211 m_storage.resize( n );
212 BaseType::m_ptr = get_ptr();
215 void resize(
const size_type n1 ,
const size_type n2 ,
216 const size_type n3 ,
const size_type n4 ,
217 const size_type n5 ,
const size_type n6 ,
218 const size_type n7 ,
const size_type n8 )
220 array_traits::CheckRank<8,BaseType::Rank>::ok();
221 m_storage.resize( n1 * n2 * n3 * n4 * n5 * n6 * n7 * n8 );
225 void resize(
const size_type n1 ,
const size_type n2 ,
226 const size_type n3 ,
const size_type n4 ,
227 const size_type n5 ,
const size_type n6 ,
230 array_traits::CheckRank<7,BaseType::Rank>::ok();
231 m_storage.resize( n1 * n2 * n3 * n4 * n5 * n6 * n7 );
235 void resize(
const size_type n1 ,
const size_type n2 ,
236 const size_type n3 ,
const size_type n4 ,
237 const size_type n5 ,
const size_type n6 )
239 array_traits::CheckRank<6,BaseType::Rank>::ok();
240 m_storage.resize( n1 * n2 * n3 * n4 * n5 * n6 );
244 void resize(
const size_type n1 ,
const size_type n2 ,
245 const size_type n3 ,
const size_type n4 ,
248 array_traits::CheckRank<5,BaseType::Rank>::ok();
249 m_storage.resize( n1 * n2 * n3 * n4 * n5 );
253 void resize(
const size_type n1 ,
const size_type n2 ,
254 const size_type n3 ,
const size_type n4 )
256 array_traits::CheckRank<4,BaseType::Rank>::ok();
257 m_storage.resize( n1 * n2 * n3 * n4 );
261 void resize(
const size_type n1 ,
const size_type n2 ,
264 array_traits::CheckRank<3,BaseType::Rank>::ok();
265 m_storage.resize( n1 * n2 * n3 );
269 void resize(
const size_type n1 ,
const size_type n2 )
271 array_traits::CheckRank<2,BaseType::Rank>::ok();
272 m_storage.resize( n1 * n2 );
276 void resize(
const size_type n1 )
278 array_traits::CheckRank<1,BaseType::Rank>::ok();
279 m_storage.resize( n1 );
284 ArrayVector(
const size_type *
const dims )
285 : BaseType(), m_storage() { resize( dims ); }
287 ArrayVector(
const size_type n1 ,
const size_type n2 ,
288 const size_type n3 ,
const size_type n4 ,
289 const size_type n5 ,
const size_type n6 ,
290 const size_type n7 ,
const size_type n8 )
291 : BaseType(), m_storage() { resize(n1,n2,n3,n4,n5,n6,n7,n8); }
293 ArrayVector(
const size_type n1 ,
const size_type n2 ,
294 const size_type n3 ,
const size_type n4 ,
295 const size_type n5 ,
const size_type n6 ,
297 : BaseType(), m_storage() { resize(n1,n2,n3,n4,n5,n6,n7); }
299 ArrayVector(
const size_type n1 ,
const size_type n2 ,
300 const size_type n3 ,
const size_type n4 ,
301 const size_type n5 ,
const size_type n6 )
302 : BaseType(), m_storage() { resize(n1,n2,n3,n4,n5,n6); }
304 ArrayVector(
const size_type n1 ,
const size_type n2 ,
305 const size_type n3 ,
const size_type n4 ,
307 : BaseType(), m_storage() { resize(n1,n2,n3,n4,n5); }
309 ArrayVector(
const size_type n1 ,
const size_type n2 ,
310 const size_type n3 ,
const size_type n4 )
311 : BaseType(), m_storage() { resize(n1,n2,n3,n4); }
313 ArrayVector(
const size_type n1 ,
const size_type n2 ,
315 : BaseType(), m_storage() { resize(n1,n2,n3); }
317 ArrayVector(
const size_type n1 ,
const size_type n2 )
318 : BaseType(), m_storage() { resize(n1,n2); }
320 ArrayVector(
const size_type n1 )
321 : BaseType(), m_storage() { resize(n1); }
ArrayOrder
Define Natural (C-language) or Fortran ordering of array dimensions. A RankZero array does not ha...
size_type size() const
Total number of member data items.
Array & assign(value_type *arg_ptr, const size_type *const dims)
Assign pointer and dimensions.
array_traits::int_t size_type
Type for sizes.