more tests on index multiplication + corresponding fixes
This commit is contained in:
parent
38e011c979
commit
9210f59d39
3 changed files with 23 additions and 15 deletions
|
@ -16,7 +16,8 @@ namespace CNORXZ
|
|||
Isq<Is...> is)
|
||||
{
|
||||
static_assert(sizeof...(Is) == sizeof...(Indices), "inconsistent index sequence");
|
||||
return MIndex<Indices...,I>( std::get<Is>(a.pack())..., b.THIS() );
|
||||
return MIndex<Indices...,I>( std::get<Is>(a.pack())...,
|
||||
std::make_shared<I>(b.THIS()) );
|
||||
}
|
||||
|
||||
template <class BlockT, class... Indices, class I, typename Meta, SizeT... Js>
|
||||
|
@ -25,7 +26,8 @@ namespace CNORXZ
|
|||
Isq<Js...> js)
|
||||
{
|
||||
static_assert(sizeof...(Js) == sizeof...(Indices), "inconsistent index sequence");
|
||||
return MIndex<Indices...,I>( a.THIS(), std::get<Js>(b.pack())... );
|
||||
return MIndex<Indices...,I>( std::make_shared<I>(a.THIS()),
|
||||
std::get<Js>(b.pack())... );
|
||||
}
|
||||
|
||||
template <class BlockT1, class... Indices1, class BlockT2, class... Indices2,
|
||||
|
@ -83,20 +85,24 @@ namespace CNORXZ
|
|||
const IndexInterface<I2,Meta2>& b)
|
||||
{
|
||||
// special operations for DIndex / YIndex
|
||||
if constexpr(index_dim<I1>::value == 1){
|
||||
if constexpr(index_dim<I2>::value == 1){
|
||||
constexpr SizeT I1D = index_dim<I1>::value;
|
||||
constexpr SizeT I2D = index_dim<I2>::value;
|
||||
if constexpr(I1D == 1){
|
||||
if constexpr(I2D == 1){
|
||||
return MIndex<I1,I2>(a.THIS(),b.THIS());
|
||||
}
|
||||
else {
|
||||
return MIndexMul::evalXM(a, b.THIS());
|
||||
return MIndexMul::evalXM(a, b.THIS(), std::make_index_sequence<I2D>{});
|
||||
}
|
||||
}
|
||||
else {
|
||||
if constexpr(index_dim<I2>::value == 1){
|
||||
return MIndexMul::evalMX(a.THIS(), b);
|
||||
if constexpr(I2D == 1){
|
||||
return MIndexMul::evalMX(a.THIS(), b, std::make_index_sequence<I1D>{});
|
||||
}
|
||||
else {
|
||||
return MIndexMul::evalMM(a.THIS(), b.THIS());
|
||||
return MIndexMul::evalMM(a.THIS(), b.THIS(),
|
||||
std::make_index_sequence<I1D>{},
|
||||
std::make_index_sequence<I2D>{});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,9 +46,6 @@ namespace CNORXZ
|
|||
GMIndex& operator+=(Int n);
|
||||
GMIndex& operator-=(Int n);
|
||||
|
||||
template <class Index, typename Meta>
|
||||
constexpr decltype(auto) operator*(const IndexInterface<Index,Meta>& a) const;
|
||||
|
||||
SizeT lex() const;
|
||||
constexpr decltype(auto) pmax() const;
|
||||
constexpr decltype(auto) lmax() const;
|
||||
|
|
|
@ -412,18 +412,23 @@ namespace
|
|||
|
||||
TEST_F(YR_Test, IndexMultiplication)
|
||||
{
|
||||
const SizeT ssize = mMeta.size();
|
||||
const SizeT s1 = mMeta.size();
|
||||
const SizeT s2 = mSize;
|
||||
auto crx = std::dynamic_pointer_cast<CRange>(cr);
|
||||
auto urx = std::dynamic_pointer_cast<URange<String>>(ur);
|
||||
for(auto cix = crx->begin(); cix != crx->end(); ++cix){
|
||||
for(auto uix = urx->begin(); uix != urx->end(); ++uix){
|
||||
const SizeT p = cix.lex()*ssize + uix.lex();
|
||||
EXPECT_EQ((cix*uix).lex(), p);
|
||||
const SizeT p1 = cix.lex()*s1 + uix.lex();
|
||||
EXPECT_EQ((cix*uix).lex(), p1);
|
||||
for(auto ci2x = crx->begin(); ci2x != crx->end(); ++ci2x){
|
||||
const SizeT p2 = cix.lex()*s1*s2 + uix.lex()*s2 + ci2x.lex();
|
||||
EXPECT_EQ((cix*uix*ci2x).lex(), p2);
|
||||
}
|
||||
}
|
||||
}
|
||||
for(auto ci = cr->begin(); ci != cr->end(); ++ci){
|
||||
for(auto ui = ur->begin(); ui != ur->end(); ++ui){
|
||||
const SizeT p = ci.lex()*ssize + ui.lex();
|
||||
const SizeT p = ci.lex()*s1 + ui.lex();
|
||||
EXPECT_EQ((ci*ui).lex(), p);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue