12#ifndef __cxz_array_base_cc_h__
13#define __cxz_array_base_cc_h__
30 template <
typename I,
typename M>
34 return data()[i.
lex()];
43 template <
typename I,
typename M>
46 auto ai = itLexSave(i);
51 template <
class... Indices>
55 return data()[pack.
lex()];
58 auto ai = itLex(pack);
64 template <
class... Indices>
67 auto ai = itLexSave(pack);
74 auto ai = itLex(pack);
81 auto ai = itLexSave(pack);
86 template <
typename I,
typename M>
90 auto ai = itLexSave(begin);
91 auto aj = itLexSave(end);
92 return std::make_shared<CSlice<T>>(ai.prange(aj),
this, ai.format(), ai.pos());
98 return mRange->size();
101 template <
typename T>
107 template <
typename T>
110 return this->cbegin();
113 template <
typename T>
119 template <
typename T>
120 template <
class Index>
126 "got non-trivial index for container with trivial format");
127 this->checkFormatCompatibility(*i);
131 if(i->formatIsTrivial()){
137 auto aformat = beg.deepFormat();
138 auto amax = beg.deepMax();
139 auto fi = i->reformat( aformat, amax );
143 this->checkFormatCompatibility(*i);
149 this->checkFormatCompatibility(*i);
155 template <
typename T>
156 template <
class... Indices>
162 template <
typename T>
172 template <
typename T>
176 return begin() + acc.
lex();
179 template <
typename T>
183 CXZ_ASSERT(acc.lex() < this->size(),
"index out of range");
185 return begin() + acc.
lex();
188 template <
typename T>
193 CXZ_ASSERT(acc.lmax().val() == j.lmax().val(),
194 "got index of iteration space size = " << acc.lmax().val()
195 <<
", expected size = " << acc.lmax().val());
198 std::sort(f1.begin(),f1.end());
199 std::sort(f2.begin(),f2.end());
203 <<
", which is incompatible to target format " <<
toString(f2));
206 while(i1 < f1.size() and i2 < f2.size()){
207 if(f1[i1] < f2[i2]) {
208 if(++i1 == f1.size())
break;
210 <<
", which is incompatible to target format " <<
toString(f2));
212 else if(f1[i1] > f2[i2]) {
213 if(++i2 == f2.size())
break;
215 <<
", which is incompatible to target format " <<
toString(f2));
228 template <
typename T>
233 template <
typename T>
234 template <
typename I,
typename M>
246 template <
typename T>
247 template <
typename I,
typename M>
250 auto ai = itLexSave(i);
254 template <
typename T>
255 template <
class... Indices>
259 return data()[pack.
lex()];
262 auto ai = itLex(pack);
267 template <
typename T>
268 template <
class... Indices>
271 auto ai = itLexSave(pack);
275 template <
typename T>
278 auto ai = itLex(pack);
282 template <
typename T>
289 template <
typename T>
290 template <
typename I,
typename M>
294 auto ai = itLexSave(begin);
295 auto aj = itLexSave(end);
296 return std::make_shared<Slice<T>>(ai.prange(aj),
this, ai.format(), ai.pos());
299 template <
typename T>
302 return iterator(this->data(), this->cbegin());
305 template <
typename T>
308 return iterator(this->data(), this->cend());
311 template <
typename T>
312 template <
class Index>
318 "got non-trivial index for container with trivial format");
319 this->checkFormatCompatibility(*i);
323 if(i->formatIsTrivial()){
329 auto aformat = beg.deepFormat();
330 auto amax = beg.deepMax();
331 auto fi = i->reformat( aformat, amax );
335 this->checkFormatCompatibility(*i);
341 this->checkFormatCompatibility(*i);
347 template <
typename T>
348 template <
class... Indices>
354 template <
typename T>
364 template <
typename T>
368 return begin() + acc.
lex();
371 template <
typename T>
375 CXZ_ASSERT(acc.lex() < this->size(),
"index out of range");
377 return begin() + acc.
lex();
Array base class declarations.
#define CXZ_ASSERT(statement, errmsg)
Sptr< ArrayBase< T > > sl(const IndexInterface< I, M > &begin, const IndexInterface< I, M > &end)
iterator itLex(const Acc &acc)
OpRoot< T, Index > operator()(const Sptr< Index > &i)
T & operator[](const IndexInterface< I, M > &i)
ArrayBase(const RangePtr &range)
T & at(const IndexInterface< I, M > &i)
iterator itLexSave(const Acc &acc)
COpRoot< T, Index > operator()(const Sptr< Index > &i) const
CArrayBase(const RangePtr &range)
virtual RangePtr range() const
const T & operator[](const IndexInterface< I, M > &i) const
virtual const_iterator begin() const
Sptr< CArrayBase< T > > sl(const IndexInterface< I, M > &begin, const IndexInterface< I, M > &end) const
const T & at(const IndexInterface< I, M > &i) const
const_iterator itLex(const Acc &acc) const
void checkFormatCompatibility(const Acc &acc) const
const_iterator itLexSave(const Acc &acc) const
virtual const_iterator end() const
virtual SizeT size() const
Sptr< I > moveToPtr(I &&i)
constexpr decltype(auto) coproot(const CArrayBase< T > &a, const Sptr< IndexT > &ind)
Sptr< RangeBase > RangePtr
Sptr< YIndex > yindexPtr(const DPack &is)
std::vector< T, Allocator< T > > Vector
Sptr< Range > rangeCast(const RangePtr r)
bool formatIsTrivial(const Vector< SizeT > &f, const Vector< SizeT > &s)
String toString(const T &a)
constexpr decltype(auto) mindexPtr(const SPack< Indices... > &pack)
std::shared_ptr< T > Sptr
Vector< T > toVec(const Arr< T, N > &a)
constexpr decltype(auto) oproot(ArrayBase< T > &a, const Sptr< IndexT > &ind)