12#ifndef __cxz_prange_cc_h__
13#define __cxz_prange_cc_h__
24 template <
class IndexT>
30 auto o = mRangePtr->orig();
31 auto p = mRangePtr->parts()[
pos];
32 mOrig = std::make_shared<IndexT>(o,
p);
35 template <
class IndexT>
39 *mOrig = mRangePtr->parts()[IB::mPos];
43 template <
class IndexT>
47 *mOrig = mRangePtr->parts()[IB::mPos];
51 template <
class IndexT>
55 *mOrig = mRangePtr->parts()[IB::mPos];
59 template <
class IndexT>
62 return PIndex(mRangePtr, IB::mPos +
n);
65 template <
class IndexT>
68 return lex() -
i.
lex();
71 template <
class IndexT>
74 return PIndex(mRangePtr, IB::mPos -
n);
77 template <
class IndexT>
81 *mOrig = mRangePtr->parts()[IB::mPos];
85 template <
class IndexT>
89 *mOrig = mRangePtr->parts()[IB::mPos];
93 template <
class IndexT>
99 template <
class IndexT>
102 return UPos(mRangePtr->size());
105 template <
class IndexT>
108 return UPos(mRangePtr->size());
111 template <
class IndexT>
117 template <
class IndexT>
123 template <
class IndexT>
129 template <
class IndexT>
135 template <
class IndexT>
139 if(
id == this->
id()){
143 return mOrig->stepSize(
id);
147 template <
class IndexT>
151 <<
") smaller than begin index position (" << lex() <<
")");
163 template <
class IndexT>
169 template <
class IndexT>
175 template <
class IndexT>
178 CXZ_ASSERT(
f[0]*
s[0] == lmax().val(),
"got wrong extension: " <<
f[0]*
s[0]
179 <<
" vs " << lmax().val());
185 template <
class IndexT>
188 return mOrig->stringMeta();
191 template <
class IndexT>
194 return mOrig->
meta();
197 template <
class IndexT>
205 template <
class IndexT>
208 return poproot(
_this, mRangePtr->parts(), mOrig->xpr(mOrig) );
211 template <
class IndexT>
212 template <
class Xpr,
class F>
216 mRangePtr->parts().data(),
xpr, std::forward<F>(
f));
219 template <
class IndexT>
222 return mOrig->formatIsTrivial();
225 template <
class IndexT>
232 template <
class IndexT>
240 template <
class IndexT>
250 template <
class IndexT>
255 for(
const auto& x: mRangePtr->parts()){
261 CXZ_ERROR(
"meta position '" <<
toString(mOrig->meta()) <<
"' not part of range");
268 template <
class I,
class I1>
278 template <
class RangeT>
280 mRange(range), mParts(
_parts)
283 template <
class RangeT>
288 template <
class RangeT>
294 mProd = this->fromCreated(
info, key);
295 if(mProd ==
nullptr) {
296 mProd = std::shared_ptr<PRange<RangeT>>(
new PRange<RangeT>(mRange, mParts) );
297 this->addToCreated(
info, key, mProd);
305 template <
class RangeT>
308 return mParts.size()-1;
311 template <
class RangeT>
317 template <
class RangeT>
320 return mRange->stringMeta( mParts[pos] );
323 template <
class RangeT>
329 template <
class RangeT>
332 return mRange->metaType();
335 template <
class RangeT>
338 if(r->type() == type()){
340 if(
rx->orig() == orig()){
342 for(
auto i:
rx->parts()){
343 if(
find(
p.begin(),
p.end(),
i) !=
p.end()){
350 return derive()->extend(r);
353 template <
class RangeT>
359 template <
class RangeT>
365 template <
class RangeT>
369 auto i = mRange->begin();
371 for(
const auto&
p: mParts){
372 meta[
j++] = *(
i =
p);
382 template <
class RangeT>
384 mRange(range), mParts(
_parts)
386 const auto max = std::max_element( mParts.begin(), mParts.end() );
387 mParts.push_back( *
max+1 );
390 template <
class RangeT>
400 template <
class RangeT>
#define CXZ_ERROR(errmsg)
#define CXZ_ASSERT(statement, errmsg)
const Sptr< IndexT > & orig() const
PIndex & operator-=(Int n)
RangePtr prange(const PIndex< IndexT > &last) const
UPos stepSize(const IndexId< I > &id) const
PIndex operator-(Int n) const
String stringMeta() const
PIndex & operator=(SizeT lexpos)
PIndex & reformat(const Vector< SizeT > &f, const Vector< SizeT > &s)
PIndex & operator+=(Int n)
decltype(auto) deepMax() const
decltype(auto) meta() const
PIndex operator+(Int n) const
IndexT::MetaType MetaType
bool formatIsTrivial() const
PIndex & at(const MetaType &metaPos)
decltype(auto) deepFormat() const
PIndex(const RangePtr &range, SizeT pos=0)
Sptr< RangeType > range() const
const Vector< SizeT > & parts() const
virtual SizeT size() const override final
virtual const TypeInfo & type() const override final
virtual RangePtr extend(const RangePtr &r) const override final
virtual SizeT dim() const override final
virtual const TypeInfo & metaType() const override final
virtual String stringMeta(SizeT pos) const override final
Sptr< RangeT > orig() const
RangePtr urange(const Vector< MetaT > &space)
constexpr decltype(auto) poproot(const Sptr< IndexT > &ind, const SizeT *parts, Op &&op)
Sptr< RangeBase > RangePtr
std::vector< T, Allocator< T > > Vector
decltype(auto) xpr(const Sptr< I > &i)
Sptr< Range > rangeCast(const RangePtr r)
decltype(auto) iptrMul(const Sptr< I1 > &a, const Sptr< I2 > &b)
bool formatIsTrivial(const Vector< SizeT > &f, const Vector< SizeT > &s)
String toString(const T &a)
RangePtr prange(const Sptr< RangeT > &range, const Vector< SizeT > &parts)
std::shared_ptr< T > Sptr
PRange, PRangeFactory and PIndex declaration.
URange, URangeFactory and UIndex declaration.