pos_type: auto -> decltype(auto) + rop_types: handle local index offsets
This commit is contained in:
parent
a4a67d2841
commit
df2b6892d9
4 changed files with 38 additions and 13 deletions
|
@ -151,7 +151,7 @@ namespace CNORXZ
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class PosT>
|
template <class PosT>
|
||||||
constexpr UPos UPos::operator-(const PosT& in) const
|
constexpr decltype(auto) UPos::operator-(const PosT& in) const
|
||||||
{
|
{
|
||||||
return UPos(mExt - in.val());
|
return UPos(mExt - in.val());
|
||||||
}
|
}
|
||||||
|
@ -458,7 +458,7 @@ namespace CNORXZ
|
||||||
|
|
||||||
template <class BPosT, class NPosT>
|
template <class BPosT, class NPosT>
|
||||||
template <class PosT>
|
template <class PosT>
|
||||||
constexpr auto MPos<BPosT,NPosT>::operator+(const PosT& a) const
|
constexpr decltype(auto) MPos<BPosT,NPosT>::operator+(const PosT& a) const
|
||||||
{
|
{
|
||||||
typedef decltype(BPosT::operator+(a)) OBPosT;
|
typedef decltype(BPosT::operator+(a)) OBPosT;
|
||||||
typedef decltype(mNext + a.next()) ONPosT;
|
typedef decltype(mNext + a.next()) ONPosT;
|
||||||
|
@ -467,7 +467,7 @@ namespace CNORXZ
|
||||||
|
|
||||||
template <class BPosT, class NPosT>
|
template <class BPosT, class NPosT>
|
||||||
template <class PosT>
|
template <class PosT>
|
||||||
constexpr auto MPos<BPosT,NPosT>::operator*(const PosT& a) const
|
constexpr decltype(auto) MPos<BPosT,NPosT>::operator*(const PosT& a) const
|
||||||
{
|
{
|
||||||
typedef decltype(BPosT::operator*(a)) OBPosT;
|
typedef decltype(BPosT::operator*(a)) OBPosT;
|
||||||
typedef decltype(mNext * a) ONPosT;
|
typedef decltype(mNext * a) ONPosT;
|
||||||
|
@ -476,7 +476,7 @@ namespace CNORXZ
|
||||||
|
|
||||||
template <class BPosT, class NPosT>
|
template <class BPosT, class NPosT>
|
||||||
template <class PosT>
|
template <class PosT>
|
||||||
constexpr auto MPos<BPosT,NPosT>::operator()(const PosT& a) const
|
constexpr decltype(auto) MPos<BPosT,NPosT>::operator()(const PosT& a) const
|
||||||
{
|
{
|
||||||
typedef decltype(BPosT::operator()(a)) OBPosT;
|
typedef decltype(BPosT::operator()(a)) OBPosT;
|
||||||
typedef decltype(mNext(a)) ONPosT;
|
typedef decltype(mNext(a)) ONPosT;
|
||||||
|
|
|
@ -66,7 +66,7 @@ namespace CNORXZ
|
||||||
constexpr decltype(auto) operator+(const PosT& a) const;
|
constexpr decltype(auto) operator+(const PosT& a) const;
|
||||||
|
|
||||||
template <class PosT>
|
template <class PosT>
|
||||||
constexpr UPos operator-(const PosT& a) const;
|
constexpr decltype(auto) operator-(const PosT& a) const;
|
||||||
|
|
||||||
//constexpr SPos<0> operator*(const SPos<0>& a) const;
|
//constexpr SPos<0> operator*(const SPos<0>& a) const;
|
||||||
|
|
||||||
|
@ -179,14 +179,14 @@ namespace CNORXZ
|
||||||
constexpr const NPosT& next() const;
|
constexpr const NPosT& next() const;
|
||||||
|
|
||||||
template <class PosT>
|
template <class PosT>
|
||||||
constexpr auto operator+(const PosT& a) const;
|
constexpr decltype(auto) operator+(const PosT& a) const;
|
||||||
|
|
||||||
template <class PosT>
|
template <class PosT>
|
||||||
constexpr auto operator*(const PosT& a) const;
|
constexpr decltype(auto) operator*(const PosT& a) const;
|
||||||
|
|
||||||
// same as operator*, except for FPos/SFPos, where map is executed
|
// same as operator*, except for FPos/SFPos, where map is executed
|
||||||
template <class PosT>
|
template <class PosT>
|
||||||
constexpr auto operator()(const PosT& a) const;
|
constexpr decltype(auto) operator()(const PosT& a) const;
|
||||||
|
|
||||||
template <class PosT>
|
template <class PosT>
|
||||||
constexpr decltype(auto) extend(const PosT& a) const;
|
constexpr decltype(auto) extend(const PosT& a) const;
|
||||||
|
|
|
@ -18,7 +18,8 @@ namespace CNORXZ
|
||||||
const Sptr<IndexT>& li) :
|
const Sptr<IndexT>& li) :
|
||||||
mData(a.buffermap().data()),
|
mData(a.buffermap().data()),
|
||||||
mRIndex(ri),
|
mRIndex(ri),
|
||||||
mIndex(li)
|
mIndex(li),
|
||||||
|
mLOff(mIndex->pos())
|
||||||
{
|
{
|
||||||
CXZ_ASSERT(a.buffermap().size() == ri->lmax().val(),
|
CXZ_ASSERT(a.buffermap().size() == ri->lmax().val(),
|
||||||
"data map not properly initialized: map size = " << a.buffermap().size()
|
"data map not properly initialized: map size = " << a.buffermap().size()
|
||||||
|
@ -32,14 +33,21 @@ namespace CNORXZ
|
||||||
//CXZ_ASSERT(pos.val() < mRIndex->pmax().val(), pos.val() << ">=" << mRIndex->pmax().val());
|
//CXZ_ASSERT(pos.val() < mRIndex->pmax().val(), pos.val() << ">=" << mRIndex->pmax().val());
|
||||||
//CXZ_ASSERT(mData[pos.val()] != nullptr, "data[" << pos.val() << "] == null");
|
//CXZ_ASSERT(mData[pos.val()] != nullptr, "data[" << pos.val() << "] == null");
|
||||||
//CXZ_ASSERT(pos.next().val() < mIndex->pmax().val(), pos.val() << ">=" << mIndex->pmax().val());
|
//CXZ_ASSERT(pos.next().val() < mIndex->pmax().val(), pos.val() << ">=" << mIndex->pmax().val());
|
||||||
return (mData[pos.val()])[pos.next().val()];
|
if constexpr(is_epos_type<PosT>::value){
|
||||||
|
// PRELIMINARY!!!
|
||||||
|
// discards potential vector entries in pos (only pos.next() is considered)!!!
|
||||||
|
return vreg(mData[pos.val()[0]]+mLOff,pos.next());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return (mData[pos.val()])[mLOff+pos.next().val()];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, class RIndexT, class IndexT>
|
template <typename T, class RIndexT, class IndexT>
|
||||||
constexpr decltype(auto) CROpRoot<T,RIndexT,IndexT>::operator()() const
|
constexpr decltype(auto) CROpRoot<T,RIndexT,IndexT>::operator()() const
|
||||||
{
|
{
|
||||||
//CXZ_ASSERT(mData[0] != nullptr, "data[" << 0 << "] == null");
|
//CXZ_ASSERT(mData[0] != nullptr, "data[" << 0 << "] == null");
|
||||||
return (mData[0])[0];
|
return (mData[0])[mLOff];
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, class RIndexT, class IndexT>
|
template <typename T, class RIndexT, class IndexT>
|
||||||
|
@ -66,7 +74,8 @@ namespace CNORXZ
|
||||||
mLocal(&a.local()),
|
mLocal(&a.local()),
|
||||||
mData(a.buffermap().data()),
|
mData(a.buffermap().data()),
|
||||||
mRIndex(ri),
|
mRIndex(ri),
|
||||||
mIndex(li)
|
mIndex(li),
|
||||||
|
mLOff(mIndex->pos())
|
||||||
{
|
{
|
||||||
CXZ_ASSERT(a.buffermap().size() == ri->lmax().val(),
|
CXZ_ASSERT(a.buffermap().size() == ri->lmax().val(),
|
||||||
"data map not properly initialized: map size = " << a.buffermap().size()
|
"data map not properly initialized: map size = " << a.buffermap().size()
|
||||||
|
@ -106,7 +115,21 @@ namespace CNORXZ
|
||||||
//CXZ_ASSERT(pos.val() < mRIndex->pmax().val(), pos.val() << ">=" << mRIndex->pmax().val());
|
//CXZ_ASSERT(pos.val() < mRIndex->pmax().val(), pos.val() << ">=" << mRIndex->pmax().val());
|
||||||
//CXZ_ASSERT(mData[pos.val()] != nullptr, "data[" << pos.val() << "] == null");
|
//CXZ_ASSERT(mData[pos.val()] != nullptr, "data[" << pos.val() << "] == null");
|
||||||
//CXZ_ASSERT(pos.next().val() < mIndex->pmax().val(), pos.val() << ">=" << mIndex->pmax().val());
|
//CXZ_ASSERT(pos.next().val() < mIndex->pmax().val(), pos.val() << ">=" << mIndex->pmax().val());
|
||||||
return (mData[pos.val()])[pos.next().val()];
|
if constexpr(is_epos_type<PosT>::value){
|
||||||
|
// PRELIMINARY!!!
|
||||||
|
// discards potential vector entries in pos (only pos.next() is considered)!!!
|
||||||
|
if constexpr(pos_type_is_consecutive<PosT>::value){
|
||||||
|
return vreg(mData[pos.val()[0]]+mLOff,pos.next());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// non-consecutive data cannot be directly accessed
|
||||||
|
// so there is no non-const (write) access!
|
||||||
|
return vreg(const_cast<const T*>(mData[pos.val()[0]]+mLOff),pos.next());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return (mData[pos.val()])[mLOff+pos.next().val()];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, class RIndexT, class IndexT>
|
template <typename T, class RIndexT, class IndexT>
|
||||||
|
|
|
@ -41,6 +41,7 @@ namespace CNORXZ
|
||||||
const T* const* mData;
|
const T* const* mData;
|
||||||
Sptr<RIndexT> mRIndex;
|
Sptr<RIndexT> mRIndex;
|
||||||
Sptr<IndexT> mIndex;
|
Sptr<IndexT> mIndex;
|
||||||
|
SizeT mLOff; // local index offset (position)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -80,6 +81,7 @@ namespace CNORXZ
|
||||||
const T* const* mData;
|
const T* const* mData;
|
||||||
Sptr<RIndexT> mRIndex;
|
Sptr<RIndexT> mRIndex;
|
||||||
Sptr<IndexT> mIndex;
|
Sptr<IndexT> mIndex;
|
||||||
|
SizeT mLOff; // local index offset (position)
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T, class RIndexT, class IndexT>
|
template <typename T, class RIndexT, class IndexT>
|
||||||
|
|
Loading…
Reference in a new issue