fix dynamic expressions

This commit is contained in:
Christian Zimmermann 2020-07-09 17:37:28 +02:00
parent 354a275c12
commit a64291484c
7 changed files with 43 additions and 42 deletions

View file

@ -321,10 +321,10 @@ namespace MultiArrayTools
}
template <typename T, class... Ranges>
MExt<void> ConstOperationRoot<T,Ranges...>::rootSteps(std::intptr_t iPtrNum) const
MExt<None> ConstOperationRoot<T,Ranges...>::rootSteps(std::intptr_t iPtrNum) const
{
return MExt<void>(getStepSize( mIndex, iPtrNum ));
//return MExt<void>(getStepSize( getRootIndices( mIndex->info() ), iPtrNum ));
return MExt<None>(getStepSize( mIndex, iPtrNum ));
//return MExt<None>(getStepSize( getRootIndices( mIndex->info() ), iPtrNum ));
}
@ -402,10 +402,10 @@ namespace MultiArrayTools
}
template <class Range>
MExt<void> MetaOperationRoot<Range>::rootSteps(std::intptr_t iPtrNum) const
MExt<None> MetaOperationRoot<Range>::rootSteps(std::intptr_t iPtrNum) const
{
return MExt<void>(getStepSize( *mIndex, iPtrNum ));
//return MExt<void>(getStepSize( getRootIndices( mIndex->info() ), iPtrNum ));
return MExt<None>(getStepSize( *mIndex, iPtrNum ));
//return MExt<None>(getStepSize( getRootIndices( mIndex->info() ), iPtrNum ));
}
@ -544,9 +544,9 @@ namespace MultiArrayTools
}
template <typename T, class... Ranges>
MExt<void> OperationRoot<T,Ranges...>::rootSteps(std::intptr_t iPtrNum) const
MExt<None> OperationRoot<T,Ranges...>::rootSteps(std::intptr_t iPtrNum) const
{
return MExt<void>(getStepSize( mIndex, iPtrNum ));
return MExt<None>(getStepSize( mIndex, iPtrNum ));
}
template <typename T, class... Ranges>
@ -661,10 +661,10 @@ namespace MultiArrayTools
}
template <typename T, class... Ranges>
MExt<void> ParallelOperationRoot<T,Ranges...>::rootSteps(std::intptr_t iPtrNum) const
MExt<None> ParallelOperationRoot<T,Ranges...>::rootSteps(std::intptr_t iPtrNum) const
{
return MExt<void>(getStepSize( mIndex, iPtrNum ));
//return MExt<void>(getStepSize( mIndex.info(), iPtrNum ));
return MExt<None>(getStepSize( mIndex, iPtrNum ));
//return MExt<None>(getStepSize( mIndex.info(), iPtrNum ));
}
template <typename T, class... Ranges>

View file

@ -204,7 +204,7 @@ namespace MultiArrayTools
template <class ET>
inline ConstOperationRoot& set(ET pos);
MExt<void> rootSteps(std::intptr_t iPtrNum = 0) const; // nullptr for simple usage with decltype
MExt<None> rootSteps(std::intptr_t iPtrNum = 0) const; // nullptr for simple usage with decltype
template <class Expr>
Expr loop(Expr exp) const;
@ -278,7 +278,7 @@ namespace MultiArrayTools
template <class ET>
inline MetaOperationRoot& set(ET pos);
MExt<void> rootSteps(std::intptr_t iPtrNum = 0) const; // nullptr for simple usage with decltype
MExt<None> rootSteps(std::intptr_t iPtrNum = 0) const; // nullptr for simple usage with decltype
template <class Expr>
Expr loop(Expr exp) const;
@ -354,7 +354,7 @@ namespace MultiArrayTools
template <class ET>
inline OperationRoot& set(ET pos);
MExt<void> rootSteps(std::intptr_t iPtrNum = 0) const; // nullptr for simple usage with decltype
MExt<None> rootSteps(std::intptr_t iPtrNum = 0) const; // nullptr for simple usage with decltype
template <class Expr>
Expr loop(Expr exp) const;
@ -416,7 +416,7 @@ namespace MultiArrayTools
template <class ET>
inline ParallelOperationRoot& set(ET pos);
MExt<void> rootSteps(std::intptr_t iPtrNum = 0) const; // nullptr for simple usage with decltype
MExt<None> rootSteps(std::intptr_t iPtrNum = 0) const; // nullptr for simple usage with decltype
template <class Expr>
Expr loop(Expr exp) const;

View file

@ -102,34 +102,34 @@ namespace MultiArrayTools
template <class Expr>
ExpressionHolder<Expr> DynamicIndex::ifor(size_t step, Expr ex) const
DynamicExpression DynamicIndex::ifor(size_t step, Expr ex) const
{
if(mIVec.size() == 1){
return ExpressionHolder<Expr>(mIVec.back().first->ifor(step,ex));
return mIVec.back().first->ifor(step,ex);
}
else {
return ExpressionHolder<Expr>(ForMaker::mk(mIVec.size()-2, step,
mIVec.back().first->ifor(step,ex),mIVec));
return ForMaker::mk(mIVec.size()-2, step,
mIVec.back().first->ifor(step,ex),mIVec);
}
}
template <class Expr>
ExpressionHolder<Expr> DynamicIndex::iforh(size_t step, Expr ex) const
DynamicExpression DynamicIndex::iforh(size_t step, Expr ex) const
{
if(mIVec.size() == 1){
return ExpressionHolder<Expr>(mIVec.back().first->iforh(step,ex));
return mIVec.back().first->iforh(step,ex);
}
else {
return ExpressionHolder<Expr>(ForMaker::mk(mIVec.size()-2, step,
mIVec.back().first->iforh(step,ex),
mIVec, true));
return ForMaker::mk(mIVec.size()-2, step,
mIVec.back().first->iforh(step,ex),
mIVec, true);
}
}
template <class Expr>
ExpressionHolder<Expr> DynamicIndex::pifor(size_t step, Expr ex) const
DynamicExpression DynamicIndex::pifor(size_t step, Expr ex) const
{
return ifor(step, ex); // no multithreading here at the moment...
}

View file

@ -232,13 +232,13 @@ namespace MultiArrayTools
void print(size_t offset);
template <class Expr>
ExpressionHolder<Expr> ifor(size_t step, Expr ex) const;
DynamicExpression ifor(size_t step, Expr ex) const;
template <class Expr>
ExpressionHolder<Expr> iforh(size_t step, Expr ex) const;
DynamicExpression iforh(size_t step, Expr ex) const;
template <class Expr>
ExpressionHolder<Expr> pifor(size_t step, Expr ex) const;
DynamicExpression pifor(size_t step, Expr ex) const;
};

View file

@ -35,7 +35,7 @@ namespace MultiArrayHelper
};
template <>
struct SubProp<void>
struct SubProp<None>
{
static constexpr size_t ISSTATIC = 1;
static constexpr size_t SIZE = 1;

View file

@ -114,14 +114,14 @@ namespace MultiArrayHelper
};
template <>
class MExt<void>
class MExt<None>
{
private:
size_t mExt = 0u;
public:
static constexpr size_t NUM = 0;
static constexpr size_t SIZE = NUM + 1;
@ -226,45 +226,45 @@ namespace MultiArrayHelper
//template <>
inline MExt<void>::MExt(size_t ext) : mExt(ext) {}
inline MExt<None>::MExt(size_t ext) : mExt(ext) {}
//template <>
template <class Z>
inline MExt<void>::MExt(size_t y, const Z& z) :
inline MExt<None>::MExt(size_t y, const Z& z) :
mExt(z.val()) {}
//template <>
template <class Y, class Z>
inline MExt<void>::MExt(const Y& y, const Z& z) :
inline MExt<None>::MExt(const Y& y, const Z& z) :
mExt(y.val()) {}
//template <>
template <size_t N>
inline MExt<void>::MExt(const std::array<size_t,N>& arr) :
inline MExt<None>::MExt(const std::array<size_t,N>& arr) :
mExt(std::get<NUM>(arr)) {}
template <class Y>
inline MExt<void>::MExt(const MExt<Y>& y) :
inline MExt<None>::MExt(const MExt<Y>& y) :
mExt(y.val()) {}
//template <>
inline const size_t& MExt<void>::val() const
inline const size_t& MExt<None>::val() const
{
return mExt;
}
//template <>
inline MExt<void> MExt<void>::operator+(const MExt<void>& in) const
inline MExt<None> MExt<None>::operator+(const MExt<None>& in) const
{
return MExt<void>(mExt + in.val());
return MExt<None>(mExt + in.val());
}
//template <>
inline MExt<void> MExt<void>::operator*(size_t in) const
inline MExt<None> MExt<None>::operator*(size_t in) const
{
return MExt<void>(mExt * in);
return MExt<None>(mExt * in);
}

View file

@ -55,6 +55,7 @@ namespace MultiArrayHelper
ExtT(const ExtType& in) : mExt(in) {}
virtual size_t size() const override final { return sizeof(ExtType)/sizeof(size_t); }
//virtual size_t size() const override final { return ExtType::MExtSize(); }
//virtual size_t rootSteps() const override final;
const ExtType& ext() const { return mExt; }
@ -87,7 +88,7 @@ namespace MultiArrayHelper
};
inline MExt<void> mkExt(size_t s) { return MExt<void>(s); }
inline MExt<None> mkExt(size_t s) { return MExt<None>(s); }
class ExpressionBase
{