array_base: operator() and op function

This commit is contained in:
Christian Zimmermann 2022-12-20 17:21:29 +01:00
parent 07242a995e
commit d25cbda2fc
3 changed files with 124 additions and 17 deletions

View file

@ -144,7 +144,7 @@ namespace CNORXZ
{ {
CXZ_ASSERT(i.lex() < this->size(), "index out of range"); CXZ_ASSERT(i.lex() < this->size(), "index out of range");
auto beg = this->begin(); auto beg = this->begin();
//assertCompatible(i,beg); //CXZ_ASSERT(false, "IMPLEMENT CHECKS!!");
// check further compatibility of index/range format!!! // check further compatibility of index/range format!!!
auto ai = beg + i.lex(); auto ai = beg + i.lex();
return *ai; return *ai;
@ -185,14 +185,35 @@ namespace CNORXZ
return this->cend(); return this->cend();
} }
/*
template <typename T> template <typename T>
template <typename I, typename M> template <class I, typename M>
ConstOperationRoot<T,I> CArrayBase<T>::operator()(const IndexPtr<I,M>& i) const COpRoot<T,I> CArrayBase<T>::operator()(const IndexPtr<I,M>& i) const
{ {
return ConstOperationRoot<T,I>(); return COpRoot<T,I>(*this, std::static_pointer_cast<I>(i));
}
template <typename T>
template <class I, SizeT L>
COpRoot<T,I> CArrayBase<T>::operator()(const LIndex<I,L>& i) const
{
return COpRoot<T,LIndex<I,L>>(*this, i);
}
template <typename T>
template <class I, typename M>
COpRoot<T,I> CArrayBase<T>::op(const IndexPtr<I,M>& i) const
{
CXZ_ASSERT(false, "IMPLEMENT CHECKS!!");
return COpRoot<T,I>(*this, std::static_pointer_cast<I>(i));
}
template <typename T>
template <class I, SizeT L>
COpRoot<T,I> CArrayBase<T>::op(const LIndex<I,L>& i) const
{
CXZ_ASSERT(false, "IMPLEMENT CHECKS!!");
return COpRoot<T,LIndex<I,L>>(*this, i);
} }
*/
/***************** /*****************
* ArrayBase * * ArrayBase *
@ -244,14 +265,35 @@ namespace CNORXZ
return iterator(this->data(), this->cend()); return iterator(this->data(), this->cend());
} }
/*
template <typename T> template <typename T>
template <typename I, typename M> template <class I, typename M>
OperationRoot<T,I> ArrayBase<T>::operator()(const IndexPtr<I,M>& i) OpRoot<T,I> ArrayBase<T>::operator()(const IndexPtr<I,M>& i) const
{ {
return OperationRoot<T,I>(); return OpRoot<T,I>(*this, std::static_pointer_cast<I>(i));
}
template <typename T>
template <class I, SizeT L>
OpRoot<T,I> ArrayBase<T>::operator()(const LIndex<I,L>& i) const
{
return OpRoot<T,LIndex<I,L>>(*this, i);
}
template <typename T>
template <class I, typename M>
OpRoot<T,I> ArrayBase<T>::op(const IndexPtr<I,M>& i) const
{
CXZ_ASSERT(false, "IMPLEMENT CHECKS!!");
return OpRoot<T,I>(*this, std::static_pointer_cast<I>(i));
}
template <typename T>
template <class I, SizeT L>
OpRoot<T,I> ArrayBase<T>::op(const LIndex<I,L>& i) const
{
CXZ_ASSERT(false, "IMPLEMENT CHECKS!!");
return OpRoot<T,LIndex<I,L>>(*this, i);
} }
*/
} }
#endif #endif

View file

@ -9,7 +9,7 @@
#include "base/base.h" #include "base/base.h"
#include "aindex.h" #include "aindex.h"
//#include "operation/" #include "operation/op_types.h"
namespace CNORXZ namespace CNORXZ
{ {
@ -55,8 +55,17 @@ namespace CNORXZ
virtual bool isView() const = 0; virtual bool isView() const = 0;
//template <typename I, typename M> template <class I, typename M>
//ConstOperationRoot<T,I> operator()(const IndexPtr<I,M>& i) const; COpRoot<T,I> operator()(const IndexPtr<I,M>& i) const;
template <class I, SizeT L>
COpRoot<T,I> operator()(const LIndex<I,L>& i) const;
template <class I, typename M>
COpRoot<T,I> op(const IndexPtr<I,M>& i) const;
template <class I, SizeT L>
COpRoot<T,I> op(const LIndex<I,L>& i) const;
}; };
template <typename T> template <typename T>
@ -93,9 +102,17 @@ namespace CNORXZ
virtual iterator begin(); virtual iterator begin();
virtual iterator end(); virtual iterator end();
//template <typename I, typename M> template <class I, typename M>
//OperationRoot<T,I> operator()(const IndexPtr<I,M>& i); OpRoot<T,I> operator()(const IndexPtr<I,M>& i) const;
template <class I, SizeT L>
OpRoot<T,I> operator()(const LIndex<I,L>& i) const;
template <class I, typename M>
OpRoot<T,I> op(const IndexPtr<I,M>& i) const;
template <class I, SizeT L>
OpRoot<T,I> op(const LIndex<I,L>& i) const;
}; };
} }

View file

@ -209,9 +209,57 @@ namespace CNORXZ
// there should be also a static analogue // there should be also a static analogue
// definition: ranges/lindex.h // definition: ranges/lindex.h
template <class Index> template <class Index, SizeT L>
class LIndex; class LIndex;
// definition: array/array_base.h
template <typename T>
class CArrayBase;
// definition: array/array_base.h
template <typename T>
class ArrayBase;
// definition: array/array.h
template <typename T>
class MArray;
// definition: array/slice.h
template <typename T>
class CSlice;
// definition: array/slice.h
template <typename T>
class Slice;
// definition: operation/op_types.h
template <class OpT>
class COpInterface;
// definition: operation/op_types.h
template <class OpT>
class OpInterface;
// definition: operation/op_types.h
template <typename T, class IndexT>
class COpRoot;
// definition: operation/op_types.h
template <typename T, class IndexT>
class OpCont;
// definition: operation/op_types.h
template <typename T, class IndexT>
class OpRoot;
// definition: operation/op_types.h
template <class F, class... Ops>
class Operation;
// definition: operation/op_types.h
template <class CXpr>
class Contraction;
/********************* /*********************
* derived types * * derived types *
*********************/ *********************/