add missing operator* for GMIndex + fix various bugs

This commit is contained in:
Christian Zimmermann 2023-03-19 01:48:51 +01:00
parent 4642ebe6d2
commit 026c7f1a87
3 changed files with 15 additions and 2 deletions

View file

@ -214,7 +214,7 @@ namespace CNORXZ
template <class F, class... Ops> template <class F, class... Ops>
struct op_size<Operation<F,Ops...>> struct op_size<Operation<F,Ops...>>
{ static constexpr SizeT value = sizeof...(Ops); }; { static constexpr SizeT value = ( op_size<Ops>::value + ... ); };
template <class CXpr> template <class CXpr>
class Contraction : public OpInterface<Contraction<CXpr>> class Contraction : public OpInterface<Contraction<CXpr>>
@ -238,6 +238,10 @@ namespace CNORXZ
CXpr mCXpr; CXpr mCXpr;
}; };
template <class CXpr>
struct op_size<Contraction<CXpr>>
{ static constexpr SizeT value = op_size<CXpr>::value; };
template <class F, class Op, class IndexT> template <class F, class Op, class IndexT>
constexpr decltype(auto) contraction(F&& f, Op&& op, const Sptr<IndexT>& i); constexpr decltype(auto) contraction(F&& f, Op&& op, const Sptr<IndexT>& i);

View file

@ -254,7 +254,7 @@ namespace CNORXZ
} }
if constexpr(not std::is_same<FormatT,None>::value){ mLex = lexpos; } if constexpr(not std::is_same<FormatT,None>::value){ mLex = lexpos; }
IB::mPos = iter<0,NI>( [&](auto i) { IB::mPos = iter<0,NI>( [&](auto i) {
*mIPack[i] = (lex() / lexFormat()[i].val()) % mIPack[i]->lmax().val(); *mIPack[i] = (lexpos / lexFormat()[i].val()) % mIPack[i]->lmax().val();
return format()[i].val() * mIPack[i]->pos(); return format()[i].val() * mIPack[i]->pos();
}, [](const auto&... e) { return (e + ...); } ); }, [](const auto&... e) { return (e + ...); } );
return *this; return *this;
@ -510,6 +510,12 @@ namespace CNORXZ
return std::make_shared<GMIndex<FormatT,Indices...>>(bs, is...); return std::make_shared<GMIndex<FormatT,Indices...>>(bs, is...);
} }
template <class I1, class FormatT, class... Indices>
decltype(auto) operator*(const Sptr<GMIndex<FormatT,Indices...>>& a, const Sptr<I1>& b)
{
return iptrMul(a, b);
}
/********************* /*********************
* MRangeFactory * * MRangeFactory *
*********************/ *********************/

View file

@ -148,6 +148,9 @@ namespace CNORXZ
template <class FormatT, class... Indices> template <class FormatT, class... Indices>
constexpr decltype(auto) gmindexPtr(const FormatT& bs, const Sptr<Indices>&... is); constexpr decltype(auto) gmindexPtr(const FormatT& bs, const Sptr<Indices>&... is);
template <class I1, class FormatT, class... Indices>
decltype(auto) operator*(const Sptr<GMIndex<FormatT,Indices...>>& a, const Sptr<I1>& b);
template <class... Ranges> template <class... Ranges>
class MRangeFactory : public RangeFactoryBase class MRangeFactory : public RangeFactoryBase
{ {