From d25cbda2fc202503edd8e97ec13959ec6d8e6b40 Mon Sep 17 00:00:00 2001 From: Christian Zimmermann Date: Tue, 20 Dec 2022 17:21:29 +0100 Subject: [PATCH] array_base: operator() and op function --- src/include/array/array_base.cc.h | 64 +++++++++++++++++++++++++------ src/include/array/array_base.h | 27 ++++++++++--- src/include/base/types.h | 50 +++++++++++++++++++++++- 3 files changed, 124 insertions(+), 17 deletions(-) diff --git a/src/include/array/array_base.cc.h b/src/include/array/array_base.cc.h index afb6c92..9fb0657 100644 --- a/src/include/array/array_base.cc.h +++ b/src/include/array/array_base.cc.h @@ -144,7 +144,7 @@ namespace CNORXZ { CXZ_ASSERT(i.lex() < this->size(), "index out of range"); auto beg = this->begin(); - //assertCompatible(i,beg); + //CXZ_ASSERT(false, "IMPLEMENT CHECKS!!"); // check further compatibility of index/range format!!! auto ai = beg + i.lex(); return *ai; @@ -185,14 +185,35 @@ namespace CNORXZ return this->cend(); } - /* template - template - ConstOperationRoot CArrayBase::operator()(const IndexPtr& i) const + template + COpRoot CArrayBase::operator()(const IndexPtr& i) const { - return ConstOperationRoot(); + return COpRoot(*this, std::static_pointer_cast(i)); + } + + template + template + COpRoot CArrayBase::operator()(const LIndex& i) const + { + return COpRoot>(*this, i); + } + + template + template + COpRoot CArrayBase::op(const IndexPtr& i) const + { + CXZ_ASSERT(false, "IMPLEMENT CHECKS!!"); + return COpRoot(*this, std::static_pointer_cast(i)); + } + + template + template + COpRoot CArrayBase::op(const LIndex& i) const + { + CXZ_ASSERT(false, "IMPLEMENT CHECKS!!"); + return COpRoot>(*this, i); } - */ /***************** * ArrayBase * @@ -244,14 +265,35 @@ namespace CNORXZ return iterator(this->data(), this->cend()); } - /* template - template - OperationRoot ArrayBase::operator()(const IndexPtr& i) + template + OpRoot ArrayBase::operator()(const IndexPtr& i) const { - return OperationRoot(); + return OpRoot(*this, std::static_pointer_cast(i)); + } + + template + template + OpRoot ArrayBase::operator()(const LIndex& i) const + { + return OpRoot>(*this, i); + } + + template + template + OpRoot ArrayBase::op(const IndexPtr& i) const + { + CXZ_ASSERT(false, "IMPLEMENT CHECKS!!"); + return OpRoot(*this, std::static_pointer_cast(i)); + } + + template + template + OpRoot ArrayBase::op(const LIndex& i) const + { + CXZ_ASSERT(false, "IMPLEMENT CHECKS!!"); + return OpRoot>(*this, i); } - */ } #endif diff --git a/src/include/array/array_base.h b/src/include/array/array_base.h index 9be12c4..ae552cc 100644 --- a/src/include/array/array_base.h +++ b/src/include/array/array_base.h @@ -9,7 +9,7 @@ #include "base/base.h" #include "aindex.h" -//#include "operation/" +#include "operation/op_types.h" namespace CNORXZ { @@ -55,8 +55,17 @@ namespace CNORXZ virtual bool isView() const = 0; - //template - //ConstOperationRoot operator()(const IndexPtr& i) const; + template + COpRoot operator()(const IndexPtr& i) const; + + template + COpRoot operator()(const LIndex& i) const; + + template + COpRoot op(const IndexPtr& i) const; + + template + COpRoot op(const LIndex& i) const; }; template @@ -93,9 +102,17 @@ namespace CNORXZ virtual iterator begin(); virtual iterator end(); - //template - //OperationRoot operator()(const IndexPtr& i); + template + OpRoot operator()(const IndexPtr& i) const; + template + OpRoot operator()(const LIndex& i) const; + + template + OpRoot op(const IndexPtr& i) const; + + template + OpRoot op(const LIndex& i) const; }; } diff --git a/src/include/base/types.h b/src/include/base/types.h index 2f004dd..8f6a1b8 100644 --- a/src/include/base/types.h +++ b/src/include/base/types.h @@ -209,8 +209,56 @@ namespace CNORXZ // there should be also a static analogue // definition: ranges/lindex.h - template + template class LIndex; + + // definition: array/array_base.h + template + class CArrayBase; + + // definition: array/array_base.h + template + class ArrayBase; + + // definition: array/array.h + template + class MArray; + + // definition: array/slice.h + template + class CSlice; + + // definition: array/slice.h + template + class Slice; + + // definition: operation/op_types.h + template + class COpInterface; + + // definition: operation/op_types.h + template + class OpInterface; + + // definition: operation/op_types.h + template + class COpRoot; + + // definition: operation/op_types.h + template + class OpCont; + + // definition: operation/op_types.h + template + class OpRoot; + + // definition: operation/op_types.h + template + class Operation; + + // definition: operation/op_types.h + template + class Contraction; /********************* * derived types *