diff --git a/src/multi_array.h b/src/multi_array.h index acc8a9b..1435959 100644 --- a/src/multi_array.h +++ b/src/multi_array.h @@ -179,6 +179,12 @@ namespace MultiArrayTools { return MAB::operator()(str...); } + + template + ConstMultiArrayOperationRoot operator()(const NameTypes&... str) const; + + template + ConstMultiArrayOperationRoot operator()(const NameType& name, bool master) const; template MultiArrayOperationRoot operator()(const NameTypes&... str); diff --git a/src/multi_array_operation.cc b/src/multi_array_operation.cc index 3c2bde6..60110b6 100644 --- a/src/multi_array_operation.cc +++ b/src/multi_array_operation.cc @@ -46,6 +46,7 @@ namespace MultiArrayTools for(iref = mArrayRef.beginIndex().pos(); iref != mArrayRef.endIndex(); ++iref){ std::cout << iref.pos() << '\r' << std::flush; get() = in.get(); + //assert(not std::isnan( get() )); } //CHECK; MAOB::mIibPtr->freeLinked(); @@ -90,6 +91,19 @@ namespace MultiArrayTools //mIndex.name(nm); } + template + MultiArrayOperationRoot:: + MultiArrayOperationRoot(const MultiArrayOperationRoot& in) : + MutableMultiArrayOperationBase(), + mArrayRef(in.mArrayRef), + mIndex(mArrayRef.beginIndex()), + mNm(in.mNm) + { + MAOB::mIibPtr = &mIndex; + MAOB::mIibPtr->name(mNm); + //mIndex.name(nm); + } + template MultiArrayOperationRoot& MultiArrayOperationRoot::operator=(const MultiArrayOperationRoot& in) @@ -313,14 +327,20 @@ namespace MultiArrayTools template T& MultiArrayOperationRoot::get() { + //CHECK; //return mArrayRef[mIndex]; + assert(MAOB::mIibPtr == &mIndex); + //VCHECK(mArrayRef[*dynamic_cast(MAOB::mIibPtr)]); return mArrayRef[*dynamic_cast(MAOB::mIibPtr)]; } template const T& MultiArrayOperationRoot::get() const { + //CHECK; //return mArrayRef[mIndex]; + assert(MAOB::mIibPtr == &mIndex); + //VCHECK(mArrayRef[*dynamic_cast(MAOB::mIibPtr)]); return mArrayRef[*dynamic_cast(MAOB::mIibPtr)]; } @@ -408,6 +428,19 @@ namespace MultiArrayTools //mIndex.name(nm); } + template + ConstMultiArrayOperationRoot:: + ConstMultiArrayOperationRoot(const ConstMultiArrayOperationRoot& in) : + MultiArrayOperationBase(), + mArrayRef(in.mArrayRef), + mIndex(mArrayRef.beginIndex()), + mNm(in.mNm) + { + MAOB::mIibPtr = &mIndex; + MAOB::mIibPtr->name(mNm); + //mIndex.name(nm); + } + /* template const ConstMultiArrayOperationRoot& @@ -561,6 +594,8 @@ namespace MultiArrayTools template const T& ConstMultiArrayOperationRoot::get() const { + //CHECK; + assert(MAOB::mIibPtr == &mIndex); return mArrayRef[*dynamic_cast(MAOB::mIibPtr)]; } @@ -683,13 +718,13 @@ namespace MultiArrayTools MultiArrayOperation:: MultiArrayOperation(Operation& op, const MAOps&... args) : mOp(op), - mArgs(std::make_tuple(args...)) {} + mArgs(std::make_tuple(args...)) { /*CHECK;*/ } template MultiArrayOperation:: MultiArrayOperation(const Operation& op, const MAOps&... args) : mOp(op), - mArgs(std::make_tuple(args...)) {} + mArgs(std::make_tuple(args...)) { /*CHECK;*/ } template template @@ -777,9 +812,9 @@ namespace MultiArrayTools template const T& MultiArrayOperation::get() const { + //CHECK; mVal = OperationCall:: template callOperation(mOp, mArgs); - //std::cout << mVal << std::endl; return mVal; } @@ -821,9 +856,6 @@ namespace MultiArrayTools // DON'T link here !! //linkIndicesTo(&mRunIndex); } - - - // !!!!! template template @@ -921,62 +953,14 @@ namespace MultiArrayTools template const T& MultiArrayContraction::get() const { + //CHECK; mOp.reset(); for(mRunIndex.copyPos( mBeginIndex ); mRunIndex.pos() != mEndIndex.pos(); ++mRunIndex){ OperationCall:: template callOperation(mOp, mArgs); - //MAO::mOp(std::get<0>(MAO::mArgs).get() ); } mOp.endOp(); - //std::cout << mOp() << std::endl; return mOp(); } - - /* - template - MultiArrayContraction:: - MultiArrayContraction(const ContractOperation& cop, - const typename Range::IndexType& runIndex, - const MAOps&... mao) : - MultiArrayContraction(cop, mao...), - mBeginIndex(runIndex), mEndIndex(runIndex), - mRunIndex(runIndex) - { - mBeginIndex.setPos(0); - mEndIndex.setPos(mRunIndex.max()); - MAO::linkIndicesTo(&mRunIndex); - } - - template - MultiArrayContraction:: - MultiArrayContraction(const ContractOperation& cop, - const typename Range::IndexType& runIndex, - size_t begin, - size_t end, - const MAOps&... mao) : - MultiArrayContraction(cop, mao...), - mBeginIndex(runIndex), mEndIndex(runIndex), - mRunIndex(runIndex) - { - mBeginIndex.setPos(begin); - mEndIndex.setPos(end); - MAO::linkIndicesTo(&mRunIndex); - } - - - // for the moment simplest case only: - template - const T& MultiArrayContraction::get() const - { - MAO::mOp.reset(); - for(mRunIndex.copyPos( mBeginIndex ); mRunIndex.pos() != mEndIndex.pos(); ++mRunIndex){ - OperationCall:: - template callOperation(MAO::mOp, MAO::mArgs); - //MAO::mOp(std::get<0>(MAO::mArgs).get() ); - } - MAO::mOp.endOp(); - std::cout << MAO::mOp() << std::endl; - return MAO::mOp(); - }*/ } diff --git a/src/multi_array_operation.h b/src/multi_array_operation.h index 16185e1..c09e96b 100644 --- a/src/multi_array_operation.h +++ b/src/multi_array_operation.h @@ -5,6 +5,7 @@ #include #include +#include #include "base_def.h" #include "index_base.h" @@ -55,6 +56,7 @@ namespace MultiArrayTools //typedef decltype(MultiArray().begin()) IndexType; MultiArrayOperationRoot(MutableMultiArrayBase& ma, const Name& nm); + MultiArrayOperationRoot(const MultiArrayOperationRoot& in); MultiArrayOperationRoot& operator=(const MultiArrayOperationRoot& in); MultiArrayOperationRoot& operator=(MultiArrayOperationRoot& in); @@ -175,7 +177,8 @@ namespace MultiArrayTools ConstMultiArrayOperationRoot(const MultiArrayBase& ma, const Name& nm); ConstMultiArrayOperationRoot(const MultiArrayOperationRoot& in); - + ConstMultiArrayOperationRoot(const ConstMultiArrayOperationRoot& in); + template MultiArrayOperation, MAOps...> operator()(const Operation& op, const MAOps&... secs) const; @@ -310,7 +313,7 @@ namespace MultiArrayTools MultiArrayContraction(const ContractOperation& cop, const typename Range::IndexType& runIndex, - const MAOps&... args); + const MAOps&... mao); MultiArrayContraction(const ContractOperation& cop, const typename Range::IndexType& runIndex, @@ -318,7 +321,6 @@ namespace MultiArrayTools size_t end, const MAOps&... mao); - template MultiArrayOperation,MAOps2...> operator()(Operation2& op, const MAOps2&... secs) const; diff --git a/src/unit_test.cc b/src/unit_test.cc index a945534..371b323 100644 --- a/src/unit_test.cc +++ b/src/unit_test.cc @@ -191,7 +191,6 @@ namespace { MultiArray2dAny max; }; - TEST_F(OneDimTest, CorrectExtensions) { EXPECT_EQ(ma.size(), 5);