10 #ifndef Shards_ArrayVector_hpp
11 #define Shards_ArrayVector_hpp
15 #include <Shards_Array.hpp>
26 class Tag1 = void ,
class Tag2 = void ,
27 class Tag3 = void ,
class Tag4 = void ,
28 class Tag5 = void ,
class Tag6 = void ,
29 class Tag7 = void ,
class Tag8 =
void >
34 template<
typename Scalar , ArrayOrder Order >
35 class ArrayVector<Scalar,Order,void,void,void,void, void,void,void,void>
36 :
public Array<Scalar,Order,void,void,void,void, void,void,void,void>
39 std::vector<Scalar> m_storage ;
42 Array<Scalar,Order,void,void,void,void, void,void,void,void>
45 ArrayVector(
const ArrayVector & );
46 ArrayVector & operator = (
const ArrayVector & );
48 Scalar * get_ptr() {
return m_storage.empty() ? NULL : & m_storage[0] ; }
52 typedef array_traits::int_t size_type ;
55 : BaseType() , m_storage() {}
59 template<
class Tag1 ,
class Tag2 ,
class Tag3 ,
class Tag4 ,
60 class Tag5 ,
class Tag6 ,
class Tag7 ,
class Tag8 >
61 void resize(
const size_type n1 ,
const size_type n2 ,
62 const size_type n3 ,
const size_type n4 ,
63 const size_type n5 ,
const size_type n6 ,
64 const size_type n7 ,
const size_type n8 )
66 m_storage.resize( n1 * n2 * n3 * n4 * n5 * n6 * n7 * n8 );
67 BaseType::template assign<Tag1,Tag2,Tag3,Tag4,Tag5,Tag6,Tag7,Tag8>
68 ( get_ptr() ,n1,n2,n3,n4,n5,n6,n7,n8);
71 template<
class Tag1 ,
class Tag2 ,
class Tag3 ,
class Tag4 ,
72 class Tag5 ,
class Tag6 ,
class Tag7 >
73 void resize(
const size_type n1 ,
const size_type n2 ,
74 const size_type n3 ,
const size_type n4 ,
75 const size_type n5 ,
const size_type n6 ,
78 m_storage.resize( n1 * n2 * n3 * n4 * n5 * n6 * n7 );
79 BaseType::template assign<Tag1,Tag2,Tag3,Tag4,Tag5,Tag6,Tag7>
80 ( get_ptr() ,n1,n2,n3,n4,n5,n6,n7);
83 template<
class Tag1 ,
class Tag2 ,
class Tag3 ,
class Tag4 ,
84 class Tag5 ,
class Tag6 >
85 void resize(
const size_type n1 ,
const size_type n2 ,
86 const size_type n3 ,
const size_type n4 ,
87 const size_type n5 ,
const size_type n6 )
89 m_storage.resize( n1 * n2 * n3 * n4 * n5 * n6 );
90 BaseType::template assign<Tag1,Tag2,Tag3,Tag4,Tag5,Tag6>
91 ( get_ptr() ,n1,n2,n3,n4,n5,n6);
94 template<
class Tag1 ,
class Tag2 ,
class Tag3 ,
class Tag4 ,
96 void resize(
const size_type n1 ,
const size_type n2 ,
97 const size_type n3 ,
const size_type n4 ,
100 m_storage.resize( n1 * n2 * n3 * n4 * n5 );
101 BaseType::template assign<Tag1,Tag2,Tag3,Tag4,Tag5>
102 ( get_ptr(),n1,n2,n3,n4,n5);
105 template<
class Tag1 ,
class Tag2 ,
class Tag3 ,
class Tag4 >
106 void resize(
const size_type n1 ,
const size_type n2 ,
107 const size_type n3 ,
const size_type n4 )
109 m_storage.resize( n1 * n2 * n3 * n4 );
110 BaseType::template assign<Tag1,Tag2,Tag3,Tag4>
111 ( get_ptr(),n1,n2,n3,n4);
114 template<
class Tag1 ,
class Tag2 ,
class Tag3 >
115 void resize(
const size_type n1 ,
const size_type n2 ,
118 m_storage.resize( n1 * n2 * n3 );
119 BaseType::template assign<Tag1,Tag2,Tag3>
120 ( get_ptr(),n1,n2,n3);
123 template<
class Tag1 ,
class Tag2 >
124 void resize(
const size_type n1 ,
const size_type n2 )
126 m_storage.resize( n1 * n2 );
127 BaseType::template assign<Tag1,Tag2>( get_ptr(),n1,n2);
130 template<
class Tag1 >
131 void resize(
const size_type n1 )
133 m_storage.resize( n1 );
134 BaseType::template assign<Tag1>( get_ptr(),n1);
140 template<
typename Scalar ,
ArrayOrder Order ,
141 class Tag1 ,
class Tag2 ,
class Tag3 ,
class Tag4 ,
142 class Tag5 ,
class Tag6 ,
class Tag7 ,
class Tag8 >
144 :
public Array<Scalar,Order,Tag1,Tag2,Tag3,Tag4,Tag5,Tag6,Tag7,Tag8>
147 std::vector<Scalar> m_storage ;
150 array_traits::Helper<Scalar,Order,Tag1,Tag2,Tag3,Tag4,Tag5,Tag6,Tag7,Tag8>
154 Array<Scalar,Order,Tag1,Tag2,Tag3,Tag4,Tag5,Tag6,Tag7,Tag8>
157 ArrayVector(
const ArrayVector & );
158 ArrayVector & operator = (
const ArrayVector & );
160 Scalar * get_ptr() {
return m_storage.empty() ? NULL : & m_storage[0] ; }
164 typedef array_traits::int_t size_type ;
167 : BaseType() , m_storage() {}
171 void resize(
const size_type *
const dims )
173 help_type::assign( BaseType::m_stride , dims );
175 m_storage.resize( n );
176 BaseType::m_ptr = get_ptr();
179 void resize(
const size_type n1 ,
const size_type n2 ,
180 const size_type n3 ,
const size_type n4 ,
181 const size_type n5 ,
const size_type n6 ,
182 const size_type n7 ,
const size_type n8 )
184 array_traits::CheckRank<8,BaseType::Rank>::ok();
185 m_storage.resize( n1 * n2 * n3 * n4 * n5 * n6 * n7 * n8 );
189 void resize(
const size_type n1 ,
const size_type n2 ,
190 const size_type n3 ,
const size_type n4 ,
191 const size_type n5 ,
const size_type n6 ,
194 array_traits::CheckRank<7,BaseType::Rank>::ok();
195 m_storage.resize( n1 * n2 * n3 * n4 * n5 * n6 * n7 );
199 void resize(
const size_type n1 ,
const size_type n2 ,
200 const size_type n3 ,
const size_type n4 ,
201 const size_type n5 ,
const size_type n6 )
203 array_traits::CheckRank<6,BaseType::Rank>::ok();
204 m_storage.resize( n1 * n2 * n3 * n4 * n5 * n6 );
208 void resize(
const size_type n1 ,
const size_type n2 ,
209 const size_type n3 ,
const size_type n4 ,
212 array_traits::CheckRank<5,BaseType::Rank>::ok();
213 m_storage.resize( n1 * n2 * n3 * n4 * n5 );
217 void resize(
const size_type n1 ,
const size_type n2 ,
218 const size_type n3 ,
const size_type n4 )
220 array_traits::CheckRank<4,BaseType::Rank>::ok();
221 m_storage.resize( n1 * n2 * n3 * n4 );
225 void resize(
const size_type n1 ,
const size_type n2 ,
228 array_traits::CheckRank<3,BaseType::Rank>::ok();
229 m_storage.resize( n1 * n2 * n3 );
233 void resize(
const size_type n1 ,
const size_type n2 )
235 array_traits::CheckRank<2,BaseType::Rank>::ok();
236 m_storage.resize( n1 * n2 );
240 void resize(
const size_type n1 )
242 array_traits::CheckRank<1,BaseType::Rank>::ok();
243 m_storage.resize( n1 );
248 ArrayVector(
const size_type *
const dims )
249 : BaseType(), m_storage() { resize( dims ); }
251 ArrayVector(
const size_type n1 ,
const size_type n2 ,
252 const size_type n3 ,
const size_type n4 ,
253 const size_type n5 ,
const size_type n6 ,
254 const size_type n7 ,
const size_type n8 )
255 : BaseType(), m_storage() { resize(n1,n2,n3,n4,n5,n6,n7,n8); }
257 ArrayVector(
const size_type n1 ,
const size_type n2 ,
258 const size_type n3 ,
const size_type n4 ,
259 const size_type n5 ,
const size_type n6 ,
261 : BaseType(), m_storage() { resize(n1,n2,n3,n4,n5,n6,n7); }
263 ArrayVector(
const size_type n1 ,
const size_type n2 ,
264 const size_type n3 ,
const size_type n4 ,
265 const size_type n5 ,
const size_type n6 )
266 : BaseType(), m_storage() { resize(n1,n2,n3,n4,n5,n6); }
268 ArrayVector(
const size_type n1 ,
const size_type n2 ,
269 const size_type n3 ,
const size_type n4 ,
271 : BaseType(), m_storage() { resize(n1,n2,n3,n4,n5); }
273 ArrayVector(
const size_type n1 ,
const size_type n2 ,
274 const size_type n3 ,
const size_type n4 )
275 : BaseType(), m_storage() { resize(n1,n2,n3,n4); }
277 ArrayVector(
const size_type n1 ,
const size_type n2 ,
279 : BaseType(), m_storage() { resize(n1,n2,n3); }
281 ArrayVector(
const size_type n1 ,
const size_type n2 )
282 : BaseType(), m_storage() { resize(n1,n2); }
284 ArrayVector(
const size_type n1 )
285 : 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.