From cf724f60eda91fb7c992bf69cb9eeafc8e1577cc Mon Sep 17 00:00:00 2001 From: Christian Zimmermann Date: Tue, 6 Mar 2018 14:35:32 +0100 Subject: [PATCH] md-slice call works (with the restriction, that multi-indices cant be used) --- src/include/pack_num.h | 2 +- src/tests/ma_unit_test.cc | 43 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/src/include/pack_num.h b/src/include/pack_num.h index beacc68..b0b968a 100644 --- a/src/include/pack_num.h +++ b/src/include/pack_num.h @@ -67,7 +67,7 @@ namespace MultiArrayHelper ( index.template getPtr().get() ) ) .val(); std::get(blocks) = tmp; - PackNum::mkSliceBlocks(blocks, index, op, total * tmp); + PackNum::template mkSliceBlocks(blocks, index, op, total * tmp); } }; diff --git a/src/tests/ma_unit_test.cc b/src/tests/ma_unit_test.cc index 92eb8ed..5a009c3 100644 --- a/src/tests/ma_unit_test.cc +++ b/src/tests/ma_unit_test.cc @@ -212,6 +212,49 @@ namespace { EXPECT_EQ( sl2.at('l'), 8.175 ); EXPECT_EQ( sl2.at('f'), 6.408 ); EXPECT_EQ( sl2.at('g'), 4.209 ); + + Slice sl3(sr3ptr, sr1ptr, sr2ptr); + mj->at( mkt('x','a') ); + auto j1 = MAT::getIndex(sr1ptr); + auto j2 = MAT::getIndex(sr2ptr); + (*mj)(j1,j2); + j->at('1'); + sl3.define(j, j1, j2) = ma(mj, j); + + EXPECT_EQ( sl3.at( mkt('1', 'x','a') ), 2.917 ); + EXPECT_EQ( sl3.at( mkt('2', 'x','a') ), 9.436 ); + EXPECT_EQ( sl3.at( mkt('3', 'x','a') ), 0.373 ); + + EXPECT_EQ( sl3.at( mkt('1', 'x','l') ), 7.192 ); + EXPECT_EQ( sl3.at( mkt('2', 'x','l') ), 7.315 ); + EXPECT_EQ( sl3.at( mkt('3', 'x','l') ), 1.536 ); + + EXPECT_EQ( sl3.at( mkt('1', 'x','f') ), 4.892 ); + EXPECT_EQ( sl3.at( mkt('2', 'x','f') ), 0.280 ); + EXPECT_EQ( sl3.at( mkt('3', 'x','f') ), 8.870 ); + + EXPECT_EQ( sl3.at( mkt('1', 'x','g') ), 4.790 ); + EXPECT_EQ( sl3.at( mkt('2', 'x','g') ), 8.215 ); + EXPECT_EQ( sl3.at( mkt('3', 'x','g') ), 5.063 ); + + + EXPECT_EQ( sl3.at( mkt('1', 'y','a') ), 1.530 ); + EXPECT_EQ( sl3.at( mkt('2', 'y','a') ), 3.084 ); + EXPECT_EQ( sl3.at( mkt('3', 'y','a') ), 1.609 ); + + EXPECT_EQ( sl3.at( mkt('1', 'y','l') ), 4.847 ); + EXPECT_EQ( sl3.at( mkt('2', 'y','l') ), 8.175 ); + EXPECT_EQ( sl3.at( mkt('3', 'y','l') ), 0.112 ); + + EXPECT_EQ( sl3.at( mkt('1', 'y','f') ), 6.712 ); + EXPECT_EQ( sl3.at( mkt('2', 'y','f') ), 6.408 ); + EXPECT_EQ( sl3.at( mkt('3', 'y','f') ), 1.959 ); + + EXPECT_EQ( sl3.at( mkt('1', 'y','g') ), 0.331 ); + EXPECT_EQ( sl3.at( mkt('2', 'y','g') ), 4.209 ); + EXPECT_EQ( sl3.at( mkt('3', 'y','g') ), 2.951 ); + + } } // end namespace