start refactoring dynamic stuff: DExt -> Polymorphism: not finished, does not compile so far...
This commit is contained in:
parent
c8d9eb9aa4
commit
4391d3a79a
3 changed files with 104 additions and 33 deletions
|
@ -155,6 +155,25 @@ namespace MultiArrayTools
|
||||||
return mTar.rootSteps(iPtrNum).extend( mSec.rootSteps(iPtrNum) );
|
return mTar.rootSteps(iPtrNum).extend( mSec.rootSteps(iPtrNum) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T, class Target, class OpClass>
|
||||||
|
inline void AssignmentExpr2<T,Target,OpClass>::operator()(size_t mlast, DExt last)
|
||||||
|
{
|
||||||
|
(*this)(mlast, std::dynamic_pointer_cast<ExtT<ExtType>>(last)->ext());
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T, class Target, class OpClass>
|
||||||
|
inline DExt AssignmentExpr2<T,Target,OpClass>::dRootSteps(std::intptr_t iPtrNum) const
|
||||||
|
{
|
||||||
|
return std::make_shared<ExtT<ExtType>>(rootSteps(iPtrNum));
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T, class Target, class OpClass>
|
||||||
|
inline DExt AssignmentExpr2<T,Target,OpClass>::dExtension() const
|
||||||
|
{
|
||||||
|
CHECK;
|
||||||
|
return nullptr; //???!!!
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T, class Target, class OpClass>
|
template <typename T, class Target, class OpClass>
|
||||||
AddExpr<T,Target,OpClass>::AddExpr(T* dataPtr, const Target& tar, const OpClass& sec) :
|
AddExpr<T,Target,OpClass>::AddExpr(T* dataPtr, const Target& tar, const OpClass& sec) :
|
||||||
mTar(tar), mSec(sec), mDataPtr(dataPtr) {}
|
mTar(tar), mSec(sec), mDataPtr(dataPtr) {}
|
||||||
|
@ -173,7 +192,6 @@ namespace MultiArrayTools
|
||||||
//return mSec.rootSteps(iPtrNum);
|
//return mSec.rootSteps(iPtrNum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/****************************
|
/****************************
|
||||||
* ConstOperationRoot *
|
* ConstOperationRoot *
|
||||||
****************************/
|
****************************/
|
||||||
|
|
|
@ -17,6 +17,8 @@
|
||||||
|
|
||||||
#include "arith.h"
|
#include "arith.h"
|
||||||
|
|
||||||
|
#include "xfor/xfor.h"
|
||||||
|
|
||||||
namespace MultiArrayTools
|
namespace MultiArrayTools
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -106,7 +108,7 @@ namespace MultiArrayTools
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T, class Target, class OpClass>
|
template <typename T, class Target, class OpClass>
|
||||||
class AssignmentExpr2
|
class AssignmentExpr2 : public ExpressionBase
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
AssignmentExpr2() = default;
|
AssignmentExpr2() = default;
|
||||||
|
@ -128,6 +130,11 @@ namespace MultiArrayTools
|
||||||
inline void operator()(size_t start = 0);
|
inline void operator()(size_t start = 0);
|
||||||
inline void operator()(size_t start, ExtType last);
|
inline void operator()(size_t start, ExtType last);
|
||||||
auto rootSteps(std::intptr_t iPtrNum = 0) const -> ExtType;
|
auto rootSteps(std::intptr_t iPtrNum = 0) const -> ExtType;
|
||||||
|
|
||||||
|
inline void operator()(size_t mlast, DExt last) override final;
|
||||||
|
|
||||||
|
inline DExt dRootSteps(std::intptr_t iPtrNum = 0) const override final;
|
||||||
|
inline DExt dExtension() const override final;
|
||||||
};
|
};
|
||||||
|
|
||||||
//template <typename T, class OpClass>
|
//template <typename T, class OpClass>
|
||||||
|
|
|
@ -21,7 +21,41 @@ namespace MultiArrayHelper
|
||||||
// 'HIDDEN FOR' CLASS for nested for loops in contractions a.s.o.
|
// 'HIDDEN FOR' CLASS for nested for loops in contractions a.s.o.
|
||||||
// (NO COUNTING OF MASTER POSITION !!!!!)
|
// (NO COUNTING OF MASTER POSITION !!!!!)
|
||||||
|
|
||||||
typedef std::pair<size_t const*,size_t> DExt;
|
//typedef std::pair<size_t const*,size_t> DExt;
|
||||||
|
|
||||||
|
class ExtBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ExtBase() = default;
|
||||||
|
ExtBase(const ExtBase& in) = default;
|
||||||
|
ExtBase(ExtBase&& in) = default;
|
||||||
|
ExtBase& operator=(const ExtBase& in) = default;
|
||||||
|
ExtBase& operator=(ExtBase&& in) = default;
|
||||||
|
|
||||||
|
//virtual size_t size() const = 0;
|
||||||
|
//virtual size_t rootSteps() const = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class ExtType>
|
||||||
|
class ExtT : public ExtBase
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
ExtType mExt;
|
||||||
|
public:
|
||||||
|
ExtT() = default;
|
||||||
|
ExtT(const ExtT& in) = default;
|
||||||
|
ExtT(ExtT&& in) = default;
|
||||||
|
ExtT& operator=(const ExtT& in) = default;
|
||||||
|
ExtT& operator=(ExtT&& in) = default;
|
||||||
|
|
||||||
|
ExtT(const ExtType& in) : mExt(in) {}
|
||||||
|
|
||||||
|
//virtual size_t size() const override final;
|
||||||
|
//virtual size_t rootSteps() const override final;
|
||||||
|
const ExtType& ext() const { return mExt; }
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef std::shared_ptr<ExtBase> DExt;
|
||||||
|
|
||||||
inline MExt<void> mkExt(size_t s) { return MExt<void>(s); }
|
inline MExt<void> mkExt(size_t s) { return MExt<void>(s); }
|
||||||
|
|
||||||
|
@ -393,7 +427,8 @@ namespace MultiArrayHelper
|
||||||
template <class IndexClass, class Expr, ForType FT>
|
template <class IndexClass, class Expr, ForType FT>
|
||||||
inline void For<IndexClass,Expr,FT>::operator()(size_t mlast, DExt last)
|
inline void For<IndexClass,Expr,FT>::operator()(size_t mlast, DExt last)
|
||||||
{
|
{
|
||||||
operator()(mlast, *reinterpret_cast<ExtType const*>(last.first));
|
operator()(mlast, std::dynamic_pointer_cast<ExtT<ExtType>>(last)->ext());
|
||||||
|
//operator()(mlast, *reinterpret_cast<ExtType const*>(last.first));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class IndexClass, class Expr, ForType FT>
|
template <class IndexClass, class Expr, ForType FT>
|
||||||
|
@ -438,16 +473,18 @@ namespace MultiArrayHelper
|
||||||
template <class IndexClass, class Expr, ForType FT>
|
template <class IndexClass, class Expr, ForType FT>
|
||||||
DExt For<IndexClass,Expr,FT>::dRootSteps(std::intptr_t iPtrNum) const
|
DExt For<IndexClass,Expr,FT>::dRootSteps(std::intptr_t iPtrNum) const
|
||||||
{
|
{
|
||||||
mRootSteps = rootSteps(iPtrNum);
|
return std::make_shared<ExtT<ExtType>>(rootSteps(iPtrNum));
|
||||||
return std::make_pair<size_t const*,size_t>(reinterpret_cast<size_t const*>(&mRootSteps),
|
//mRootSteps = rootSteps(iPtrNum);
|
||||||
sizeof(ExtType)/sizeof(size_t));
|
//return std::make_pair<size_t const*,size_t>(reinterpret_cast<size_t const*>(&mRootSteps),
|
||||||
|
// sizeof(ExtType)/sizeof(size_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class IndexClass, class Expr, ForType FT>
|
template <class IndexClass, class Expr, ForType FT>
|
||||||
DExt For<IndexClass,Expr,FT>::dExtension() const
|
DExt For<IndexClass,Expr,FT>::dExtension() const
|
||||||
{
|
{
|
||||||
return std::make_pair<size_t const*,size_t>(reinterpret_cast<size_t const*>(&mExt),
|
return std::make_shared<ExtT<ExtType>>(mExt);
|
||||||
sizeof(ExtType)/sizeof(size_t));
|
//return std::make_pair<size_t const*,size_t>(reinterpret_cast<size_t const*>(&mExt),
|
||||||
|
// sizeof(ExtType)/sizeof(size_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class IndexClass, class Expr, ForType FT>
|
template <class IndexClass, class Expr, ForType FT>
|
||||||
|
@ -482,7 +519,8 @@ namespace MultiArrayHelper
|
||||||
template <class IndexClass, class Expr>
|
template <class IndexClass, class Expr>
|
||||||
inline void PFor<IndexClass,Expr>::operator()(size_t mlast, DExt last)
|
inline void PFor<IndexClass,Expr>::operator()(size_t mlast, DExt last)
|
||||||
{
|
{
|
||||||
operator()(mlast, *reinterpret_cast<ExtType const*>(last.first));
|
operator()(mlast, std::dynamic_pointer_cast<ExtT<ExtType>>(last)->ext());
|
||||||
|
//operator()(mlast, *reinterpret_cast<ExtType const*>(last.first));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class IndexClass, class Expr>
|
template <class IndexClass, class Expr>
|
||||||
|
@ -545,16 +583,18 @@ namespace MultiArrayHelper
|
||||||
template <class IndexClass, class Expr>
|
template <class IndexClass, class Expr>
|
||||||
DExt PFor<IndexClass,Expr>::dRootSteps(std::intptr_t iPtrNum) const
|
DExt PFor<IndexClass,Expr>::dRootSteps(std::intptr_t iPtrNum) const
|
||||||
{
|
{
|
||||||
mRootSteps = rootSteps(iPtrNum);
|
return std::make_shared<ExtT<ExtType>>(rootSteps(iPtrNum));
|
||||||
return std::make_pair<size_t const*,size_t>(reinterpret_cast<size_t const*>(&mRootSteps),
|
//mRootSteps = rootSteps(iPtrNum);
|
||||||
sizeof(ExtType)/sizeof(size_t));
|
//return std::make_pair<size_t const*,size_t>(reinterpret_cast<size_t const*>(&mRootSteps),
|
||||||
|
// sizeof(ExtType)/sizeof(size_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class IndexClass, class Expr>
|
template <class IndexClass, class Expr>
|
||||||
DExt PFor<IndexClass,Expr>::dExtension() const
|
DExt PFor<IndexClass,Expr>::dExtension() const
|
||||||
{
|
{
|
||||||
return std::make_pair<size_t const*,size_t>(reinterpret_cast<size_t const*>(&mExt),
|
return std::make_shared<ExtT<ExtType>>(mExt);
|
||||||
sizeof(ExtType)/sizeof(size_t));
|
//return std::make_pair<size_t const*,size_t>(reinterpret_cast<size_t const*>(&mExt),
|
||||||
|
// sizeof(ExtType)/sizeof(size_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************
|
/************************
|
||||||
|
@ -586,7 +626,8 @@ namespace MultiArrayHelper
|
||||||
template <class IndexClass, class Expr>
|
template <class IndexClass, class Expr>
|
||||||
inline void SingleExpression<IndexClass,Expr>::operator()(size_t mlast, DExt last)
|
inline void SingleExpression<IndexClass,Expr>::operator()(size_t mlast, DExt last)
|
||||||
{
|
{
|
||||||
operator()(mlast, *reinterpret_cast<ExtType const*>(last.first));
|
operator()(mlast, std::dynamic_pointer_cast<ExtT<ExtType>>(last)->ext());
|
||||||
|
//operator()(mlast, *reinterpret_cast<ExtType const*>(last.first));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class IndexClass, class Expr>
|
template <class IndexClass, class Expr>
|
||||||
|
@ -628,16 +669,18 @@ namespace MultiArrayHelper
|
||||||
template <class IndexClass, class Expr>
|
template <class IndexClass, class Expr>
|
||||||
DExt SingleExpression<IndexClass,Expr>::dRootSteps(std::intptr_t iPtrNum) const
|
DExt SingleExpression<IndexClass,Expr>::dRootSteps(std::intptr_t iPtrNum) const
|
||||||
{
|
{
|
||||||
mRootSteps = rootSteps(iPtrNum);
|
return std::make_shared<ExtT<ExtType>>(rootSteps(iPtrNum));
|
||||||
return std::make_pair<size_t const*,size_t>(reinterpret_cast<size_t const*>(&mRootSteps),
|
//mRootSteps = rootSteps(iPtrNum);
|
||||||
sizeof(ExtType)/sizeof(size_t));
|
//return std::make_pair<size_t const*,size_t>(reinterpret_cast<size_t const*>(&mRootSteps),
|
||||||
|
// sizeof(ExtType)/sizeof(size_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class IndexClass, class Expr>
|
template <class IndexClass, class Expr>
|
||||||
DExt SingleExpression<IndexClass,Expr>::dExtension() const
|
DExt SingleExpression<IndexClass,Expr>::dExtension() const
|
||||||
{
|
{
|
||||||
return std::make_pair<size_t const*,size_t>(reinterpret_cast<size_t const*>(&mExt),
|
return std::make_shared<ExtT<ExtType>>(mExt);
|
||||||
sizeof(ExtType)/sizeof(size_t));
|
//return std::make_pair<size_t const*,size_t>(reinterpret_cast<size_t const*>(&mExt),
|
||||||
|
// sizeof(ExtType)/sizeof(size_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************
|
/****************
|
||||||
|
@ -670,7 +713,8 @@ namespace MultiArrayHelper
|
||||||
template <class IndexClass, class Expr>
|
template <class IndexClass, class Expr>
|
||||||
inline void SubExpr<IndexClass,Expr>::operator()(size_t mlast, DExt last)
|
inline void SubExpr<IndexClass,Expr>::operator()(size_t mlast, DExt last)
|
||||||
{
|
{
|
||||||
operator()(mlast, *reinterpret_cast<ExtType const*>(last.first));
|
operator()(mlast, std::dynamic_pointer_cast<ExtT<ExtType>>(last)->ext());
|
||||||
|
//operator()(mlast, *reinterpret_cast<ExtType const*>(last.first));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class IndexClass, class Expr>
|
template <class IndexClass, class Expr>
|
||||||
|
@ -711,16 +755,18 @@ namespace MultiArrayHelper
|
||||||
template <class IndexClass, class Expr>
|
template <class IndexClass, class Expr>
|
||||||
DExt SubExpr<IndexClass,Expr>::dRootSteps(std::intptr_t iPtrNum) const
|
DExt SubExpr<IndexClass,Expr>::dRootSteps(std::intptr_t iPtrNum) const
|
||||||
{
|
{
|
||||||
mRootSteps = rootSteps(iPtrNum);
|
return std::make_shared<ExtT<ExtType>>(rootSteps(iPtrNum));
|
||||||
return std::make_pair<size_t const*,size_t>(reinterpret_cast<size_t const*>(&mRootSteps),
|
//mRootSteps = rootSteps(iPtrNum);
|
||||||
sizeof(ExtType)/sizeof(size_t));
|
//return std::make_pair<size_t const*,size_t>(reinterpret_cast<size_t const*>(&mRootSteps),
|
||||||
|
//sizeof(ExtType)/sizeof(size_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class IndexClass, class Expr>
|
template <class IndexClass, class Expr>
|
||||||
DExt SubExpr<IndexClass,Expr>::dExtension() const
|
DExt SubExpr<IndexClass,Expr>::dExtension() const
|
||||||
{
|
{
|
||||||
return std::make_pair<size_t const*,size_t>(reinterpret_cast<size_t const*>(&mExt),
|
return std::make_shared<ExtT<ExtType>>(mExt);
|
||||||
sizeof(ExtType)/sizeof(size_t));
|
//return std::make_pair<size_t const*,size_t>(reinterpret_cast<size_t const*>(&mExt),
|
||||||
|
// sizeof(ExtType)/sizeof(size_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
/***************************
|
/***************************
|
||||||
|
@ -764,9 +810,7 @@ namespace MultiArrayHelper
|
||||||
inline void ExpressionHolder<Expr>::operator()(size_t mlast, ExtType last)
|
inline void ExpressionHolder<Expr>::operator()(size_t mlast, ExtType last)
|
||||||
{
|
{
|
||||||
mExpr(mlast,
|
mExpr(mlast,
|
||||||
std::make_pair<size_t const*,size_t>
|
std::make_shared<ExtT<ExtType>>(last));
|
||||||
(reinterpret_cast<size_t const*>(&last),
|
|
||||||
sizeof(ExtType)/sizeof(size_t)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Expr>
|
template <class Expr>
|
||||||
|
@ -791,14 +835,16 @@ namespace MultiArrayHelper
|
||||||
auto ExpressionHolder<Expr>::rootSteps(std::intptr_t iPtrNum) const
|
auto ExpressionHolder<Expr>::rootSteps(std::intptr_t iPtrNum) const
|
||||||
-> ExtType
|
-> ExtType
|
||||||
{
|
{
|
||||||
return *reinterpret_cast<ExtType const*>( mExpr.dRootSteps(iPtrNum).first );
|
return std::dynamic_pointer_cast<ExtT<ExtType>>(*mExpr.dRootSteps(iPtrNum))->ext();
|
||||||
|
//return *reinterpret_cast<ExtType const*>( mExpr.dRootSteps(iPtrNum).first );
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Expr>
|
template <class Expr>
|
||||||
auto ExpressionHolder<Expr>::extension() const
|
auto ExpressionHolder<Expr>::extension() const
|
||||||
-> ExtType
|
-> ExtType
|
||||||
{
|
{
|
||||||
return *reinterpret_cast<ExtType const*>( mExpr.dExtension().first );
|
return std::dynamic_pointer_cast<ExtT<ExtType>>(*mExpr.dExtension())->ext();
|
||||||
|
//return *reinterpret_cast<ExtType const*>( mExpr.dExtension().first );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue