From dc436af07de44f7c3bf47289b8311620ee586f6f Mon Sep 17 00:00:00 2001 From: Christian Zimmermann Date: Thu, 23 Mar 2017 09:54:54 +0100 Subject: [PATCH] unit tests work again --- src/multi_array_operation.cc | 41 +++++++++++++++++++++++++++++------- src/multi_array_operation.h | 14 +++++++++--- src/unit_test.cc | 6 +++--- 3 files changed, 47 insertions(+), 14 deletions(-) diff --git a/src/multi_array_operation.cc b/src/multi_array_operation.cc index e5f6ef1..74c34f7 100644 --- a/src/multi_array_operation.cc +++ b/src/multi_array_operation.cc @@ -777,7 +777,7 @@ namespace MultiArrayTools { mVal = OperationCall:: template callOperation(mOp, mArgs); - std::cout << mVal << std::endl; + //std::cout << mVal << std::endl; return mVal; } @@ -788,12 +788,37 @@ namespace MultiArrayTools template MultiArrayContraction:: - MultiArrayContraction(const ContractOperation& op, + MultiArrayContraction(const ContractOperation& cop, const typename Range::IndexType& runIndex, - const MAOps&... args) : - mOp(op), - mArgs(std::make_tuple(args...)) {} + const MAOps&... mao) : + mOp(cop), + mArgs(std::make_tuple(mao...)), + mBeginIndex(runIndex), mEndIndex(runIndex), + mRunIndex(runIndex) + { + mBeginIndex.setPos(0); + mEndIndex.setPos(mRunIndex.max()); + linkIndicesTo(&mRunIndex); + } + template + MultiArrayContraction:: + MultiArrayContraction(const ContractOperation& cop, + const typename Range::IndexType& runIndex, + size_t begin, + size_t end, + const MAOps&... mao) : + mOp(cop), + mArgs(std::make_tuple(mao...)), + mBeginIndex(runIndex), mEndIndex(runIndex), + mRunIndex(runIndex) + { + mBeginIndex.setPos(begin); + mEndIndex.setPos(end); + linkIndicesTo(&mRunIndex); + } + + // !!!!! template @@ -815,8 +840,8 @@ namespace MultiArrayTools } - template - template + template + template MultiArrayContraction,MAOps2...> MultiArrayContraction:: @@ -890,7 +915,7 @@ namespace MultiArrayTools //MAO::mOp(std::get<0>(MAO::mArgs).get() ); } mOp.endOp(); - std::cout << MAO::mOp() << std::endl; + //std::cout << mOp() << std::endl; return mOp(); } diff --git a/src/multi_array_operation.h b/src/multi_array_operation.h index 162bedd..9056f39 100644 --- a/src/multi_array_operation.h +++ b/src/multi_array_operation.h @@ -305,9 +305,17 @@ namespace MultiArrayTools typedef MultiArrayOperationBase MAOB; typedef std::tuple OBT; - - MultiArrayContraction(ContractOperation& op, const MAOps&... secs); - MultiArrayContraction(const ContractOperation& op, const MAOps&... secs); + + MultiArrayContraction(const ContractOperation& cop, + const typename Range::IndexType& runIndex, + const MAOps&... args); + + MultiArrayContraction(const ContractOperation& cop, + const typename Range::IndexType& runIndex, + size_t begin, + size_t end, + const MAOps&... mao); + template MultiArrayOperation,MAOps2...> diff --git a/src/unit_test.cc b/src/unit_test.cc index 8e2b690..a945534 100644 --- a/src/unit_test.cc +++ b/src/unit_test.cc @@ -191,7 +191,7 @@ namespace { MultiArray2dAny max; }; - /* + TEST_F(OneDimTest, CorrectExtensions) { EXPECT_EQ(ma.size(), 5); @@ -510,7 +510,7 @@ namespace { EXPECT_EQ(sl[j(j1 = 2, j2 = 0)], 14); EXPECT_EQ(sl[j(j1 = 2, j2 = 1)], 34); } - */ + TEST_F(ContractionTest, ContractionWorks) { MultiArray2dAny ma2(ra); @@ -542,7 +542,7 @@ namespace { auto i1 = i.template getIndex<0>(); auto i2 = i.template getIndex<1>(); - EXPECT_EQ(ma2[i(i1 = 0, i2 = 0)], -275); + EXPECT_EQ(ma2[i(i1 = 0, i2 = 0)], -165); EXPECT_EQ(ma2[i(i1 = 0, i2 = 1)], 324); EXPECT_EQ(ma2[i(i1 = 1, i2 = 0)], 130);