more doxy comments + WIP: index member function formatIsTrivial
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Christian Zimmermann 2023-11-05 22:20:12 +01:00
parent 7487929bfc
commit be44541135
23 changed files with 332 additions and 88 deletions

View file

@ -18,9 +18,9 @@
namespace CNORXZ namespace CNORXZ
{ {
/****************** /*=======================================================+
* CArrayBase * | Implementations for CArrayBase member functions |
******************/ +=======================================================*/
template <typename T> template <typename T>
CArrayBase<T>::CArrayBase(const RangePtr& range) : CArrayBase<T>::CArrayBase(const RangePtr& range) :
@ -31,6 +31,11 @@ namespace CNORXZ
template <typename I, typename M> template <typename I, typename M>
const T& CArrayBase<T>::operator[](const IndexInterface<I,M>& i) const const T& CArrayBase<T>::operator[](const IndexInterface<I,M>& i) const
{ {
/*
TODO: check if container format is trivial:
if yes, just return data[i.lex()], in case of at() check extensions
if not, do what is done now
*/
auto ai = itLex(i); auto ai = itLex(i);
return *ai; return *ai;
} }
@ -111,6 +116,13 @@ namespace CNORXZ
template <class Index> template <class Index>
COpRoot<T,Index> CArrayBase<T>::operator()(const Sptr<Index>& i) const COpRoot<T,Index> CArrayBase<T>::operator()(const Sptr<Index>& i) const
{ {
/*
TODO: check if container format is trivial
if yes, assert that index format is trivial and has correct extensions
if not, check if index format is trivial
- if yes: try to apply container format
- if not: check if format is compatible
*/
this->checkFormatCompatibility(*i); this->checkFormatCompatibility(*i);
return coproot(*this, i); return coproot(*this, i);
} }
@ -132,9 +144,9 @@ namespace CNORXZ
return coproot(*this, i); return coproot(*this, i);
} }
/****************************** /*=================================================================+
* CArrayBase (protected) * | Implementations for protected CArrayBase member functions |
******************************/ +=================================================================*/
template <typename T> template <typename T>
template <class Acc> template <class Acc>
@ -185,9 +197,9 @@ namespace CNORXZ
} }
} }
/***************** /*======================================================+
* ArrayBase * | Implementations for ArrayBase member functions |
*****************/ +======================================================*/
template <typename T> template <typename T>
ArrayBase<T>::ArrayBase(const RangePtr& range) : ArrayBase<T>::ArrayBase(const RangePtr& range) :
@ -287,9 +299,9 @@ namespace CNORXZ
return oproot(*this, i); return oproot(*this, i);
} }
/***************************** /*================================================================+
* ArrayBase (protected) * | Implementations for protected ArrayBase member functions |
*****************************/ +================================================================*/
template <typename T> template <typename T>
template <class Acc> template <class Acc>

View file

@ -24,75 +24,175 @@
namespace CNORXZ namespace CNORXZ
{ {
/** ****
Abstract container base class
only read access to the data
@tparam T data type
*/
template <typename T> template <typename T>
class CArrayBase class CArrayBase
{ {
public: public:
typedef AIndex<T> const_iterator; typedef AIndex<T> const_iterator; /** const iterator type */
DEFAULT_MEMBERS(CArrayBase); /**< default constructors and assignments */
/** construct container on a range
@param range
*/
CArrayBase(const RangePtr& range); CArrayBase(const RangePtr& range);
DEFAULT_MEMBERS(CArrayBase);
/** default destructor */
virtual ~CArrayBase() = default; virtual ~CArrayBase() = default;
/** const data element access
@tparam I index type
@tparam M meta data type
@param i index
*/
template <typename I, typename M> template <typename I, typename M>
const T& operator[](const IndexInterface<I,M>& i) const; const T& operator[](const IndexInterface<I,M>& i) const;
/** const data element access
performs compatibility checks
@tparam I index type
@tparam M meta data type
@param i index
*/
template <typename I, typename M> template <typename I, typename M>
const T& at(const IndexInterface<I,M>& i) const; const T& at(const IndexInterface<I,M>& i) const;
/** const data element access
@tparam I index type
@tparam M meta data type
@param pack static index pack
*/
template <class... Indices> template <class... Indices>
const T& operator[](const SPack<Indices...>& pack) const; const T& operator[](const SPack<Indices...>& pack) const;
/** const data element access
performs compatibility checks
@tparam I index type
@tparam M meta data type
@param i static index pack
*/
template <class... Indices> template <class... Indices>
const T& at(const SPack<Indices...>& pack) const; const T& at(const SPack<Indices...>& pack) const;
/** const data element access
@param pack index pack
*/
const T& operator[](const DPack& pack) const; const T& operator[](const DPack& pack) const;
/** const data element access
performs compatibility checks
@param i index pack
*/
const T& at(const DPack& pack) const; const T& at(const DPack& pack) const;
/** create hypercubic slice from this container
@tparam I type of index used to indicate slice edges
@tparam M index meta type
@param begin begin edge
@param end end edge
*/
template <typename I, typename M> template <typename I, typename M>
Sptr<CArrayBase<T>> sl(const IndexInterface<I,M>& begin, Sptr<CArrayBase<T>> sl(const IndexInterface<I,M>& begin,
const IndexInterface<I,M>& end) const; const IndexInterface<I,M>& end) const;
/** create operation on this container
@tparam Index type of operation index
@param i operation index
*/
template <class Index> template <class Index>
COpRoot<T,Index> operator()(const Sptr<Index>& i) const; COpRoot<T,Index> operator()(const Sptr<Index>& i) const;
/** create operation on this container
@tparam Indices types of operation indices
@param pack pack of operation index
*/
template <class... Indices> template <class... Indices>
inline decltype(auto) operator()(const SPack<Indices...>& pack) const; inline decltype(auto) operator()(const SPack<Indices...>& pack) const;
/** create operation on this container
@param pack pack of operation index
*/
inline decltype(auto) operator()(const DPack& pack) const; inline decltype(auto) operator()(const DPack& pack) const;
/** get pointer to container data */
virtual const T* data() const = 0; virtual const T* data() const = 0;
/** get number of elements in the container */
virtual SizeT size() const; virtual SizeT size() const;
/** get container range */
virtual RangePtr range() const; virtual RangePtr range() const;
/** get index pointing to first position */
virtual const_iterator begin() const; virtual const_iterator begin() const;
/** get index pointing to position after last position */
virtual const_iterator end() const; virtual const_iterator end() const;
/** get index pointing to first position */
virtual const_iterator cbegin() const = 0; virtual const_iterator cbegin() const = 0;
/** get index pointing to position after last position */
virtual const_iterator cend() const = 0; virtual const_iterator cend() const = 0;
/** check if container views the data, i.e. it does not own it */
virtual bool isView() const = 0; virtual bool isView() const = 0;
protected: protected:
RangePtr mRange; RangePtr mRange; /**< the container range */
/** Get valid data index.
Create well-formated index from index pack (unformatted)
or index using trivial format.
@tparam Acc index type or index pack type
@param acc index or index pack
*/
template <class Acc> template <class Acc>
const_iterator itLex(const Acc& acc) const; const_iterator itLex(const Acc& acc) const;
/** Get valid data index.
Create well-formated index from index pack (unformatted)
or index using trivial format.
Perform compatibility checks.
@tparam Acc index type or index pack type
@param acc index or index pack
*/
template <class Acc> template <class Acc>
const_iterator itLexSave(const Acc& acc) const; const_iterator itLexSave(const Acc& acc) const;
/** Perform compatibility checks
@tparam Acc index type or index pack type
@param acc index or index pack.
*/
template <class Acc> template <class Acc>
void checkFormatCompatibility(const Acc& acc) const; void checkFormatCompatibility(const Acc& acc) const;
/** check if format is trivial
@return true is container is data owning array, else return
result of the corresponding container index
*/
virtual bool formatIsTrivial() const = 0;
}; };
/** ****
Abstract container base class
read and write access to the data
@tparam T data type
*/
template <typename T> template <typename T>
class ArrayBase : public CArrayBase<T> class ArrayBase : public CArrayBase<T>
{ {
public: public:
typedef CArrayBase<T> CAB; typedef CArrayBase<T> CAB;
typedef typename CAB::const_iterator const_iterator; typedef typename CAB::const_iterator const_iterator; /**< constant iterator type */
typedef BIndex<T> iterator; typedef BIndex<T> iterator; /**< read/write iterator type */
using CAB::operator[]; using CAB::operator[];
using CAB::operator(); using CAB::operator();
@ -103,48 +203,85 @@ namespace CNORXZ
using CAB::cbegin; using CAB::cbegin;
using CAB::cend; using CAB::cend;
using CAB::sl; using CAB::sl;
//using CAB::operator();
DEFAULT_MEMBERS(ArrayBase); /**< default constructors and assignments */
/** construct a container on a range
*/
ArrayBase(const RangePtr& range); ArrayBase(const RangePtr& range);
DEFAULT_MEMBERS(ArrayBase);
/** @copydoc CArrayBase::operator[]()
*/
template <typename I, typename M> template <typename I, typename M>
T& operator[](const IndexInterface<I,M>& i); T& operator[](const IndexInterface<I,M>& i);
/** @copydoc CArrayBase::at()
*/
template <typename I, typename M> template <typename I, typename M>
T& at(const IndexInterface<I,M>& i); T& at(const IndexInterface<I,M>& i);
/** @copydoc CArrayBase::operator[]()
*/
template <class... Indices> template <class... Indices>
T& operator[](const SPack<Indices...>& pack); T& operator[](const SPack<Indices...>& pack);
/** @copydoc CArrayBase::at()
*/
template <class... Indices> template <class... Indices>
T& at(const SPack<Indices...>& pack); T& at(const SPack<Indices...>& pack);
/** @copydoc CArrayBase::operator[]()
*/
T& operator[](const DPack& pack); T& operator[](const DPack& pack);
/** @copydoc CArrayBase::at()
*/
T& at(const DPack& pack); T& at(const DPack& pack);
/** @copydoc CArrayBase::operator()()
*/
template <class Index> template <class Index>
OpRoot<T,Index> operator()(const Sptr<Index>& i); OpRoot<T,Index> operator()(const Sptr<Index>& i);
/** @copydoc CArrayBase::operator()()
*/
template <class... Indices> template <class... Indices>
inline decltype(auto) operator()(const SPack<Indices...>& pack); inline decltype(auto) operator()(const SPack<Indices...>& pack);
/** @copydoc CArrayBase::operator()()
*/
inline decltype(auto) operator()(const DPack& pack); inline decltype(auto) operator()(const DPack& pack);
/** @copydoc CArrayBase::sl()
*/
template <typename I, typename M> template <typename I, typename M>
Sptr<ArrayBase<T>> sl(const IndexInterface<I,M>& begin, Sptr<ArrayBase<T>> sl(const IndexInterface<I,M>& begin,
const IndexInterface<I,M>& end); const IndexInterface<I,M>& end);
/** @copydoc CArrayBase::data()
read/write access
*/
virtual T* data() = 0; virtual T* data() = 0;
/** @copydoc CArrayBase::begin()
read/write access
*/
virtual iterator begin(); virtual iterator begin();
/** @copydoc CArrayBase::end()
read/write access
*/
virtual iterator end(); virtual iterator end();
protected: protected:
/** @copydoc CArrayBase::itLex()
*/
template <class Acc> template <class Acc>
iterator itLex(const Acc& acc); iterator itLex(const Acc& acc);
/** @copydoc CArrayBase::itLexSave()
*/
template <class Acc> template <class Acc>
iterator itLexSave(const Acc& acc); iterator itLexSave(const Acc& acc);
}; };

View file

@ -17,9 +17,9 @@
namespace CNORXZ namespace CNORXZ
{ {
/**************** /*=======================================================+
* MArray * | Implementation of MArray public member functions |
***************/ +=======================================================*/
template <typename T> template <typename T>
MArray<T>::MArray(const RangePtr& range) : MArray<T>::MArray(const RangePtr& range) :
@ -92,6 +92,15 @@ namespace CNORXZ
return false; return false;
} }
/*==========================================================+
| Implementation of MArray protected member functions |
+==========================================================*/
template <typename T>
bool MArray<T>::formatIsTrivial() const
{
return true;
}
} }
#endif #endif

View file

@ -43,6 +43,9 @@ namespace CNORXZ
SERIALIZATION_FUNCTIONS; SERIALIZATION_FUNCTIONS;
protected:
virtual bool formatIsTrivial() const override final;
private: private:
Vector<T> mCont; Vector<T> mCont;
}; };

View file

@ -17,9 +17,9 @@
namespace CNORXZ namespace CNORXZ
{ {
/************** /*========================================================+
* CSlice * | Implementation of public CSlice member functions |
**************/ +========================================================*/
template <typename T> template <typename T>
CSlice<T>::CSlice(const RangePtr& range, const CArrayBase<T>* parent, CSlice<T>::CSlice(const RangePtr& range, const CArrayBase<T>* parent,
@ -54,9 +54,19 @@ namespace CNORXZ
return true; return true;
} }
/************* /*===========================================================+
* Slice * | Implementation of protected CSlice member functions |
*************/ +===========================================================*/
template <typename T>
bool CSlice<T>::formatIsTrivial() const
{
return cbegin().formatIsTrivial();
}
/*=======================================================+
| Implementation of public Slice member functions |
+=======================================================*/
template <typename T> template <typename T>
Slice<T>::Slice(const RangePtr& range, ArrayBase<T>* parent, Slice<T>::Slice(const RangePtr& range, ArrayBase<T>* parent,
@ -96,6 +106,16 @@ namespace CNORXZ
{ {
return true; return true;
} }
/*==========================================================+
| Implementation of protected Slice member functions |
+==========================================================*/
template <typename T>
bool Slice<T>::formatIsTrivial() const
{
return cbegin().formatIsTrivial();
}
} }
#endif #endif

View file

@ -18,6 +18,12 @@
namespace CNORXZ namespace CNORXZ
{ {
/** ****
constant and possibly partial view on the data
of another container
@tparam T data type
*/
template <typename T> template <typename T>
class CSlice : public CArrayBase<T> class CSlice : public CArrayBase<T>
{ {
@ -25,13 +31,15 @@ namespace CNORXZ
typedef CArrayBase<T> AB; typedef CArrayBase<T> AB;
typedef typename AB::const_iterator const_iterator; typedef typename AB::const_iterator const_iterator;
protected: DEFAULT_MEMBERS(CSlice); /**< default constructors and assignments */
const CArrayBase<T>* mCParent = nullptr;
YFormat mBlockSizes;
SizeT mOff = 0;
public: /** create slice from an array
DEFAULT_MEMBERS(CSlice);
@param range the slice's container range
@param parent the original container
@param blockSizes the format of the slice
@param off the initial pointer position w.r.t. the original initial position
*/
CSlice(const RangePtr& range, const CArrayBase<T>* parent, CSlice(const RangePtr& range, const CArrayBase<T>* parent,
const YFormat& blockSizes, SizeT off); const YFormat& blockSizes, SizeT off);
@ -39,23 +47,39 @@ namespace CNORXZ
virtual const_iterator cbegin() const override; virtual const_iterator cbegin() const override;
virtual const_iterator cend() const override; virtual const_iterator cend() const override;
virtual bool isView() const override final; virtual bool isView() const override final;
protected:
virtual bool formatIsTrivial() const override final;
const CArrayBase<T>* mCParent = nullptr; /**< pointer to the original container */
YFormat mBlockSizes; /**< the format */
SizeT mOff = 0; /** pointer offset w.r.t. the original pointer */
}; };
/** ****
possibly partial view on the data
of another container
@tparam T data type
*/
template <typename T> template <typename T>
class Slice : public ArrayBase<T> class Slice : public ArrayBase<T>
{ {
public: public:
typedef CArrayBase<T> AB; typedef CArrayBase<T> AB;
//typedef CSlice<T> CS;
typedef typename AB::const_iterator const_iterator; typedef typename AB::const_iterator const_iterator;
private: DEFAULT_MEMBERS(Slice); /**< default constructors and assignments */
ArrayBase<T>* mParent = nullptr;
YFormat mBlockSizes;
SizeT mOff = 0;
public: /** create slice from an array
DEFAULT_MEMBERS(Slice);
@param range the slice's container range
@param parent the original container
@param blockSizes the format of the slice
@param off the initial pointer position w.r.t. the original initial position
*/
Slice(const RangePtr& range, ArrayBase<T>* parent, Slice(const RangePtr& range, ArrayBase<T>* parent,
const YFormat& blockSizes, SizeT off); const YFormat& blockSizes, SizeT off);
@ -64,6 +88,15 @@ namespace CNORXZ
virtual const_iterator cbegin() const override; virtual const_iterator cbegin() const override;
virtual const_iterator cend() const override; virtual const_iterator cend() const override;
virtual bool isView() const override final; virtual bool isView() const override final;
protected:
virtual bool formatIsTrivial() const override final;
private:
ArrayBase<T>* mParent = nullptr;
YFormat mBlockSizes;
SizeT mOff = 0;
}; };
} }

View file

@ -111,6 +111,9 @@ namespace CNORXZ
template <class Xpr, class F = NoF> template <class Xpr, class F = NoF>
decltype(auto) ifor(const Xpr& xpr, F&& f) const; decltype(auto) ifor(const Xpr& xpr, F&& f) const;
/** @copydoc IndexInterface::formatIsTrivial() */
bool formatIsTrivial() const;
private: private:
Sptr<RangeType> mRangePtr; Sptr<RangeType> mRangePtr;
}; };

View file

@ -73,6 +73,9 @@ namespace CNORXZ
const XIndexPtr& xptr() const; const XIndexPtr& xptr() const;
/** @copydoc IndexInterface::formatIsTrivial() */
bool formatIsTrivial() const;
private: private:
XIndexPtr mI; XIndexPtr mI;
}; };

View file

@ -190,11 +190,14 @@ namespace CNORXZ
decltype(auto) ifor(const Xpr& xpr, F&& f) const decltype(auto) ifor(const Xpr& xpr, F&& f) const
{ return THIS().ifor(xpr,std::forward<F>(f)); } { return THIS().ifor(xpr,std::forward<F>(f)); }
/** check is format is trivial */
bool formatIsTrivial() const { return THIS().formatIsTrivial(); }
protected: protected:
SizeT mPos = 0; /**< the memory position */ SizeT mPos = 0; /**< the memory position */
private: private:
friend I; // why not protected???!!! friend I; // not protected; I should really be something that is derived from IndexInterface
// NO DEFAULT CONSTRUCTORS/ASSIGNMENTS! // NO DEFAULT CONSTRUCTORS/ASSIGNMENTS!
IndexInterface(); IndexInterface();

View file

@ -448,6 +448,13 @@ namespace CNORXZ
return mkIFor<0>(xpr, std::forward<F>(f)); return mkIFor<0>(xpr, std::forward<F>(f));
} }
template <class FormatT, class... Indices>
bool GMIndex<FormatT,Indices...>::formatIsTrivial() const
{
CXZ_ERROR("IMPLEMENT!!!");
return true;
}
template <class FormatT, class... Indices> template <class FormatT, class... Indices>
GMIndex<FormatT,Indices...>& GMIndex<FormatT,Indices...>::operator()(const Sptr<MIndex<Indices...>>& mi) GMIndex<FormatT,Indices...>& GMIndex<FormatT,Indices...>::operator()(const Sptr<MIndex<Indices...>>& mi)
{ {

View file

@ -93,6 +93,9 @@ namespace CNORXZ
auto deepFormat() const; auto deepFormat() const;
GMIndex& setFormat(const FormatT& bs); GMIndex& setFormat(const FormatT& bs);
/** @copydoc IndexInterface::formatIsTrivial() */
bool formatIsTrivial() const;
private: private:
template <SizeT... Is> template <SizeT... Is>
static constexpr decltype(auto) mkLexFormat(const SPack<Indices...>& ipack, Isq<Is...> is); static constexpr decltype(auto) mkLexFormat(const SPack<Indices...>& ipack, Isq<Is...> is);

View file

@ -195,25 +195,6 @@ namespace CNORXZ
return mOrig->xpr(mOrig); return mOrig->xpr(mOrig);
} }
template <class IndexT>
template <class I>
decltype(auto) PIndex<IndexT>::reformat(const Sptr<I>& ind) const
{
return ind;
}
template <class IndexT>
template <class I>
decltype(auto) PIndex<IndexT>::slice(const Sptr<I>& ind) const
{
if(ind != nullptr){
if(ind->dim() != 0){
return Sptr<PIndex<IndexT>>();
}
}
return std::make_shared<PIndex<IndexT>>(*this);
}
template <class IndexT> template <class IndexT>
template <class Xpr, class F> template <class Xpr, class F>
decltype(auto) PIndex<IndexT>::ifor(const Xpr& xpr, F&& f) const decltype(auto) PIndex<IndexT>::ifor(const Xpr& xpr, F&& f) const
@ -222,6 +203,12 @@ namespace CNORXZ
mRangePtr->parts().data(), xpr, std::forward<F>(f)); mRangePtr->parts().data(), xpr, std::forward<F>(f));
} }
template <class IndexT>
bool PIndex<IndexT>::formatIsTrivial() const
{
return mOrig->formatIsTrivial();
}
template <class IndexT> template <class IndexT>
PIndex<IndexT>& PIndex<IndexT>::operator()() PIndex<IndexT>& PIndex<IndexT>::operator()()
{ {

View file

@ -61,12 +61,6 @@ namespace CNORXZ
PIndex& at(const MetaType& metaPos); PIndex& at(const MetaType& metaPos);
decltype(auto) xpr(const Sptr<PIndex<IndexT>>& _this) const; decltype(auto) xpr(const Sptr<PIndex<IndexT>>& _this) const;
template <class I>
decltype(auto) reformat(const Sptr<I>& ind) const;
template <class I>
decltype(auto) slice(const Sptr<I>& ind) const;
template <class Xpr, class F> template <class Xpr, class F>
decltype(auto) ifor(const Xpr& xpr, F&& f) const; decltype(auto) ifor(const Xpr& xpr, F&& f) const;
@ -74,6 +68,9 @@ namespace CNORXZ
PIndex& operator()(const Sptr<IndexT>& i); PIndex& operator()(const Sptr<IndexT>& i);
const Sptr<IndexT>& orig() const; const Sptr<IndexT>& orig() const;
/** @copydoc IndexInterface::formatIsTrivial() */
bool formatIsTrivial() const;
private: private:
Sptr<RangeType> mRangePtr; Sptr<RangeType> mRangePtr;
Sptr<IndexT> mOrig; Sptr<IndexT> mOrig;

View file

@ -176,26 +176,7 @@ namespace CNORXZ
{ {
return 1; return 1;
} }
/*
template <typename MetaT, SizeT S>
template <class Index>
decltype(auto) SIndex<MetaT,S>::formatFrom(const Index& ind) const
{
return *this;
}
template <typename MetaT, SizeT S>
template <class Index>
decltype(auto) SIndex<MetaT,S>::slice(const Sptr<Index>& ind) const
{
if(ind != nullptr){
if(ind->dim() != 0) {
return Sptr<SIndex<MetaType,S>>();
}
}
return std::make_shared<SIndex<MetaType,S>>(*this);
}
*/
template <typename MetaT, SizeT S> template <typename MetaT, SizeT S>
template <class Xpr, class F> template <class Xpr, class F>
decltype(auto) SIndex<MetaT,S>::ifor(const Xpr& xpr, F&& f) const decltype(auto) SIndex<MetaT,S>::ifor(const Xpr& xpr, F&& f) const
@ -203,6 +184,12 @@ namespace CNORXZ
return SFor<S,0,Xpr,F>(this->id(), xpr, std::forward<F>(f)); return SFor<S,0,Xpr,F>(this->id(), xpr, std::forward<F>(f));
} }
template <typename MetaT, SizeT S>
bool SIndex<MetaT,S>::formatIsTrivial() const
{
return true;
}
template <typename MetaType, SizeT S, class I1> template <typename MetaType, SizeT S, class I1>
decltype(auto) operator*(const Sptr<SIndex<MetaType,S>>& a, const Sptr<I1>& b) decltype(auto) operator*(const Sptr<SIndex<MetaType,S>>& a, const Sptr<I1>& b)
{ {

View file

@ -65,6 +65,9 @@ namespace CNORXZ
template <class Xpr, class F> template <class Xpr, class F>
decltype(auto) ifor(const Xpr& xpr, F&& f) const; decltype(auto) ifor(const Xpr& xpr, F&& f) const;
/** @copydoc IndexInterface::formatIsTrivial() */
bool formatIsTrivial() const;
private: private:
Sptr<RangeType> mRangePtr; Sptr<RangeType> mRangePtr;
const MetaT* mMetaPtr; const MetaT* mMetaPtr;

View file

@ -194,6 +194,12 @@ namespace CNORXZ
return For<0,Xpr,F>(this->pmax().val(), this->id(), xpr, std::forward<F>(f)); return For<0,Xpr,F>(this->pmax().val(), this->id(), xpr, std::forward<F>(f));
} }
template <typename MetaT>
bool UIndex<MetaT>::formatIsTrivial() const
{
return true;
}
template <typename MetaT, class I1> template <typename MetaT, class I1>
decltype(auto) operator*(const Sptr<UIndex<MetaT>>& a, const Sptr<I1>& b) decltype(auto) operator*(const Sptr<UIndex<MetaT>>& a, const Sptr<I1>& b)
{ {

View file

@ -70,6 +70,9 @@ namespace CNORXZ
template <class Xpr, class F> template <class Xpr, class F>
decltype(auto) ifor(const Xpr& xpr, F&& f) const; decltype(auto) ifor(const Xpr& xpr, F&& f) const;
/** @copydoc IndexInterface::formatIsTrivial() */
bool formatIsTrivial() const;
private: private:
Sptr<RangeType> mRangePtr; Sptr<RangeType> mRangePtr;
const MetaT* mMetaPtr; const MetaT* mMetaPtr;

View file

@ -191,6 +191,12 @@ namespace CNORXZ
return DXpr<SizeT>(mI->ifor(xpr, std::forward<std::function<SizeT(SizeT,SizeT)>>(f))); return DXpr<SizeT>(mI->ifor(xpr, std::forward<std::function<SizeT(SizeT,SizeT)>>(f)));
} }
template <class Index, typename Meta>
bool XIndex<Index,Meta>::formatIsTrivial() const
{
return mI->formatIsTrivial();
}
template <class Index, typename Meta> template <class Index, typename Meta>
Index& XIndex<Index,Meta>::get() Index& XIndex<Index,Meta>::get()
{ {

View file

@ -61,6 +61,7 @@ namespace CNORXZ
virtual DXpr<SizeT> ifor(const DXpr<SizeT>& xpr, virtual DXpr<SizeT> ifor(const DXpr<SizeT>& xpr,
std::function<SizeT(SizeT,SizeT)>&& f) const = 0; std::function<SizeT(SizeT,SizeT)>&& f) const = 0;
virtual bool formatIsTrivial() const = 0;
}; };
//Sptr<XIndexBase>& operator++(Sptr<XIndexBase>& i); //Sptr<XIndexBase>& operator++(Sptr<XIndexBase>& i);
@ -114,6 +115,8 @@ namespace CNORXZ
virtual DXpr<SizeT> ifor(const DXpr<SizeT>& xpr, virtual DXpr<SizeT> ifor(const DXpr<SizeT>& xpr,
std::function<SizeT(SizeT,SizeT)>&& f) const override final; std::function<SizeT(SizeT,SizeT)>&& f) const override final;
virtual bool formatIsTrivial() const override final;
Index& get(); Index& get();
const Index& get() const; const Index& get() const;

View file

@ -84,6 +84,9 @@ namespace CNORXZ
const YFormat& lexFormat() const; const YFormat& lexFormat() const;
YIndex& setFormat(const YFormat& bs); YIndex& setFormat(const YFormat& bs);
/** @copydoc IndexInterface::formatIsTrivial() */
bool formatIsTrivial() const;
private: private:
inline Vector<SizeT> mkFormat() const; inline Vector<SizeT> mkFormat() const;
inline Vector<SizeT> mkLexFormat() const; inline Vector<SizeT> mkLexFormat() const;

View file

@ -139,6 +139,11 @@ namespace CNORXZ
return 1; return 1;
} }
bool CIndex::formatIsTrivial() const
{
return true;
}
/*============================================================+ /*============================================================+
| Implementations of member functions of CRangeFactory | | Implementations of member functions of CRangeFactory |
+============================================================*/ +============================================================*/

View file

@ -182,6 +182,11 @@ namespace CNORXZ
return mI->deepFormat(); return mI->deepFormat();
} }
bool DIndex::formatIsTrivial() const
{
return true;
}
DXpr<SizeT> DIndex::ifor(const DXpr<SizeT>& xpr, std::function<SizeT(SizeT,SizeT)>&& f) const DXpr<SizeT> DIndex::ifor(const DXpr<SizeT>& xpr, std::function<SizeT(SizeT,SizeT)>&& f) const
{ {
return DXpr<SizeT>(mI->ifor(xpr, std::forward<std::function<SizeT(SizeT,SizeT)>>(f)) ); return DXpr<SizeT>(mI->ifor(xpr, std::forward<std::function<SizeT(SizeT,SizeT)>>(f)) );

View file

@ -401,6 +401,12 @@ namespace CNORXZ
return o; return o;
} }
bool YIndex::formatIsTrivial() const
{
CXZ_ERROR("IMPLEMENT!!!");
return true;
}
const YFormat& YIndex::format() const const YFormat& YIndex::format() const
{ {
return mFormat; return mFormat;