diff --git a/src/multi_array_operation.cc b/src/multi_array_operation.cc index 5e1c35c..85eccc5 100644 --- a/src/multi_array_operation.cc +++ b/src/multi_array_operation.cc @@ -96,7 +96,7 @@ namespace MultiArrayTools return out; } - void minimizeAppearanceOfType(std::map, std::vector > mp, + void minimizeAppearanceOfType(std::map, std::vector >& mp, BlockType bt) { size_t minNum = getBTNum( mp.begin()->second, bt ); @@ -121,7 +121,7 @@ namespace MultiArrayTools template std::shared_ptr seekBlockIndex(std::shared_ptr ownIdx, - const OperationBase& second) + const OperationBase& second) { std::vector > ivec; seekIndexInst(ownIdx, ivec); @@ -130,10 +130,8 @@ namespace MultiArrayTools for(auto& xx: ivec){ mp[xx] = second.block(xx); } - // seek minimal number of VALUEs => guarantees absence of conflicting blocks minimizeAppearanceOfType(mp, BlockType::VALUE); - // seek mininmal number of SPLITs => maximal vectorization possible minimizeAppearanceOfType(mp, BlockType::SPLIT); @@ -207,7 +205,7 @@ namespace MultiArrayTools block(blockIndex); second.block(blockIndex); - + for(*mIndex = 0; mIndex->pos() != mIndex->max(); mIndex->pp(blockIndex) ){ get() = mSecond.get(); } diff --git a/src/multi_array_operation.h b/src/multi_array_operation.h index 9998fc1..b48b1f8 100644 --- a/src/multi_array_operation.h +++ b/src/multi_array_operation.h @@ -50,7 +50,7 @@ namespace MultiArrayTools size_t getBTNum(const std::vector& mp, BlockType bt); - void minimizeAppearanceOfType(std::map, std::vector > mp, + void minimizeAppearanceOfType(std::map, std::vector >& mp, BlockType bt); template diff --git a/src/op_unit_test.cc b/src/op_unit_test.cc index ef73c6e..644f276 100644 --- a/src/op_unit_test.cc +++ b/src/op_unit_test.cc @@ -165,12 +165,12 @@ namespace { EXPECT_EQ( xround( res.at(mkt(mkt('3','b'),'A')) ), xround(2.911 + 8.870 - 1.470) ); EXPECT_EQ( xround( res.at(mkt(mkt('3','b'),'B')) ), xround(2.911 + 4.790 - 2.210) ); } - /* - TEST_F(OpTest_MDim, ExecOp3) - { - MultiArray res(mr1ptr,sr4ptr); - MultiArray ma1(mr1ptr, v3); - MultiArray ma2(sr2ptr, v1); + + TEST_F(OpTest_MDim, ExecOp3) + { + MultiArray res(mr1ptr,sr4ptr); + MultiArray ma1(mr1ptr, v3); + MultiArray ma2(sr2ptr, v1); MultiArray ma3(sr4ptr, v4); auto si1 = std::dynamic_pointer_cast( sr2ptr->index() ); @@ -181,21 +181,21 @@ namespace { res(mi,si3) = ma1(mi) + ma2(si1) + ma3(si3); - EXPECT_EQ( xround( res.at(mkt(mkt('1','a'),'A')) ), xround(0.353 + 2.917 + 1.470) ) ); - EXPECT_EQ( xround( res.at(mkt(mkt('1','a'),'B')) ), xround(0.353 + 2.917 + 2.210) ) ); - EXPECT_EQ( xround( res.at(mkt(mkt('1','b'),'A')) ), xround(4.005 + 2.917 + 1.470) ) ); - EXPECT_EQ( xround( res.at(mkt(mkt('1','b'),'B')) ), xround(4.005 + 2.917 + 2.210) ) ); + EXPECT_EQ( xround( res.at(mkt(mkt('1','a'),'A')) ), xround(0.353 + 2.917 + 1.470) ); + EXPECT_EQ( xround( res.at(mkt(mkt('1','a'),'B')) ), xround(0.353 + 2.917 + 2.210) ); + EXPECT_EQ( xround( res.at(mkt(mkt('1','b'),'A')) ), xround(4.005 + 2.917 + 1.470) ); + EXPECT_EQ( xround( res.at(mkt(mkt('1','b'),'B')) ), xround(4.005 + 2.917 + 2.210) ); - EXPECT_EQ( xround( res.at(mkt(mkt('2','a'),'A')) ), xround(1.070 + 9.436 + 1.470) ) ); - EXPECT_EQ( xround( res.at(mkt(mkt('2','a'),'B')) ), xround(1.070 + 9.436 + 2.210) ) ); - EXPECT_EQ( xround( res.at(mkt(mkt('2','b'),'A')) ), xround(2.310 + 9.436 + 1.470) ) ); - EXPECT_EQ( xround( res.at(mkt(mkt('2','b'),'B')) ), xround(2.310 + 9.436 + 2.210) ) ); + EXPECT_EQ( xround( res.at(mkt(mkt('2','a'),'A')) ), xround(1.070 + 9.436 + 1.470) ); + EXPECT_EQ( xround( res.at(mkt(mkt('2','a'),'B')) ), xround(1.070 + 9.436 + 2.210) ); + EXPECT_EQ( xround( res.at(mkt(mkt('2','b'),'A')) ), xround(2.310 + 9.436 + 1.470) ); + EXPECT_EQ( xround( res.at(mkt(mkt('2','b'),'B')) ), xround(2.310 + 9.436 + 2.210) ); - EXPECT_EQ( xround( res.at(mkt(mkt('3','a'),'A')) ), xround(9.243 + 0.373 + 1.470) ) ); - EXPECT_EQ( xround( res.at(mkt(mkt('3','a'),'B')) ), xround(9.243 + 0.373 + 2.210) ) ); - EXPECT_EQ( xround( res.at(mkt(mkt('3','b'),'A')) ), xround(2.911 + 0.373 + 1.470) ) ); - EXPECT_EQ( xround( res.at(mkt(mkt('3','b'),'B')) ), xround(2.911 + 0.373 + 2.210) ) ); - }*/ + EXPECT_EQ( xround( res.at(mkt(mkt('3','a'),'A')) ), xround(9.243 + 0.373 + 1.470) ); + EXPECT_EQ( xround( res.at(mkt(mkt('3','a'),'B')) ), xround(9.243 + 0.373 + 2.210) ); + EXPECT_EQ( xround( res.at(mkt(mkt('3','b'),'A')) ), xround(2.911 + 0.373 + 1.470) ); + EXPECT_EQ( xround( res.at(mkt(mkt('3','b'),'B')) ), xround(2.911 + 0.373 + 2.210) ); + } } // anonymous namspace diff --git a/src/pack_num.h b/src/pack_num.h index fadbbdb..2c05c32 100644 --- a/src/pack_num.h +++ b/src/pack_num.h @@ -88,11 +88,12 @@ namespace MultiArrayHelper std::shared_ptr idxPtr) { auto& siPtr = std::get(ip); + //VCHECK(siPtr.id()); if(siPtr.get() == idxPtr.get()){ - return std::get(bs) + PackNum::pp(ip, bs, idxPtr); + return PackNum::pp(ip, bs, idxPtr); } else { - size_t tmp = siPtr->pp(idxPtr); + int tmp = siPtr->pp(idxPtr); if(siPtr->pos() == siPtr->max()){ (*siPtr) = 0; return PackNum::pp(ip, bs, idxPtr) - siPtr->max() + 1; @@ -298,7 +299,8 @@ namespace MultiArrayHelper return std::get<0>(bs); } else { - return siPtr->pp(idxPtr) * std::get<1>(bs); + int tmp = siPtr->pp(idxPtr); + return tmp * std::get<1>(bs); } }