md-slice call works (with the restriction, that multi-indices cant be used)

This commit is contained in:
Christian Zimmermann 2018-03-06 14:35:32 +01:00
parent fb6c5c47ae
commit cf724f60ed
2 changed files with 44 additions and 1 deletions

View file

@ -67,7 +67,7 @@ namespace MultiArrayHelper
( index.template getPtr<N>().get() ) ) ( index.template getPtr<N>().get() ) )
.val(); .val();
std::get<N+1>(blocks) = tmp; std::get<N+1>(blocks) = tmp;
PackNum<N-1>::mkSliceBlocks(blocks, index, op, total * tmp); PackNum<N-1>::template mkSliceBlocks<T,Op,SRanges...>(blocks, index, op, total * tmp);
} }
}; };

View file

@ -212,6 +212,49 @@ namespace {
EXPECT_EQ( sl2.at('l'), 8.175 ); EXPECT_EQ( sl2.at('l'), 8.175 );
EXPECT_EQ( sl2.at('f'), 6.408 ); EXPECT_EQ( sl2.at('f'), 6.408 );
EXPECT_EQ( sl2.at('g'), 4.209 ); EXPECT_EQ( sl2.at('g'), 4.209 );
Slice<double,SRange,SRange,SRange> 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 } // end namespace