diff --git a/src/include/array/array_base.cc.h b/src/include/array/array_base.cc.h index 0856c17..ca38cbf 100644 --- a/src/include/array/array_base.cc.h +++ b/src/include/array/array_base.cc.h @@ -64,12 +64,12 @@ namespace CNORXZ template template - Sptr> CArrayBase::sl(const IndexInterface& i) const + Sptr> CArrayBase::sl(const IndexInterface& begin, + const IndexInterface& end) const { - auto beg = std::make_shared(this->begin()); - auto si = i.slice(beg); - auto it = *beg + i.lex(); - return std::make_shared(this, *si, it.pos()); + auto ai = itLexSave(begin); + auto aj = itLexSave(end); + return std::make_shared(subcube(ai,aj), this, ai.format(), ai.pos()); } template diff --git a/src/include/array/array_base.h b/src/include/array/array_base.h index 55183a9..cdf3c75 100644 --- a/src/include/array/array_base.h +++ b/src/include/array/array_base.h @@ -40,7 +40,8 @@ namespace CNORXZ const T& at(const DPack& pack) const; template - Sptr> sl(const IndexInterface& i) const; + Sptr> sl(const IndexInterface& begin, + const IndexInterface& end) const; template COpRoot operator()(const Sptr& i) const; diff --git a/src/include/ranges/prange.cc.h b/src/include/ranges/prange.cc.h index fc478b5..1efae1d 100644 --- a/src/include/ranges/prange.cc.h +++ b/src/include/ranges/prange.cc.h @@ -326,6 +326,23 @@ namespace CNORXZ { return Vector { mRange->id() }; } + + + /**************************** + * non-member functions * + ****************************/ + + template + RangePtr prange(const IndexInterface& begin, const IndexInterface& end) + { + Vector parts(end-begin); + const SizeT off = begin.pos(); + for(auto i = begin.THIS(); i != end.THIS(); ++i){ + parts[i.pos()-off] = i.pos(); + } + return begin.range()->partial(parts); // implement!!!! + //return PRangeFactory(begin.range(), parts).create(); + } } #endif diff --git a/src/include/ranges/prange.h b/src/include/ranges/prange.h index e1788ea..78961c8 100644 --- a/src/include/ranges/prange.h +++ b/src/include/ranges/prange.h @@ -117,6 +117,9 @@ namespace CNORXZ Sptr mRange; Vector mParts; }; + + template + RangePtr prange(const IndexInterface& begin, const IndexInterface& end); } // namespace CNORXZ diff --git a/src/include/ranges/range_base.h b/src/include/ranges/range_base.h index 69a1803..4d4002c 100644 --- a/src/include/ranges/range_base.h +++ b/src/include/ranges/range_base.h @@ -124,6 +124,7 @@ namespace CNORXZ RangePtr getSub(const RangePtr& r, SizeT num); MArray getSub(const RangePtr& r); + } #endif diff --git a/src/include/ranges/yrange.h b/src/include/ranges/yrange.h index f13989c..16b476c 100644 --- a/src/include/ranges/yrange.h +++ b/src/include/ranges/yrange.h @@ -9,6 +9,7 @@ #include "xpr/xpr.h" #include "index_format.h" #include "index_pack.h" +#include "prange.h" namespace CNORXZ { @@ -159,6 +160,10 @@ namespace CNORXZ static Sptr func(const RangePtr& r); }; + template <> + RangePtr prange(const IndexInterface>& begin, + const IndexInterface>& end); + } #endif diff --git a/src/lib/ranges/yrange.cc b/src/lib/ranges/yrange.cc index 45a45dd..082fc22 100644 --- a/src/lib/ranges/yrange.cc +++ b/src/lib/ranges/yrange.cc @@ -560,4 +560,18 @@ namespace CNORXZ { return std::dynamic_pointer_cast( YRangeFactory({r}).create() ); } + + template <> + RangePtr prange(const IndexInterface>& begin, + const IndexInterface>& end) + { + CXZ_WARNING("YRange specialization"); // test + const SizeT dim = begin.range()->dim(); + Vector v(dim); + for(SizeT i = 0; i != dim; ++i){ + v[i] = prange( DIndex(begin.THIS().pack()[i]), DIndex(end.THIS().pack()[i]) ); + } + return YRangeFactory(v).create(); + } + }