redefine index-index-multiplications
This commit is contained in:
parent
8513b6dcd3
commit
a3a25af289
4 changed files with 106 additions and 18 deletions
|
@ -131,18 +131,6 @@ namespace CNORXZ
|
|||
return std::make_shared<IndexInterface<I,MetaType>>( *i - n );
|
||||
}
|
||||
|
||||
template <class I1, class I2, typename MType1, typename MType2>
|
||||
decltype(auto) operator*(const IndexInterface<I1,MType1>& a,
|
||||
const IndexInterface<I2,MType2>& b)
|
||||
{
|
||||
return MIndex<I1,I2>(a.THIS(),b.THIS());
|
||||
}
|
||||
|
||||
template <class I1, class I2, typename MType1, typename MType2>
|
||||
decltype(auto) operator*(const IndexPtr<I1,MType1>& a, const IndexPtr<I2,MType2>& b)
|
||||
{
|
||||
return std::make_shared<MIndex<I1,I2>>(a->THIS(), b->THIS());
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -41,6 +41,7 @@ namespace CNORXZ
|
|||
bool operator>(const IndexInterface& in) const;
|
||||
bool operator<=(const IndexInterface& in) const;
|
||||
bool operator>=(const IndexInterface& in) const;
|
||||
|
||||
decltype(auto) operator*() const { return THIS().operator*(); }
|
||||
|
||||
SizeT dim() const { return THIS().dim(); }
|
||||
|
@ -82,6 +83,10 @@ namespace CNORXZ
|
|||
struct index_const_size
|
||||
{ static constexpr SizeT value = 0; };
|
||||
|
||||
template <class I>
|
||||
struct index_dim
|
||||
{ static constexpr SizeT value = 1; };
|
||||
|
||||
template <class I, typename MetaType>
|
||||
IndexPtr<I,MetaType>& operator++(const IndexPtr<I,MetaType>& i);
|
||||
|
||||
|
@ -95,12 +100,6 @@ namespace CNORXZ
|
|||
template <class I, typename MetaType>
|
||||
IndexPtr<I,MetaType> operator-(const IndexPtr<I,MetaType>& i, Int n);
|
||||
|
||||
template <class I1, class I2, typename MType1, typename MType2>
|
||||
decltype(auto) operator*(const IndexInterface<I1,MType1>& a,
|
||||
const IndexInterface<I2,MType2>& b);
|
||||
|
||||
template <class I1, class I2, typename MType1, typename MType2>
|
||||
decltype(auto) operator*(const IndexPtr<I1,MType1>& a, const IndexPtr<I2,MType2>& b);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -449,6 +449,69 @@ namespace CNORXZ
|
|||
return mLexBlockSizes;
|
||||
}
|
||||
|
||||
template <class... Indices>
|
||||
constexpr decltype(auto) mindex(const Sptr<Indices>&... is)
|
||||
{
|
||||
return MIndex<Indices...>(is...);
|
||||
}
|
||||
|
||||
/*****************
|
||||
* MIndexMul *
|
||||
*****************/
|
||||
|
||||
template <class BlockT, class... Indices, class I, typename Meta, SizeT... Is>
|
||||
constexpr decltype(auto) MIndexMul::evalMX(const GMIndex<BlockT,Indices...>& a,
|
||||
const IndexInterface<I,Meta>& b,
|
||||
Isq<Is...> is)
|
||||
{
|
||||
static_assert(sizeof...(Is) == sizeof...(Indices), "inconsistent index sequence");
|
||||
return MIndex<Indices...,I>( std::get<Is>(a.pack())..., b.THIS() );
|
||||
}
|
||||
|
||||
template <class BlockT, class... Indices, class I, typename Meta, SizeT... Js>
|
||||
constexpr decltype(auto) MIndexMul::evalXM(const IndexInterface<I,Meta>& a,
|
||||
const GMIndex<BlockT,Indices...>& b,
|
||||
Isq<Js...> js)
|
||||
{
|
||||
static_assert(sizeof...(Js) == sizeof...(Indices), "inconsistent index sequence");
|
||||
return MIndex<Indices...,I>( a.THIS(), std::get<Js>(b.pack())... );
|
||||
}
|
||||
|
||||
template <class BlockT1, class... Indices1, class BlockT2, class... Indices2, SizeT... Is, SizeT... Js>
|
||||
constexpr decltype(auto) MIndexMul::evalMM(const GMIndex<BlockT1,Indices1...>& a,
|
||||
const GMIndex<BlockT2,Indices2...>& b,
|
||||
Isq<Is...> is, Isq<Js...> js)
|
||||
{
|
||||
static_assert(sizeof...(Is) == sizeof...(Indices1), "inconsistent index sequence");
|
||||
static_assert(sizeof...(Js) == sizeof...(Indices2), "inconsistent index sequence");
|
||||
return MIndex<Indices1...,Indices2...>( std::get<Is>(a.pack())...,
|
||||
std::get<Js>(b.pack())... );
|
||||
}
|
||||
|
||||
// move to separate file!!!
|
||||
template <class I1, typename Meta1, class I2, typename Meta2>
|
||||
constexpr decltype(auto) operator*(const IndexInterface<I1,Meta1>& a,
|
||||
const IndexInterface<I2,Meta2>& b)
|
||||
{
|
||||
// special operations for DIndex / YIndex
|
||||
if constexpr(index_dim<I1>::value == 1){
|
||||
if constexpr(index_dim<I2>::value == 1){
|
||||
return MIndex<I1,I2>(a.THIS(),b.THIS());
|
||||
}
|
||||
else {
|
||||
return MIndexMul::evalXM(a, b.THIS());
|
||||
}
|
||||
}
|
||||
else {
|
||||
if constexpr(index_dim<I2>::value == 1){
|
||||
return MIndexMul::evalMX(a.THIS(), b);
|
||||
}
|
||||
else {
|
||||
return MIndexMul::evalMM(a.THIS(), b.THIS());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*********************
|
||||
* MRangeFactory *
|
||||
|
|
|
@ -46,6 +46,9 @@ 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;
|
||||
|
@ -117,6 +120,41 @@ namespace CNORXZ
|
|||
template <class... Indices>
|
||||
struct index_const_size<MIndex<Indices...>>
|
||||
{ static constexpr SizeT value = (index_const_size<Indices>::value * ...); };
|
||||
|
||||
template <class... Indices>
|
||||
struct index_dim<MIndex<Indices...>>
|
||||
{ static constexpr SizeT value = sizeof...(Indices); };
|
||||
|
||||
template <class... Indices>
|
||||
constexpr decltype(auto) mindex(const Sptr<Indices>&... is);
|
||||
|
||||
struct MIndexMul
|
||||
{
|
||||
template <class BlockT, class... Indices, class I, typename Meta, SizeT... Is>
|
||||
static constexpr decltype(auto) evalMX(const GMIndex<BlockT,Indices...>& a,
|
||||
const IndexInterface<I,Meta>& b,
|
||||
Isq<Is...> is);
|
||||
|
||||
template <class BlockT, class... Indices, class I, typename Meta, SizeT... Js>
|
||||
static constexpr decltype(auto) evalXM(const IndexInterface<I,Meta>& a,
|
||||
const GMIndex<BlockT,Indices...>& b,
|
||||
Isq<Js...> js);
|
||||
|
||||
template <class BlockT1, class... Indices1, class BlockT2, class... Indices2, SizeT... Is, SizeT... Js>
|
||||
static constexpr decltype(auto) evalMM(const GMIndex<BlockT1,Indices1...>& a,
|
||||
const GMIndex<BlockT2,Indices2...>& b,
|
||||
Isq<Is...> is, Isq<Js...> js);
|
||||
};
|
||||
|
||||
// move to separate file!!!
|
||||
template <class I1, typename Meta1, class I2, typename Meta2>
|
||||
constexpr decltype(auto) operator*(const IndexInterface<I1,Meta1>& a,
|
||||
const IndexInterface<I2,Meta2>& b);
|
||||
|
||||
//template <class BlockT, class... Indices2, SizeT... Is, SizeT... Js>
|
||||
//constexpr decltype(auto) mindex(const GMIndex<BlockT,Indices2...>& a,
|
||||
// Isq<Is...> is, Isq<Js...> js) const;
|
||||
|
||||
|
||||
template <class... Ranges>
|
||||
class MRangeFactory : public RangeFactoryBase
|
||||
|
|
Loading…
Reference in a new issue