implement missing prange member functions

This commit is contained in:
Christian Zimmermann 2023-10-21 19:23:38 +02:00
parent 301967288f
commit cf0e7c5856
5 changed files with 50 additions and 33 deletions

View file

@ -482,17 +482,14 @@ namespace CNORXZ
template <class FormatT, class... Indices>
RangePtr GMIndex<FormatT,Indices...>::prange(const MIndex<Indices...>& end) const
{
CXZ_ERROR("IMPLEMENT!!!");
return nullptr;
/*
return ifor<0,NI>
return iter<0,NI>
( [&](auto i) {
typedef typename std::remove_reference<decltype(mIPack[i])>::type::RangeType RangeT;
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>

View file

@ -126,8 +126,15 @@ namespace CNORXZ
template <class IndexT>
RangePtr PIndex<IndexT>::prange(const PIndex<IndexT>& end) const
{
CXZ_ERROR("IMPLEMENT!!!");
return nullptr;
CXZ_ASSERT(end > *this, "got end index position smaller than begin index position");
auto oi = *orig();
auto oend = *end.orig();
const SizeT beginPos = oi.lex();
Vector<SizeT> parts(oend.lex()-beginPos);
for(auto i = oi; i != oend; ++i){
parts[i.lex()-beginPos] = i.lex();
}
return CNORXZ::prange(mRangePtr->orig(), parts);
}
template <class IndexT>
@ -206,6 +213,12 @@ namespace CNORXZ
return *this;
}
template <class IndexT>
const Sptr<IndexT>& PIndex<IndexT>::orig() const
{
return mOrig;
}
/************************
* PIndex (private) *
************************/
@ -302,7 +315,7 @@ namespace CNORXZ
}
template <class RangeT>
RangePtr PRange<RangeT>::orig() const
Sptr<RangeT> PRange<RangeT>::orig() const
{
return mRange;
}

View file

@ -104,7 +104,7 @@ namespace CNORXZ
virtual const TypeInfo& metaType() const override final;
virtual RangePtr extend(const RangePtr& r) const override final;
RangePtr orig() const;
Sptr<RangeT> orig() const;
const Vector<SizeT>& parts() const;
RangePtr derive() const;

View file

@ -3,6 +3,7 @@
#define __cxz_range_cc_h__
#include "srange.h"
#include "prange.h"
namespace CNORXZ
{
@ -144,8 +145,13 @@ namespace CNORXZ
template <typename MetaT, SizeT S>
RangePtr SIndex<MetaT,S>::prange(const SIndex<MetaType,S>& end) const
{
CXZ_ERROR("IMPLEMENT!!!");
return nullptr;
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 S>

View file

@ -65,34 +65,35 @@ namespace CNORXZ
const MetaT* mMetaPtr;
};
template <typename MetaType, SizeT S, class I1>
decltype(auto) operator*(const Sptr<SIndex<MetaType,S>>& a, const Sptr<I1>& b);
template <typename MetaT, SizeT S, class I1>
decltype(auto) operator*(const Sptr<SIndex<MetaT,S>>& a, const Sptr<I1>& b);
template <typename MetaType, SizeT S>
template <typename MetaT, SizeT S>
class SRangeFactory : public RangeFactoryBase
{
public:
SRangeFactory(const Arr<MetaType,S>& space);
SRangeFactory(Arr<MetaType,S>&& space);
SRangeFactory(const Arr<MetaType,S>& space, const RangePtr& ref);
SRangeFactory(Arr<MetaType,S>&& space, const RangePtr& ref);
SRangeFactory(const Arr<MetaT,S>& space);
SRangeFactory(Arr<MetaT,S>&& space);
SRangeFactory(const Arr<MetaT,S>& space, const RangePtr& ref);
SRangeFactory(Arr<MetaT,S>&& space, const RangePtr& ref);
private:
SRangeFactory() = default;
virtual void make() override final;
Arr<MetaType,S> mSpace;
Arr<MetaT,S> mSpace;
RangePtr mRef;
};
template <typename MetaType, SizeT S>
class SRange : public RangeInterface<SRange<MetaType,S>>
template <typename MetaT, SizeT S>
class SRange : public RangeInterface<SRange<MetaT,S>>
{
public:
typedef RangeBase RB;
typedef SIndex<MetaType,S> IndexType;
typedef SIndex<MetaT,S> IndexType;
typedef MetaT MetaType;
friend SRangeFactory<MetaType,S>;
friend SRangeFactory<MetaT,S>;
virtual SizeT size() const override final;
virtual SizeT dim() const override final;
@ -101,28 +102,28 @@ namespace CNORXZ
virtual const TypeInfo& metaType() const override final;
virtual RangePtr extend(const RangePtr& r) const override final;
const MetaType& get(SizeT pos) const;
const MetaType* get() const;
SizeT getMeta(const MetaType& metaPos) const;
const MetaT& get(SizeT pos) const;
const MetaT* get() const;
SizeT getMeta(const MetaT& metaPos) const;
private:
SRange() = default;
SRange(const SRange& in) = delete;
SRange(const Arr<MetaType,S>& space);
SRange(Arr<MetaType,S>&& space);
SRange(const Arr<MetaT,S>& space);
SRange(Arr<MetaT,S>&& space);
Arr<MetaType,S> mSpace;
Arr<MetaT,S> mSpace;
virtual Vector<Uuid> key() const override final;
SERIALIZATION_FUNCTIONS_NOPUB;
};
template <typename MetaType, SizeT S>
struct RangeCast<SRange<MetaType,S>>
template <typename MetaT, SizeT S>
struct RangeCast<SRange<MetaT,S>>
{
static Sptr<SRange<MetaType,S>> func(const RangePtr& r);
static Sptr<SRange<MetaT,S>> func(const RangePtr& r);
};
}