index: add prange member function

This commit is contained in:
Christian Zimmermann 2023-10-21 18:29:16 +02:00
parent db6b0a14ec
commit 301967288f
18 changed files with 223 additions and 147 deletions

View file

@ -69,7 +69,7 @@ namespace CNORXZ
{
auto ai = itLexSave(begin);
auto aj = itLexSave(end);
return std::make_shared<CSlice>(subcube(ai,aj), this, ai.format(), ai.pos());
return std::make_shared<CSlice>(ai.prange(aj), this, ai.format(), ai.pos());
}
template <typename T>

View file

@ -47,6 +47,8 @@ namespace CNORXZ
CIndex& at(const SizeT& metaPos);
COpRoot<SizeT,CIndex> xpr(const Sptr<CIndex>& _this) const;
RangePtr prange(const CIndex& end) const;
SizeT deepFormat() const;
/*
template <class Index>

View file

@ -54,6 +54,7 @@ namespace CNORXZ
DType meta() const;
DIndex& at(const DType& meta);
DXpr<SizeT> xpr(const Sptr<DIndex>& _this) const;
RangePtr prange(const DIndex& end) const;
Vector<SizeT> deepFormat() const;
DXpr<SizeT> ifor(const DXpr<SizeT>& xpr, std::function<SizeT(SizeT,SizeT)>&& f) const;

View file

@ -54,6 +54,8 @@ namespace CNORXZ
decltype(auto) meta() const { return THIS().meta(); }
I& at(const MetaType& meta) { return THIS().at(meta); }
decltype(auto) xpr(const Sptr<I>& _this) const { return THIS().xpr(_this); }
RangePtr prange(const IndexInterface& end) const { return THIS().prange(end.THIS()); }
/*
template <class Index>
decltype(auto) formatTo(const Sptr<Index>& ind) const { return ind->formatFrom(THIS()); }

View file

@ -479,6 +479,22 @@ namespace CNORXZ
return mLexFormat;
}
template <class FormatT, class... Indices>
RangePtr GMIndex<FormatT,Indices...>::prange(const MIndex<Indices...>& end) const
{
CXZ_ERROR("IMPLEMENT!!!");
return nullptr;
/*
return ifor<0,NI>
( [&](auto i) {
typedef typename std::remove_reference<decltype(mIPack[i])>::type::RangeType RangeT;
return std::dynamic_pointer_cast<RangeT>( mIPack[i]->prange( *end.pack()[i] ) );
},
[](const auto&... e) { return mrange(e...); }
);
*/
}
template <class FormatT, class... Indices>
auto GMIndex<FormatT,Indices...>::deepFormat() const
{

View file

@ -81,6 +81,7 @@ namespace CNORXZ
const SPack<Indices...>& pack() const;
const auto& format() const;
const auto& lexFormat() const;
RangePtr prange(const MIndex<Indices...>& end) const;
auto deepFormat() const;
GMIndex& setFormat(const FormatT& bs);

View file

@ -123,6 +123,19 @@ namespace CNORXZ
}
}
template <class IndexT>
RangePtr PIndex<IndexT>::prange(const PIndex<IndexT>& end) const
{
CXZ_ERROR("IMPLEMENT!!!");
return nullptr;
}
template <class IndexT>
decltype(auto) PIndex<IndexT>::deepFormat() const
{
return mOrig->deepFormat();
}
template <class IndexT>
String PIndex<IndexT>::stringMeta() const
{
@ -208,7 +221,7 @@ namespace CNORXZ
}
++IB::mPos;
}
CXZ_ERROR("meta position '" << mOrig->meta() << "' not part of range");
CXZ_ERROR("meta position '" << toString(mOrig->meta()) << "' not part of range");
}
/***************************
@ -327,22 +340,16 @@ namespace CNORXZ
return Vector<Uuid> { mRange->id() };
}
/****************************
* non-member functions *
****************************/
template <class I, typename M>
RangePtr prange(const IndexInterface<I,M>& begin, const IndexInterface<I,M>& end)
template <class RangeT>
RangePtr prange(const Sptr<RangeT>& range, const Vector<SizeT>& parts)
{
Vector<SizeT> 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<typename I::RangeType>(begin.range(), parts).create();
return PRangeFactory<RangeT>(range,parts).create();
}
}
#endif

View file

@ -41,6 +41,8 @@ namespace CNORXZ
template <SizeT I>
UPos stepSize(const IndexId<I>& id) const;
RangePtr prange(const PIndex<IndexT>& end) const;
decltype(auto) deepFormat() const;
String stringMeta() const;
decltype(auto) meta() const;
@ -118,8 +120,8 @@ namespace CNORXZ
Vector<SizeT> mParts;
};
template <class I, typename M>
RangePtr prange(const IndexInterface<I,M>& begin, const IndexInterface<I,M>& end);
template <class RangeT>
RangePtr prange(const Sptr<RangeT>& range, const Vector<SizeT>& parts);
} // namespace CNORXZ

View file

@ -141,6 +141,13 @@ namespace CNORXZ
return coproot(mMetaPtr,_this);
}
template <typename MetaT, SizeT S>
RangePtr SIndex<MetaT,S>::prange(const SIndex<MetaType,S>& end) const
{
CXZ_ERROR("IMPLEMENT!!!");
return nullptr;
}
template <typename MetaT, SizeT S>
SizeT SIndex<MetaT,S>::deepFormat() const
{

View file

@ -48,6 +48,7 @@ namespace CNORXZ
SIndex& at(const MetaT& metaPos);
decltype(auto) xpr(const Sptr<SIndex<MetaType,S>>& _this) const;
RangePtr prange(const SIndex<MetaType,S>& end) const;
SizeT deepFormat() const;
/*
template <class Index>

View file

@ -6,6 +6,7 @@
#include <algorithm>
#include "urange.h"
#include "prange.h"
#include "index_mul.h"
#include "xpr/for.h"
#include "operation/op_types.h"
@ -17,136 +18,148 @@ namespace CNORXZ
* UIndex *
*****************/
template <typename MetaType>
UIndex<MetaType>::UIndex(const RangePtr& range, SizeT pos) :
IndexInterface<UIndex<MetaType>,MetaType>(pos),
template <typename MetaT>
UIndex<MetaT>::UIndex(const RangePtr& range, SizeT pos) :
IndexInterface<UIndex<MetaT>,MetaT>(pos),
mRangePtr(rangeCast<RangeType>(range)),
mMetaPtr(&mRangePtr->get(0))
{}
template <typename MetaType>
UIndex<MetaType>& UIndex<MetaType>::operator=(size_t lexpos)
template <typename MetaT>
UIndex<MetaT>& UIndex<MetaT>::operator=(size_t lexpos)
{
IB::mPos = lexpos;
return *this;
}
template <typename MetaType>
UIndex<MetaType>& UIndex<MetaType>::operator++()
template <typename MetaT>
UIndex<MetaT>& UIndex<MetaT>::operator++()
{
++IB::mPos;
return *this;
}
template <typename MetaType>
UIndex<MetaType>& UIndex<MetaType>::operator--()
template <typename MetaT>
UIndex<MetaT>& UIndex<MetaT>::operator--()
{
--IB::mPos;
return *this;
}
template <typename MetaType>
UIndex<MetaType> UIndex<MetaType>::operator+(Int n) const
template <typename MetaT>
UIndex<MetaT> UIndex<MetaT>::operator+(Int n) const
{
return UIndex(mRangePtr, IB::mPos + n);
}
template <typename MetaType>
UIndex<MetaType> UIndex<MetaType>::operator-(Int n) const
template <typename MetaT>
UIndex<MetaT> UIndex<MetaT>::operator-(Int n) const
{
return UIndex(mRangePtr, IB::mPos - n);
}
template <typename MetaType>
UIndex<MetaType>& UIndex<MetaType>::operator+=(Int n)
template <typename MetaT>
UIndex<MetaT>& UIndex<MetaT>::operator+=(Int n)
{
IB::mPos += n;
return *this;
}
template <typename MetaType>
UIndex<MetaType>& UIndex<MetaType>::operator-=(Int n)
template <typename MetaT>
UIndex<MetaT>& UIndex<MetaT>::operator-=(Int n)
{
IB::mPos -= n;
return *this;
}
template <typename MetaType>
SizeT UIndex<MetaType>::lex() const
template <typename MetaT>
SizeT UIndex<MetaT>::lex() const
{
return IB::mPos;
}
template <typename MetaType>
UPos UIndex<MetaType>::pmax() const
template <typename MetaT>
UPos UIndex<MetaT>::pmax() const
{
return UPos(mRangePtr->size());
}
template <typename MetaType>
UPos UIndex<MetaType>::lmax() const
template <typename MetaT>
UPos UIndex<MetaT>::lmax() const
{
return UPos(mRangePtr->size());
}
template <typename MetaType>
IndexId<0> UIndex<MetaType>::id() const
template <typename MetaT>
IndexId<0> UIndex<MetaT>::id() const
{
return IndexId<0>(this->ptrId());
}
template <typename MetaType>
const MetaType& UIndex<MetaType>::operator*() const
template <typename MetaT>
const MetaT& UIndex<MetaT>::operator*() const
{
return mMetaPtr[IB::mPos];
}
template <typename MetaType>
String UIndex<MetaType>::stringMeta() const
template <typename MetaT>
String UIndex<MetaT>::stringMeta() const
{
return toString(this->meta());
}
template <typename MetaType>
const MetaType& UIndex<MetaType>::meta() const
template <typename MetaT>
const MetaT& UIndex<MetaT>::meta() const
{
return mMetaPtr[IB::mPos];
}
template <typename MetaType>
UIndex<MetaType>& UIndex<MetaType>::at(const MetaType& metaPos)
template <typename MetaT>
UIndex<MetaT>& UIndex<MetaT>::at(const MetaT& metaPos)
{
(*this) = mRangePtr->getMeta(metaPos);
return *this;
}
template <typename MetaType>
decltype(auto) UIndex<MetaType>::xpr(const Sptr<UIndex<MetaType>>& _this) const
template <typename MetaT>
decltype(auto) UIndex<MetaT>::xpr(const Sptr<UIndex<MetaT>>& _this) const
{
return coproot(mMetaPtr,_this);
}
template <typename MetaType>
SizeT UIndex<MetaType>::deepFormat() const
template <typename MetaT>
RangePtr UIndex<MetaT>::prange(const UIndex<MetaT>& end) const
{
CXZ_ASSERT(end > *this, "got end index position smaller than begin index position");
const SizeT beginPos = lex();
Vector<SizeT> parts(end.lex()-beginPos);
for(auto i = *this; i != end; ++i){
parts[i.lex()-beginPos] = i.lex();
}
return CNORXZ::prange(mRangePtr, parts);
}
template <typename MetaT>
SizeT UIndex<MetaT>::deepFormat() const
{
return 1;
}
template <typename MetaType>
size_t UIndex<MetaType>::dim() const // = 1
template <typename MetaT>
size_t UIndex<MetaT>::dim() const // = 1
{
return 1;
}
template <typename MetaType>
Sptr<URange<MetaType>> UIndex<MetaType>::range() const
template <typename MetaT>
Sptr<URange<MetaT>> UIndex<MetaT>::range() const
{
return mRangePtr;
}
template <typename MetaType>
template <typename MetaT>
template <SizeT I>
decltype(auto) UIndex<MetaType>::stepSize(const IndexId<I>& id) const
decltype(auto) UIndex<MetaT>::stepSize(const IndexId<I>& id) const
{
if constexpr(I != 0){
return SPos<0>();
@ -156,34 +169,34 @@ namespace CNORXZ
}
}
/*
template <typename MetaType>
template <typename MetaT>
template <class Index>
decltype(auto) UIndex<MetaType>::formatFrom(const Index& ind) const
decltype(auto) UIndex<MetaT>::formatFrom(const Index& ind) const
{
return *this;
}
template <typename MetaType>
template <typename MetaT>
template <class Index>
decltype(auto) UIndex<MetaType>::slice(const Sptr<Index>& ind) const
decltype(auto) UIndex<MetaT>::slice(const Sptr<Index>& ind) const
{
if(ind != nullptr){
if(ind->dim() != 0) {
return Sptr<UIndex<MetaType>>();
return Sptr<UIndex<MetaT>>();
}
}
return std::make_shared<UIndex<MetaType>>(*this);
return std::make_shared<UIndex<MetaT>>(*this);
}
*/
template <typename MetaType>
template <typename MetaT>
template <class Xpr, class F>
decltype(auto) UIndex<MetaType>::ifor(const Xpr& xpr, F&& f) const
decltype(auto) UIndex<MetaT>::ifor(const Xpr& xpr, F&& f) const
{
return For<0,Xpr,F>(this->pmax().val(), this->id(), xpr, std::forward<F>(f));
}
template <typename MetaType, class I1>
decltype(auto) operator*(const Sptr<UIndex<MetaType>>& a, const Sptr<I1>& b)
template <typename MetaT, class I1>
decltype(auto) operator*(const Sptr<UIndex<MetaT>>& a, const Sptr<I1>& b)
{
return iptrMul(a, b);
}
@ -192,32 +205,32 @@ namespace CNORXZ
* URangeFactory *
**********************/
template <typename MetaType>
URangeFactory<MetaType>::URangeFactory(const Vector<MetaType>& space) :
template <typename MetaT>
URangeFactory<MetaT>::URangeFactory(const Vector<MetaT>& space) :
mSpace(space) {}
template <typename MetaType>
URangeFactory<MetaType>::URangeFactory(Vector<MetaType>&& space) :
template <typename MetaT>
URangeFactory<MetaT>::URangeFactory(Vector<MetaT>&& space) :
mSpace(space) {}
template <typename MetaType>
URangeFactory<MetaType>::URangeFactory(const Vector<MetaType>& space, const RangePtr& ref) :
template <typename MetaT>
URangeFactory<MetaT>::URangeFactory(const Vector<MetaT>& space, const RangePtr& ref) :
mSpace(space), mRef(ref) {}
template <typename MetaType>
URangeFactory<MetaType>::URangeFactory(Vector<MetaType>&& space, const RangePtr& ref) :
template <typename MetaT>
URangeFactory<MetaT>::URangeFactory(Vector<MetaT>&& space, const RangePtr& ref) :
mSpace(space), mRef(ref) {}
template <typename MetaType>
void URangeFactory<MetaType>::make()
template <typename MetaT>
void URangeFactory<MetaT>::make()
{
const auto& info = typeid(URange<MetaType>);
const auto& info = typeid(URange<MetaT>);
if(mRef != nullptr) {
mProd = this->fromCreated(info, {mRef->id()});
}
if(mProd == nullptr){
RangePtr key = mProd = std::shared_ptr<URange<MetaType>>
( new URange<MetaType>( std::move(mSpace) ) );
RangePtr key = mProd = std::shared_ptr<URange<MetaT>>
( new URange<MetaT>( std::move(mSpace) ) );
if(mRef != nullptr) { key = mRef; }
this->addToCreated(info, { key->id() }, mProd);
}
@ -227,88 +240,88 @@ namespace CNORXZ
* URange *
***************/
template <typename MetaType>
URange<MetaType>::URange(const Vector<MetaType>& space) :
RangeInterface<URange<MetaType>>(),
template <typename MetaT>
URange<MetaT>::URange(const Vector<MetaT>& space) :
RangeInterface<URange<MetaT>>(),
mSpace(space)
{
std::sort(mSpace.begin(), mSpace.end(), std::less<MetaType>());
std::sort(mSpace.begin(), mSpace.end(), std::less<MetaT>());
auto itdupl = std::adjacent_find(mSpace.begin(), mSpace.end());
CXZ_ASSERT(itdupl == mSpace.end(), "found duplicate: " << *itdupl);
}
template <typename MetaType>
URange<MetaType>::URange(Vector<MetaType>&& space) :
RangeInterface<URange<MetaType>>(),
template <typename MetaT>
URange<MetaT>::URange(Vector<MetaT>&& space) :
RangeInterface<URange<MetaT>>(),
mSpace(space)
{
std::sort(mSpace.begin(), mSpace.end(), std::less<MetaType>());
std::sort(mSpace.begin(), mSpace.end(), std::less<MetaT>());
auto itdupl = std::adjacent_find(mSpace.begin(), mSpace.end());
CXZ_ASSERT(itdupl == mSpace.end(), "found duplicate: " << toString(*itdupl));
}
template <typename MetaType>
const MetaType& URange<MetaType>::get(SizeT pos) const
template <typename MetaT>
const MetaT& URange<MetaT>::get(SizeT pos) const
{
return mSpace[pos];
}
template <typename MetaType>
const MetaType* URange<MetaType>::get() const
template <typename MetaT>
const MetaT* URange<MetaT>::get() const
{
return mSpace.data();
}
template <typename MetaType>
SizeT URange<MetaType>::getMeta(const MetaType& meta) const
template <typename MetaT>
SizeT URange<MetaT>::getMeta(const MetaT& meta) const
{
auto b = mSpace.begin();
auto e = mSpace.end();
return std::lower_bound(b, e, meta, std::less<MetaType>()) - b;
return std::lower_bound(b, e, meta, std::less<MetaT>()) - b;
}
template <typename MetaType>
SizeT URange<MetaType>::size() const
template <typename MetaT>
SizeT URange<MetaT>::size() const
{
return mSpace.size();
}
template <typename MetaType>
SizeT URange<MetaType>::dim() const
template <typename MetaT>
SizeT URange<MetaT>::dim() const
{
return 1;
}
template <typename MetaType>
String URange<MetaType>::stringMeta(SizeT pos) const
template <typename MetaT>
String URange<MetaT>::stringMeta(SizeT pos) const
{
return toString(this->get(pos));
}
template <typename MetaType>
const TypeInfo& URange<MetaType>::type() const
template <typename MetaT>
const TypeInfo& URange<MetaT>::type() const
{
return typeid(URange<MetaType>);
return typeid(URange<MetaT>);
}
template <typename MetaType>
const TypeInfo& URange<MetaType>::metaType() const
template <typename MetaT>
const TypeInfo& URange<MetaT>::metaType() const
{
return typeid(MetaType);
return typeid(MetaT);
}
template <typename MetaType>
RangePtr URange<MetaType>::extend(const RangePtr& r) const
template <typename MetaT>
RangePtr URange<MetaT>::extend(const RangePtr& r) const
{
auto rx = rangeCast<URange<MetaType>>(r);
auto rx = rangeCast<URange<MetaT>>(r);
auto space = mSpace;
space.insert(space.end(), rx->mSpace.begin(), rx->mSpace.end());
return URangeFactory<MetaType>( space ).create();
return URangeFactory<MetaT>( space ).create();
}
template <typename MetaType>
Vector<Uuid> URange<MetaType>::key() const
template <typename MetaT>
Vector<Uuid> URange<MetaT>::key() const
{
return Vector<Uuid> { this->id() };
}
@ -317,30 +330,30 @@ namespace CNORXZ
* Range Casts *
*******************/
template <typename MetaType>
template <typename MetaT>
struct URangeCast
{
template <typename T>
static inline Sptr<URange<MetaType>> transform(const RangePtr& r)
static inline Sptr<URange<MetaT>> transform(const RangePtr& r)
{
if(r->type() == typeid(URange<T>)){
auto rr = std::dynamic_pointer_cast<URange<T>>(r);
Vector<MetaType> v(rr->size());
Vector<MetaT> v(rr->size());
std::transform(rr->begin(), rr->end(), v.begin(),
[](const T& x) { return static_cast<MetaType>(x); } );
return std::dynamic_pointer_cast<URange<MetaType>>
( URangeFactory<MetaType>(std::move(v)).create() );
[](const T& x) { return static_cast<MetaT>(x); } );
return std::dynamic_pointer_cast<URange<MetaT>>
( URangeFactory<MetaT>(std::move(v)).create() );
}
else {
return nullptr;
}
}
static inline Sptr<URange<MetaType>> cast(const RangePtr& r)
static inline Sptr<URange<MetaT>> cast(const RangePtr& r)
{
static_assert(std::is_fundamental<MetaType>::value, "got non-fundamental type");
static_assert(std::is_fundamental<MetaT>::value, "got non-fundamental type");
CXZ_ASSERT(r->dim() == 1, "range cast into URange<Int>: source range must have dim = 1, got " << r->dim());
Sptr<URange<MetaType>> o = nullptr;
Sptr<URange<MetaT>> o = nullptr;
o = transform<SizeT>(r); if(o) return o;
o = transform<Int>(r); if(o) return o;
o = transform<LInt>(r); if(o) return o;
@ -415,11 +428,11 @@ namespace CNORXZ
};
template <typename MetaType>
Sptr<URange<MetaType>> RangeCast<URange<MetaType>>::func(const RangePtr& r)
template <typename MetaT>
Sptr<URange<MetaT>> RangeCast<URange<MetaT>>::func(const RangePtr& r)
{
if constexpr(std::is_fundamental<MetaType>::value or is_vector<MetaType>::value){
return URangeCast<MetaType>::cast(r);
if constexpr(std::is_fundamental<MetaT>::value or is_vector<MetaT>::value){
return URangeCast<MetaT>::cast(r);
}
else {
CXZ_ERROR("no range cast available for input range '" << r->type().name() << "'");

View file

@ -55,6 +55,8 @@ namespace CNORXZ
UIndex& at(const MetaT& metaPos);
decltype(auto) xpr(const Sptr<UIndex<MetaType>>& _this) const;
RangePtr prange(const UIndex<MetaType>& end) const;
SizeT deepFormat() const;
/*
template <class Index>
@ -94,12 +96,13 @@ namespace CNORXZ
RangePtr mRef;
};
template <typename MetaType>
class URange : public RangeInterface<URange<MetaType>>
template <typename MetaT>
class URange : public RangeInterface<URange<MetaT>>
{
public:
typedef RangeBase RB;
typedef UIndex<MetaType> IndexType;
typedef UIndex<MetaT> IndexType;
typedef MetaT MetaType;
friend URangeFactory<MetaType>;

View file

@ -127,6 +127,12 @@ namespace CNORXZ
return mI->stepSize(id);
}
template <class Index, typename Meta>
RangePtr XIndex<Index,Meta>::prange(const XIndexPtr& end) const
{
return mI->prange( *std::dynamic_pointer_cast<Index>(end) );
}
template <class Index, typename Meta>
Vector<SizeT> XIndex<Index,Meta>::deepFormat() const
{

View file

@ -38,6 +38,7 @@ namespace CNORXZ
virtual SizeT dim() const = 0;
virtual RangePtr range() const = 0;
virtual UPos stepSize(const IndexId<0>& id) const = 0;
virtual RangePtr prange(const XIndexPtr& end) const = 0;
virtual Vector<SizeT> deepFormat() const = 0;
//virtual Vector<XIndexPtr> pack() const = 0;
//virtual Vector<SizeT> format() const = 0;
@ -92,6 +93,7 @@ namespace CNORXZ
virtual SizeT dim() const override final;
virtual RangePtr range() const override final;
virtual UPos stepSize(const IndexId<0>& id) const override final;
virtual RangePtr prange(const XIndexPtr& end) const override final;
virtual Vector<SizeT> deepFormat() const override final;
//virtual Vector<XIndexPtr> pack() const override final;
//virtual Vector<SizeT> format() const override final;

View file

@ -66,6 +66,7 @@ namespace CNORXZ
YIndex& operator()();
const DPack& pack() const;
RangePtr prange(const YIndex& end) const;
Vector<SizeT> deepFormat() const;
const YFormat& format() const;
const YFormat& lexFormat() const;
@ -160,9 +161,6 @@ namespace CNORXZ
static Sptr<YRange> func(const RangePtr& r);
};
template <>
RangePtr prange(const IndexInterface<YIndex,Vector<DType>>& begin,
const IndexInterface<YIndex,Vector<DType>>& end);
}

View file

@ -1,5 +1,6 @@
#include "ranges/ranges.h"
#include "ranges/prange.h"
#include "operation/operation.h"
namespace CNORXZ
@ -116,6 +117,17 @@ namespace CNORXZ
return coproot(m.data(), _this);
}
RangePtr CIndex::prange(const CIndex& end) const
{
CXZ_ASSERT(end > *this, "got end index position smaller than begin index position");
const SizeT beginPos = lex();
Vector<SizeT> parts(end.lex() - beginPos);
for(auto i = *this; i != end; ++i){
parts[i.lex()-beginPos] = i.lex();
}
return CNORXZ::prange(mRangePtr, parts);
}
SizeT CIndex::deepFormat() const
{
return 1;

View file

@ -167,6 +167,11 @@ namespace CNORXZ
return mI->xpr(_this->xptr());
}
RangePtr DIndex::prange(const DIndex& end) const
{
return mI->prange( end.xptr() );
}
Vector<SizeT> DIndex::deepFormat() const
{
return mI->deepFormat();

View file

@ -368,6 +368,17 @@ namespace CNORXZ
return mIs;
}
RangePtr YIndex::prange(const YIndex& end) const
{
CXZ_ASSERT(dim() == end.dim(), "end index has different number of dimensions ("
<< end.dim() << ") than begin index (" << dim() << ")");
Vector<RangePtr> v(dim());
for(SizeT i = 0; i != dim(); ++i){
v[i] = mIs[i]->prange( end.pack()[i] );
}
return YRangeFactory(v).create();
}
Vector<SizeT> YIndex::deepFormat() const
{
Vector<Vector<SizeT>> dfv(mIs.size());
@ -561,17 +572,4 @@ namespace CNORXZ
return std::dynamic_pointer_cast<YRange>( YRangeFactory({r}).create() );
}
template <>
RangePtr prange(const IndexInterface<YIndex,Vector<DType>>& begin,
const IndexInterface<YIndex,Vector<DType>>& end)
{
CXZ_WARNING("YRange specialization"); // test
const SizeT dim = begin.range()->dim();
Vector<RangePtr> 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();
}
}