2018-01-05 13:56:16 +01:00
|
|
|
|
2021-07-28 20:59:31 +02:00
|
|
|
#ifndef __cxz_xfor_h__
|
|
|
|
#define __cxz_xfor_h__
|
2018-01-05 13:56:16 +01:00
|
|
|
|
2019-01-14 18:39:09 +01:00
|
|
|
#include <omp.h>
|
|
|
|
|
2022-09-12 01:09:51 +02:00
|
|
|
#include "base/base.h"
|
|
|
|
#include "for_type.h"
|
|
|
|
#include "for_utils.h"
|
|
|
|
#include "exttype.h"
|
2018-11-01 22:11:08 +01:00
|
|
|
|
2022-09-12 01:09:51 +02:00
|
|
|
namespace CNORXZ
|
2018-01-05 13:56:16 +01:00
|
|
|
{
|
2018-01-14 22:41:35 +01:00
|
|
|
// 'HIDDEN FOR' CLASS for nested for loops in contractions a.s.o.
|
|
|
|
// (NO COUNTING OF MASTER POSITION !!!!!)
|
2018-01-15 14:56:22 +01:00
|
|
|
|
2022-09-12 01:09:51 +02:00
|
|
|
template <class Expr, class Pos>
|
|
|
|
class ExpressionInterface
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DEFAULT_MEMBERS(ExpressionInterface);
|
|
|
|
|
|
|
|
Expr& THIS() { return static_cast<Expr&>(*this); }
|
|
|
|
const Expr& THIS() const { return static_cast<const Expr&>(*this); }
|
2018-12-21 23:02:35 +01:00
|
|
|
|
2022-09-12 01:09:51 +02:00
|
|
|
Sptr<Expr> copy() const { THIS().copy(); }
|
|
|
|
|
|
|
|
void operator(SizeT mlast, Pos last) { THIS()(mlast, last); }
|
|
|
|
void operator(SizeT mlast = 0) { THIS()(mlast); }
|
2020-08-24 16:35:14 +02:00
|
|
|
|
2022-09-12 01:09:51 +02:00
|
|
|
Pos rootSteps(PtrId ptrId = 0) const { return THIS().rootSteps(ptrId); }
|
|
|
|
Pos extension() const { return THIS().extenrion(); }
|
|
|
|
};
|
|
|
|
|
|
|
|
class XprBase : public ExpressionInterface<XprBase,Dext>
|
2018-10-21 22:52:01 +02:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2022-09-12 01:09:51 +02:00
|
|
|
DEFAULT_MEMBERS(XprBase);
|
2018-10-21 22:52:01 +02:00
|
|
|
|
2022-09-12 01:09:51 +02:00
|
|
|
virtual Sptr<XprBase> copy() const = 0;
|
2020-08-29 21:46:07 +02:00
|
|
|
|
2022-09-12 01:09:51 +02:00
|
|
|
virtual void operator()(SizeT mlast, DExt last) = 0;
|
|
|
|
virtual void operator()(SizeT mlast) = 0;
|
2018-10-21 22:52:01 +02:00
|
|
|
|
2022-09-12 01:09:51 +02:00
|
|
|
virtual DExt rootSteps(PtrId iPtrNum = 0) const = 0;
|
|
|
|
virtual DExt extension() const = 0;
|
2018-10-21 22:52:01 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2018-01-15 14:56:22 +01:00
|
|
|
template <ForType FT = ForType::DEFAULT>
|
|
|
|
struct PosForward
|
|
|
|
{
|
2018-09-17 16:21:23 +02:00
|
|
|
static inline size_t valuex(size_t last, size_t step, size_t pos)
|
|
|
|
{
|
|
|
|
return last + pos * step;
|
|
|
|
}
|
|
|
|
|
2018-01-15 14:56:22 +01:00
|
|
|
static inline size_t value(size_t last, size_t max, size_t pos)
|
|
|
|
{
|
|
|
|
return last * max + pos;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct PosForward<ForType::HIDDEN>
|
|
|
|
{
|
2018-09-17 16:21:23 +02:00
|
|
|
static inline size_t valuex(size_t last, size_t step, size_t pos)
|
|
|
|
{
|
|
|
|
return last;
|
|
|
|
}
|
|
|
|
|
2018-01-15 14:56:22 +01:00
|
|
|
static inline size_t value(size_t last, size_t max, size_t pos)
|
|
|
|
{
|
|
|
|
return last;
|
|
|
|
}
|
|
|
|
};
|
2018-02-13 16:54:13 +01:00
|
|
|
|
2018-12-21 18:25:45 +01:00
|
|
|
template <class IndexClass, class Expr>
|
|
|
|
class SubExpr : public ExpressionBase
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
SubExpr() = default;
|
|
|
|
|
|
|
|
const IndexClass* mIndPtr;
|
2018-12-21 23:02:35 +01:00
|
|
|
std::intptr_t mSIPtr;
|
2018-12-21 18:25:45 +01:00
|
|
|
size_t mSPos;
|
|
|
|
size_t mMax;
|
|
|
|
|
|
|
|
Expr mExpr;
|
2018-12-21 23:02:35 +01:00
|
|
|
typedef decltype(mkExt(0).extend(mExpr.rootSteps())) ExtType;
|
2018-12-21 18:25:45 +01:00
|
|
|
ExtType mExt;
|
|
|
|
|
2019-02-13 21:59:13 +01:00
|
|
|
const vector<size_t>* mSubSet;
|
2018-12-21 18:25:45 +01:00
|
|
|
|
|
|
|
mutable ExtType mRootSteps;
|
|
|
|
|
|
|
|
public:
|
|
|
|
typedef ExpressionBase EB;
|
|
|
|
|
|
|
|
static constexpr size_t LAYER = Expr::LAYER + 1;
|
2019-07-10 18:14:50 +02:00
|
|
|
static constexpr size_t SIZE = Expr::SIZE + 1;
|
2021-01-24 02:10:06 +01:00
|
|
|
static constexpr size_t NHLAYER = Expr::NHLAYER + 1;
|
2018-12-21 18:25:45 +01:00
|
|
|
|
2022-09-12 01:09:51 +02:00
|
|
|
DEFAULT_MEMBERS_X(SubExpr);
|
2018-12-21 18:25:45 +01:00
|
|
|
|
2022-09-12 01:09:51 +02:00
|
|
|
SubExpr(const Sptr<IndexClass>& indPtr,
|
2018-12-21 23:02:35 +01:00
|
|
|
std::intptr_t siptr,
|
2019-02-13 21:59:13 +01:00
|
|
|
const vector<size_t>* subset, Expr expr);
|
2018-12-21 18:25:45 +01:00
|
|
|
|
2018-12-21 23:41:14 +01:00
|
|
|
SubExpr(const IndexClass* indPtr, std::intptr_t siptr,
|
2019-02-13 21:59:13 +01:00
|
|
|
const vector<size_t>* subset, Expr expr);
|
2018-12-21 18:25:45 +01:00
|
|
|
|
2019-02-26 18:56:57 +01:00
|
|
|
inline void operator()(size_t mlast, DExt last) override final;
|
|
|
|
inline void operator()(size_t mlast, ExtType last) ;
|
|
|
|
inline void operator()(size_t mlast = 0) override final;
|
2018-12-21 18:25:45 +01:00
|
|
|
|
|
|
|
DExt dRootSteps(std::intptr_t iPtrNum = 0) const override final;
|
|
|
|
DExt dExtension() const override final;
|
|
|
|
|
|
|
|
auto rootSteps(std::intptr_t iPtrNum = 0) const -> ExtType;
|
|
|
|
auto extension() const -> ExtType;
|
|
|
|
};
|
|
|
|
|
2021-01-24 02:10:06 +01:00
|
|
|
template <ForType FT, size_t LAYER>
|
|
|
|
struct NHLayer
|
|
|
|
{
|
|
|
|
template <class Expr>
|
|
|
|
static constexpr size_t get()
|
|
|
|
{
|
|
|
|
return Expr::NHLAYER + 1;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <size_t LAYER>
|
|
|
|
struct NHLayer<ForType::HIDDEN,LAYER>
|
|
|
|
{
|
|
|
|
template <class Expr>
|
|
|
|
static constexpr size_t get()
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct NHLayer<ForType::DEFAULT,1>
|
|
|
|
{
|
|
|
|
template <class Expr>
|
|
|
|
static constexpr size_t get()
|
|
|
|
{
|
|
|
|
return Expr::LAYER;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-01-23 19:40:15 +01:00
|
|
|
template <class IndexClass, class Expr, ForType FT, size_t DIV>
|
2018-10-23 20:02:01 +02:00
|
|
|
class For : public ExpressionBase
|
2018-01-05 13:56:16 +01:00
|
|
|
{
|
2018-01-13 18:07:52 +01:00
|
|
|
private:
|
|
|
|
For() = default;
|
|
|
|
|
2021-01-23 19:40:15 +01:00
|
|
|
typedef typename IndexClass::RangeType RangeType;
|
2018-01-13 18:07:52 +01:00
|
|
|
const IndexClass* mIndPtr;
|
2018-01-18 23:14:49 +01:00
|
|
|
size_t mSPos;
|
|
|
|
size_t mMax;
|
2018-09-17 16:21:23 +02:00
|
|
|
size_t mStep;
|
2018-01-13 18:07:52 +01:00
|
|
|
|
2018-10-23 20:02:01 +02:00
|
|
|
Expr mExpr;
|
|
|
|
typedef decltype(mExpr.rootSteps()) ExtType;
|
|
|
|
ExtType mExt;
|
|
|
|
|
|
|
|
mutable ExtType mRootSteps;
|
|
|
|
|
2018-01-05 13:56:16 +01:00
|
|
|
public:
|
2018-10-23 20:02:01 +02:00
|
|
|
typedef ExpressionBase EB;
|
2021-01-24 02:10:06 +01:00
|
|
|
|
2018-02-12 00:11:24 +01:00
|
|
|
static constexpr size_t LAYER = Expr::LAYER + 1;
|
|
|
|
static constexpr size_t SIZE = Expr::SIZE;
|
2021-01-23 19:40:15 +01:00
|
|
|
static constexpr size_t MAX = RangeType::SIZE / DIV;
|
2021-01-24 02:10:06 +01:00
|
|
|
static constexpr size_t NHLAYER = (FT == ForType::HIDDEN) ? 0 : Expr::NHLAYER + 1;
|
2022-09-12 01:09:51 +02:00
|
|
|
|
|
|
|
DEFAULT_MEMBERS(For);
|
2021-01-24 02:10:06 +01:00
|
|
|
|
2022-09-12 01:09:51 +02:00
|
|
|
For(const Sptr<IndexClass>& indPtr,
|
2018-09-17 16:21:23 +02:00
|
|
|
size_t step, Expr expr);
|
2018-01-05 13:56:16 +01:00
|
|
|
|
2018-01-13 18:07:52 +01:00
|
|
|
For(const IndexClass* indPtr,
|
2018-09-17 16:21:23 +02:00
|
|
|
size_t step, Expr expr);
|
2018-01-09 17:24:10 +01:00
|
|
|
|
2019-02-26 18:56:57 +01:00
|
|
|
inline void operator()(size_t mlast, DExt last) override final;
|
|
|
|
inline void operator()(size_t mlast, ExtType last) ;
|
|
|
|
inline void operator()(size_t mlast = 0) override final;
|
2018-10-23 20:02:01 +02:00
|
|
|
|
2022-09-12 01:09:51 +02:00
|
|
|
PFor<IndexClass,Expr> parallel() const;
|
2019-01-14 18:39:09 +01:00
|
|
|
|
2018-10-23 20:02:01 +02:00
|
|
|
DExt dRootSteps(std::intptr_t iPtrNum = 0) const override final;
|
|
|
|
DExt dExtension() const override final;
|
|
|
|
|
|
|
|
auto rootSteps(std::intptr_t iPtrNum = 0) const -> ExtType;
|
|
|
|
auto extension() const -> ExtType;
|
|
|
|
|
2018-01-07 16:57:01 +01:00
|
|
|
};
|
2018-01-05 13:56:16 +01:00
|
|
|
|
2018-10-30 15:06:29 +01:00
|
|
|
class DynamicExpression : public ExpressionBase
|
2018-10-21 22:52:01 +02:00
|
|
|
{
|
|
|
|
private:
|
|
|
|
|
2020-08-31 17:49:52 +02:00
|
|
|
size_t mThreadId = 0;
|
2022-09-12 01:09:51 +02:00
|
|
|
Sptr<ExpressionBase> mNext;
|
2018-10-21 22:52:01 +02:00
|
|
|
|
2020-08-31 17:49:52 +02:00
|
|
|
DynamicExpression() : mThreadId(omp_get_thread_num()) {}
|
2018-10-21 22:52:01 +02:00
|
|
|
public:
|
2020-08-31 17:28:00 +02:00
|
|
|
|
2020-07-08 17:55:51 +02:00
|
|
|
static constexpr size_t LAYER = 0;
|
|
|
|
static constexpr size_t SIZE = 0;
|
2021-01-24 02:10:06 +01:00
|
|
|
static constexpr size_t NHLAYER = 0;
|
2020-07-08 17:55:51 +02:00
|
|
|
|
2020-08-29 21:46:07 +02:00
|
|
|
DynamicExpression(const DynamicExpression& in) :
|
|
|
|
mThreadId(omp_get_thread_num()),
|
|
|
|
mNext( (static_cast<int>(in.mThreadId) == omp_get_thread_num()) ?
|
|
|
|
in.mNext : in.mNext->deepCopy()) {}
|
|
|
|
DynamicExpression(DynamicExpression&& in) :
|
|
|
|
mThreadId(omp_get_thread_num()),
|
|
|
|
mNext( (static_cast<int>(in.mThreadId) == omp_get_thread_num()) ?
|
|
|
|
in.mNext : in.mNext->deepCopy()) {}
|
|
|
|
DynamicExpression& operator=(const DynamicExpression& in)
|
|
|
|
{
|
|
|
|
mThreadId = omp_get_thread_num();
|
|
|
|
mNext = (static_cast<int>(in.mThreadId) == omp_get_thread_num()) ?
|
|
|
|
in.mNext : in.mNext->deepCopy();
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
DynamicExpression& operator=(DynamicExpression&& in)
|
|
|
|
{
|
|
|
|
mThreadId = omp_get_thread_num();
|
|
|
|
mNext = (static_cast<int>(in.mThreadId) == omp_get_thread_num()) ?
|
|
|
|
in.mNext : in.mNext->deepCopy();
|
|
|
|
return *this;
|
|
|
|
}
|
2018-10-21 22:52:01 +02:00
|
|
|
|
2022-09-12 01:09:51 +02:00
|
|
|
DynamicExpression(const Sptr<ExpressionBase>& next) :
|
2018-10-27 14:58:34 +02:00
|
|
|
mNext(next)
|
|
|
|
{}
|
2018-10-21 22:52:01 +02:00
|
|
|
|
2020-07-08 17:55:51 +02:00
|
|
|
template <class Expr>
|
|
|
|
DynamicExpression(const ExpressionBase& next) :
|
|
|
|
mNext(std::make_shared<Expr>(next))
|
|
|
|
{}
|
|
|
|
|
2018-10-30 15:06:29 +01:00
|
|
|
template <class Expr>
|
|
|
|
DynamicExpression(Expr ex) : mNext( std::make_shared<Expr>(ex) ) {}
|
|
|
|
|
2022-09-12 01:09:51 +02:00
|
|
|
virtual Sptr<ExpressionBase> deepCopy() const override final
|
2020-08-29 21:46:07 +02:00
|
|
|
{
|
|
|
|
return std::make_shared<DynamicExpression>(*this);
|
|
|
|
}
|
|
|
|
|
2019-02-26 18:56:57 +01:00
|
|
|
inline void operator()(size_t mlast, DExt last) override final;
|
2020-07-08 17:55:51 +02:00
|
|
|
inline void operator()(size_t mlast, DExtT last) { (*this)(mlast,last.get()); }
|
2019-02-26 18:56:57 +01:00
|
|
|
inline void operator()(size_t mlast = 0) override final;
|
2018-10-23 20:02:01 +02:00
|
|
|
|
2018-10-27 14:58:34 +02:00
|
|
|
inline DExt dRootSteps(std::intptr_t iPtrNum = 0) const override final;
|
|
|
|
inline DExt dExtension() const override final;
|
2018-10-23 20:02:01 +02:00
|
|
|
|
2020-08-24 16:35:14 +02:00
|
|
|
inline DExtT rootSteps(std::intptr_t iPtrNum = 0) const { return DExtT(dRootSteps(iPtrNum)); }
|
|
|
|
inline DExtT extension() const { return DExtT(dExtension()); }
|
2020-07-08 17:55:51 +02:00
|
|
|
|
2018-10-21 22:52:01 +02:00
|
|
|
};
|
2018-10-30 15:06:29 +01:00
|
|
|
|
2022-09-12 01:09:51 +02:00
|
|
|
}
|
2018-01-05 13:56:16 +01:00
|
|
|
|
|
|
|
/* ========================= *
|
|
|
|
* --- TEMPLATE CODE --- *
|
|
|
|
* ========================= */
|
|
|
|
|
2018-01-14 22:41:35 +01:00
|
|
|
#include <iostream>
|
|
|
|
|
2021-07-28 20:29:56 +02:00
|
|
|
namespace CNORXZInternal
|
2018-01-05 13:56:16 +01:00
|
|
|
{
|
2020-07-10 00:17:38 +02:00
|
|
|
template <class ExtType>
|
|
|
|
const ExtType& ExtBase::expl() const
|
|
|
|
{
|
2020-08-12 16:48:07 +02:00
|
|
|
return dynamic_cast<const ExtT<ExtType>*>(this)->ext();
|
2020-07-10 00:17:38 +02:00
|
|
|
}
|
2020-07-07 16:42:41 +02:00
|
|
|
|
2018-10-21 22:52:01 +02:00
|
|
|
/*****************
|
|
|
|
* F o r *
|
|
|
|
*****************/
|
|
|
|
|
2021-01-23 19:40:15 +01:00
|
|
|
template <class IndexClass, class Expr, ForType FT, size_t DIV>
|
2022-09-12 01:09:51 +02:00
|
|
|
For<IndexClass,Expr,FT,DIV>::For(const Sptr<IndexClass>& indPtr,
|
2018-09-17 16:21:23 +02:00
|
|
|
size_t step, Expr expr) :
|
2018-12-21 18:25:45 +01:00
|
|
|
mIndPtr(indPtr.get()), mSPos(mIndPtr->pos()), mMax(mIndPtr->max()), mStep(step),
|
2018-10-23 20:02:01 +02:00
|
|
|
mExpr(expr), mExt(mExpr.rootSteps( reinterpret_cast<std::intptr_t>( mIndPtr )))
|
2018-01-15 14:56:22 +01:00
|
|
|
{
|
2021-01-23 19:40:15 +01:00
|
|
|
assert(mMax % DIV == 0);
|
2018-01-15 14:56:22 +01:00
|
|
|
assert(mIndPtr != nullptr);
|
|
|
|
}
|
2018-01-13 18:07:52 +01:00
|
|
|
|
2021-01-23 19:40:15 +01:00
|
|
|
template <class IndexClass, class Expr, ForType FT, size_t DIV>
|
|
|
|
For<IndexClass,Expr,FT,DIV>::For(const IndexClass* indPtr,
|
2018-09-17 16:21:23 +02:00
|
|
|
size_t step, Expr expr) :
|
2018-10-27 14:58:34 +02:00
|
|
|
mIndPtr(indPtr), mSPos(mIndPtr->pos()), mMax(mIndPtr->max()), mStep(step),
|
2018-10-23 20:02:01 +02:00
|
|
|
mExpr(expr), mExt(mExpr.rootSteps( reinterpret_cast<std::intptr_t>( mIndPtr )))
|
2018-01-15 14:56:22 +01:00
|
|
|
{
|
2021-01-24 00:10:14 +01:00
|
|
|
//VCHECK(mMax);
|
|
|
|
//VCHECK(DIV);
|
|
|
|
//assert(mMax % DIV == 0);
|
2018-01-15 14:56:22 +01:00
|
|
|
assert(mIndPtr != nullptr);
|
|
|
|
}
|
2018-10-23 20:02:01 +02:00
|
|
|
|
2021-01-23 19:40:15 +01:00
|
|
|
template <class IndexClass, class Expr, ForType FT, size_t DIV>
|
|
|
|
inline void For<IndexClass,Expr,FT,DIV>::operator()(size_t mlast, DExt last)
|
2018-10-23 20:02:01 +02:00
|
|
|
{
|
2020-07-07 16:42:41 +02:00
|
|
|
operator()(mlast, std::dynamic_pointer_cast<ExtT<ExtType>>(last)->ext());
|
|
|
|
//operator()(mlast, *reinterpret_cast<ExtType const*>(last.first));
|
2018-10-23 20:02:01 +02:00
|
|
|
}
|
2018-01-07 22:33:34 +01:00
|
|
|
|
2021-01-23 19:40:15 +01:00
|
|
|
template <class IndexClass, class Expr, ForType FT, size_t DIV>
|
|
|
|
inline void For<IndexClass,Expr,FT,DIV>::operator()(size_t mlast,
|
2019-02-26 18:56:57 +01:00
|
|
|
ExtType last)
|
2018-01-05 13:56:16 +01:00
|
|
|
{
|
2018-02-13 16:54:13 +01:00
|
|
|
typedef typename IndexClass::RangeType RangeType;
|
2021-01-23 19:40:15 +01:00
|
|
|
for(size_t pos = 0u; pos != ForBound<RangeType::ISSTATIC>::template bound<RangeType::SIZE,DIV>(mMax); ++pos){
|
2018-09-17 16:34:47 +02:00
|
|
|
const size_t mnpos = PosForward<FT>::valuex(mlast, mStep, pos);
|
2018-10-27 14:58:34 +02:00
|
|
|
const ExtType npos = last + mExt*pos;
|
|
|
|
mExpr(mnpos, npos);
|
2018-01-09 17:24:10 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-23 19:40:15 +01:00
|
|
|
template <class IndexClass, class Expr, ForType FT, size_t DIV>
|
|
|
|
inline void For<IndexClass,Expr,FT,DIV>::operator()(size_t mlast)
|
2018-01-09 17:24:10 +01:00
|
|
|
{
|
2018-02-13 16:54:13 +01:00
|
|
|
typedef typename IndexClass::RangeType RangeType;
|
2020-07-13 13:40:39 +02:00
|
|
|
ExtType last = rootSteps();
|
|
|
|
last.zero();
|
2021-01-23 19:40:15 +01:00
|
|
|
for(size_t pos = 0u; pos != ForBound<RangeType::ISSTATIC>::template bound<RangeType::SIZE,DIV>(mMax); ++pos){
|
2018-09-17 16:34:47 +02:00
|
|
|
const size_t mnpos = PosForward<FT>::valuex(mlast, mStep, pos);
|
2018-10-27 14:58:34 +02:00
|
|
|
const ExtType npos = last + mExt*pos;
|
|
|
|
mExpr(mnpos, npos);
|
2018-01-05 13:56:16 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-23 20:02:01 +02:00
|
|
|
|
2021-01-23 19:40:15 +01:00
|
|
|
template <class IndexClass, class Expr, ForType FT, size_t DIV>
|
|
|
|
auto For<IndexClass,Expr,FT,DIV>::rootSteps(std::intptr_t iPtrNum) const
|
2018-10-23 20:02:01 +02:00
|
|
|
-> ExtType
|
|
|
|
{
|
|
|
|
return mExpr.rootSteps(iPtrNum);
|
|
|
|
}
|
|
|
|
|
2021-01-23 19:40:15 +01:00
|
|
|
template <class IndexClass, class Expr, ForType FT, size_t DIV>
|
|
|
|
auto For<IndexClass,Expr,FT,DIV>::extension() const
|
2018-10-23 20:02:01 +02:00
|
|
|
-> ExtType
|
|
|
|
{
|
|
|
|
return mExt;
|
|
|
|
}
|
|
|
|
|
2021-01-23 19:40:15 +01:00
|
|
|
template <class IndexClass, class Expr, ForType FT, size_t DIV>
|
|
|
|
DExt For<IndexClass,Expr,FT,DIV>::dRootSteps(std::intptr_t iPtrNum) const
|
2018-10-23 20:02:01 +02:00
|
|
|
{
|
2020-08-12 16:48:07 +02:00
|
|
|
return std::make_shared<ExtT<ExtType>>(rootSteps(iPtrNum));
|
2020-07-07 16:42:41 +02:00
|
|
|
//mRootSteps = rootSteps(iPtrNum);
|
|
|
|
//return std::make_pair<size_t const*,size_t>(reinterpret_cast<size_t const*>(&mRootSteps),
|
|
|
|
// sizeof(ExtType)/sizeof(size_t));
|
2018-10-23 20:02:01 +02:00
|
|
|
}
|
|
|
|
|
2021-01-23 19:40:15 +01:00
|
|
|
template <class IndexClass, class Expr, ForType FT, size_t DIV>
|
|
|
|
DExt For<IndexClass,Expr,FT,DIV>::dExtension() const
|
2018-10-23 20:02:01 +02:00
|
|
|
{
|
2020-08-12 16:48:07 +02:00
|
|
|
return std::make_shared<ExtT<ExtType>>(mExt);
|
2020-07-07 16:42:41 +02:00
|
|
|
//return std::make_pair<size_t const*,size_t>(reinterpret_cast<size_t const*>(&mExt),
|
|
|
|
// sizeof(ExtType)/sizeof(size_t));
|
2018-10-23 20:02:01 +02:00
|
|
|
}
|
2018-08-07 23:15:31 +02:00
|
|
|
|
2021-01-23 19:40:15 +01:00
|
|
|
template <class IndexClass, class Expr, ForType FT, size_t DIV>
|
|
|
|
PFor<IndexClass,Expr,DIV> For<IndexClass,Expr,FT,DIV>::parallel() const
|
2019-01-14 18:39:09 +01:00
|
|
|
{
|
|
|
|
static_assert(FT == ForType::DEFAULT, "hidden for not parallelizable");
|
2021-01-23 19:40:15 +01:00
|
|
|
return PFor<IndexClass,Expr,DIV>(mIndPtr, mStep, mExpr);
|
2019-01-14 18:39:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************
|
|
|
|
* P F o r *
|
|
|
|
******************/
|
|
|
|
|
2021-01-23 19:40:15 +01:00
|
|
|
template <class IndexClass, class Expr, size_t DIV>
|
2022-09-12 01:09:51 +02:00
|
|
|
PFor<IndexClass,Expr,DIV>::PFor(const Sptr<IndexClass>& indPtr,
|
2019-01-14 18:39:09 +01:00
|
|
|
size_t step, Expr expr) :
|
|
|
|
mIndPtr(indPtr.get()), mSPos(mIndPtr->pos()), mMax(mIndPtr->max()), mStep(step),
|
|
|
|
mExpr(expr), mExt(mExpr.rootSteps( reinterpret_cast<std::intptr_t>( mIndPtr )))
|
|
|
|
{
|
2021-01-24 00:10:14 +01:00
|
|
|
//assert(mMax % DIV == 0);
|
2019-01-14 18:39:09 +01:00
|
|
|
assert(mIndPtr != nullptr);
|
|
|
|
}
|
|
|
|
|
2021-01-23 19:40:15 +01:00
|
|
|
template <class IndexClass, class Expr, size_t DIV>
|
|
|
|
PFor<IndexClass,Expr,DIV>::PFor(const IndexClass* indPtr,
|
2019-01-14 18:39:09 +01:00
|
|
|
size_t step, Expr expr) :
|
|
|
|
mIndPtr(indPtr), mSPos(mIndPtr->pos()), mMax(mIndPtr->max()), mStep(step),
|
|
|
|
mExpr(expr), mExt(mExpr.rootSteps( reinterpret_cast<std::intptr_t>( mIndPtr )))
|
|
|
|
{
|
2021-01-23 19:40:15 +01:00
|
|
|
assert(mMax % DIV == 0);
|
2019-01-14 18:39:09 +01:00
|
|
|
assert(mIndPtr != nullptr);
|
|
|
|
}
|
|
|
|
|
2021-01-23 19:40:15 +01:00
|
|
|
template <class IndexClass, class Expr, size_t DIV>
|
|
|
|
inline void PFor<IndexClass,Expr,DIV>::operator()(size_t mlast, DExt last)
|
2019-01-14 18:39:09 +01:00
|
|
|
{
|
2020-07-07 16:42:41 +02:00
|
|
|
operator()(mlast, std::dynamic_pointer_cast<ExtT<ExtType>>(last)->ext());
|
|
|
|
//operator()(mlast, *reinterpret_cast<ExtType const*>(last.first));
|
2019-01-14 18:39:09 +01:00
|
|
|
}
|
|
|
|
|
2021-01-23 19:40:15 +01:00
|
|
|
template <class IndexClass, class Expr, size_t DIV>
|
|
|
|
inline void PFor<IndexClass,Expr,DIV>::operator()(size_t mlast,
|
2019-02-26 18:56:57 +01:00
|
|
|
ExtType last)
|
2019-01-14 18:39:09 +01:00
|
|
|
{
|
2019-01-15 17:41:43 +01:00
|
|
|
CHECK;
|
2019-01-14 18:39:09 +01:00
|
|
|
typedef typename IndexClass::RangeType RangeType;
|
|
|
|
int pos = 0;
|
|
|
|
size_t mnpos = 0;
|
|
|
|
ExtType npos;
|
2019-03-06 13:08:33 +01:00
|
|
|
#pragma omp parallel shared(mExpr) private(pos,mnpos,npos)
|
2019-01-14 18:39:09 +01:00
|
|
|
{
|
2019-03-06 13:08:33 +01:00
|
|
|
auto expr = mExpr;
|
2019-01-14 18:39:09 +01:00
|
|
|
#pragma omp for nowait
|
2021-01-23 19:40:15 +01:00
|
|
|
for(pos = 0; pos < static_cast<int>(ForBound<RangeType::ISSTATIC>::template bound<RangeType::SIZE,DIV>(mMax)); pos++){
|
2019-01-14 18:39:09 +01:00
|
|
|
mnpos = PosForward<ForType::DEFAULT>::valuex(mlast, mStep, pos);
|
|
|
|
npos = last + mExt*static_cast<size_t>(pos);
|
|
|
|
expr(mnpos, npos);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-23 19:40:15 +01:00
|
|
|
template <class IndexClass, class Expr, size_t DIV>
|
|
|
|
inline void PFor<IndexClass,Expr,DIV>::operator()(size_t mlast)
|
2019-01-14 18:39:09 +01:00
|
|
|
{
|
2019-01-15 17:41:43 +01:00
|
|
|
CHECK;
|
2020-07-13 13:40:39 +02:00
|
|
|
ExtType last = rootSteps();
|
|
|
|
last.zero();
|
2019-01-14 18:39:09 +01:00
|
|
|
int pos = 0;
|
|
|
|
size_t mnpos = 0;
|
2020-07-13 13:40:39 +02:00
|
|
|
ExtType npos = rootSteps();
|
|
|
|
npos.zero();
|
2019-03-06 13:08:33 +01:00
|
|
|
#pragma omp parallel shared(mExpr) private(pos,mnpos,npos)
|
2019-01-14 18:39:09 +01:00
|
|
|
{
|
2019-03-06 13:08:33 +01:00
|
|
|
auto expr = mExpr;
|
2019-01-14 18:39:09 +01:00
|
|
|
#pragma omp for nowait
|
2021-01-23 19:40:15 +01:00
|
|
|
for(pos = 0; pos < static_cast<int>(ForBound<RangeType::ISSTATIC>::template bound<RangeType::SIZE,DIV>(mMax)); pos++){
|
2019-01-14 18:39:09 +01:00
|
|
|
mnpos = PosForward<ForType::DEFAULT>::valuex(mlast, mStep, pos);
|
|
|
|
npos = last + mExt*static_cast<size_t>(pos);
|
|
|
|
expr(mnpos, npos);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-23 19:40:15 +01:00
|
|
|
template <class IndexClass, class Expr, size_t DIV>
|
|
|
|
auto PFor<IndexClass,Expr,DIV>::rootSteps(std::intptr_t iPtrNum) const
|
2019-01-14 18:39:09 +01:00
|
|
|
-> ExtType
|
|
|
|
{
|
|
|
|
return mExpr.rootSteps(iPtrNum);
|
|
|
|
}
|
|
|
|
|
2021-01-23 19:40:15 +01:00
|
|
|
template <class IndexClass, class Expr, size_t DIV>
|
|
|
|
auto PFor<IndexClass,Expr,DIV>::extension() const
|
2019-01-14 18:39:09 +01:00
|
|
|
-> ExtType
|
|
|
|
{
|
|
|
|
return mExt;
|
|
|
|
}
|
|
|
|
|
2021-01-23 19:40:15 +01:00
|
|
|
template <class IndexClass, class Expr, size_t DIV>
|
|
|
|
DExt PFor<IndexClass,Expr,DIV>::dRootSteps(std::intptr_t iPtrNum) const
|
2019-01-14 18:39:09 +01:00
|
|
|
{
|
2020-08-12 16:48:07 +02:00
|
|
|
return std::make_shared<ExtT<ExtType>>(rootSteps(iPtrNum));
|
2020-07-07 16:42:41 +02:00
|
|
|
//mRootSteps = rootSteps(iPtrNum);
|
|
|
|
//return std::make_pair<size_t const*,size_t>(reinterpret_cast<size_t const*>(&mRootSteps),
|
|
|
|
// sizeof(ExtType)/sizeof(size_t));
|
2019-01-14 18:39:09 +01:00
|
|
|
}
|
|
|
|
|
2021-01-23 19:40:15 +01:00
|
|
|
template <class IndexClass, class Expr, size_t DIV>
|
|
|
|
DExt PFor<IndexClass,Expr,DIV>::dExtension() const
|
2019-01-14 18:39:09 +01:00
|
|
|
{
|
2020-08-12 16:48:07 +02:00
|
|
|
return std::make_shared<ExtT<ExtType>>(mExt);
|
2020-07-07 16:42:41 +02:00
|
|
|
//return std::make_pair<size_t const*,size_t>(reinterpret_cast<size_t const*>(&mExt),
|
|
|
|
// sizeof(ExtType)/sizeof(size_t));
|
2019-01-14 18:39:09 +01:00
|
|
|
}
|
|
|
|
|
2018-10-21 22:52:01 +02:00
|
|
|
/************************
|
|
|
|
* SingleExpression *
|
|
|
|
************************/
|
2018-08-07 23:15:31 +02:00
|
|
|
|
|
|
|
template <class IndexClass, class Expr>
|
2022-09-12 01:09:51 +02:00
|
|
|
SingleExpression<IndexClass,Expr>::SingleExpression(const Sptr<IndexClass>& indPtr,
|
2018-10-21 22:52:01 +02:00
|
|
|
Expr expr) :
|
2018-10-23 20:02:01 +02:00
|
|
|
mIndPtr(indPtr.get()), mSPos(mIndPtr->pos()), mMax(mIndPtr->max()),
|
|
|
|
mExpr(expr), mExt(mExpr.rootSteps( reinterpret_cast<std::intptr_t>( mIndPtr )))
|
2018-08-07 23:15:31 +02:00
|
|
|
{
|
|
|
|
assert(mIndPtr != nullptr);
|
|
|
|
//VCHECK(mIndPtr->id());
|
|
|
|
//VCHECK(mIndPtr->max());
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class IndexClass, class Expr>
|
|
|
|
SingleExpression<IndexClass,Expr>::SingleExpression(const IndexClass* indPtr,
|
|
|
|
Expr expr) :
|
2018-10-23 20:02:01 +02:00
|
|
|
mIndPtr(indPtr), mSPos(mIndPtr->pos()), mMax(mIndPtr->max()),
|
|
|
|
mExpr(expr), mExt(mExpr.rootSteps( reinterpret_cast<std::intptr_t>( mIndPtr )))
|
2018-08-07 23:15:31 +02:00
|
|
|
{
|
|
|
|
assert(mIndPtr != nullptr);
|
|
|
|
//VCHECK(mIndPtr->id());
|
|
|
|
//VCHECK(mIndPtr->max());
|
|
|
|
}
|
2018-10-23 20:02:01 +02:00
|
|
|
|
|
|
|
template <class IndexClass, class Expr>
|
2019-02-26 18:56:57 +01:00
|
|
|
inline void SingleExpression<IndexClass,Expr>::operator()(size_t mlast, DExt last)
|
2018-10-23 20:02:01 +02:00
|
|
|
{
|
2020-07-07 16:42:41 +02:00
|
|
|
operator()(mlast, std::dynamic_pointer_cast<ExtT<ExtType>>(last)->ext());
|
|
|
|
//operator()(mlast, *reinterpret_cast<ExtType const*>(last.first));
|
2018-10-23 20:02:01 +02:00
|
|
|
}
|
|
|
|
|
2018-08-07 23:15:31 +02:00
|
|
|
template <class IndexClass, class Expr>
|
|
|
|
inline void SingleExpression<IndexClass,Expr>::operator()(size_t mlast,
|
2019-02-26 18:56:57 +01:00
|
|
|
ExtType last)
|
2018-08-07 23:15:31 +02:00
|
|
|
{
|
|
|
|
//typedef typename IndexClass::RangeType RangeType;
|
|
|
|
const size_t pos = mIndPtr->pos();
|
|
|
|
const size_t mnpos = PosForward<ForType::DEFAULT>::value(mlast, mMax, pos);
|
2018-10-27 14:58:34 +02:00
|
|
|
const ExtType npos = last + mExt*pos;
|
|
|
|
mExpr(mnpos, npos);
|
2018-08-07 23:15:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class IndexClass, class Expr>
|
2019-02-26 18:56:57 +01:00
|
|
|
inline void SingleExpression<IndexClass,Expr>::operator()(size_t mlast)
|
2018-08-07 23:15:31 +02:00
|
|
|
{
|
|
|
|
//typedef typename IndexClass::RangeType RangeType;
|
2020-07-13 13:40:39 +02:00
|
|
|
ExtType last = rootSteps();
|
|
|
|
last.zero();
|
2018-08-07 23:15:31 +02:00
|
|
|
const size_t pos = mIndPtr->pos();
|
|
|
|
const size_t mnpos = PosForward<ForType::DEFAULT>::value(mlast, mMax, pos);
|
2018-10-27 14:58:34 +02:00
|
|
|
const ExtType npos = last + mExt*pos;
|
|
|
|
mExpr(mlast, last);
|
2018-08-07 23:15:31 +02:00
|
|
|
}
|
2018-10-21 22:52:01 +02:00
|
|
|
|
2018-10-23 20:02:01 +02:00
|
|
|
template <class IndexClass, class Expr>
|
|
|
|
auto SingleExpression<IndexClass,Expr>::rootSteps(std::intptr_t iPtrNum) const
|
|
|
|
-> ExtType
|
|
|
|
{
|
|
|
|
return mExpr.rootSteps(iPtrNum);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class IndexClass, class Expr>
|
|
|
|
auto SingleExpression<IndexClass,Expr>::extension() const
|
|
|
|
-> ExtType
|
|
|
|
{
|
|
|
|
return mExt;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class IndexClass, class Expr>
|
2018-10-27 14:58:34 +02:00
|
|
|
DExt SingleExpression<IndexClass,Expr>::dRootSteps(std::intptr_t iPtrNum) const
|
2018-10-23 20:02:01 +02:00
|
|
|
{
|
2020-08-12 16:48:07 +02:00
|
|
|
return std::make_shared<ExtT<ExtType>>(rootSteps(iPtrNum));
|
2020-07-07 16:42:41 +02:00
|
|
|
//mRootSteps = rootSteps(iPtrNum);
|
|
|
|
//return std::make_pair<size_t const*,size_t>(reinterpret_cast<size_t const*>(&mRootSteps),
|
|
|
|
// sizeof(ExtType)/sizeof(size_t));
|
2018-10-23 20:02:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class IndexClass, class Expr>
|
|
|
|
DExt SingleExpression<IndexClass,Expr>::dExtension() const
|
|
|
|
{
|
2020-08-12 16:48:07 +02:00
|
|
|
return std::make_shared<ExtT<ExtType>>(mExt);
|
2020-07-07 16:42:41 +02:00
|
|
|
//return std::make_pair<size_t const*,size_t>(reinterpret_cast<size_t const*>(&mExt),
|
|
|
|
// sizeof(ExtType)/sizeof(size_t));
|
2018-10-23 20:02:01 +02:00
|
|
|
}
|
2018-08-07 23:15:31 +02:00
|
|
|
|
2018-12-21 18:25:45 +01:00
|
|
|
/****************
|
|
|
|
* SubExpr *
|
|
|
|
****************/
|
2018-12-21 23:02:35 +01:00
|
|
|
|
2018-12-21 18:25:45 +01:00
|
|
|
template <class IndexClass, class Expr>
|
2022-09-12 01:09:51 +02:00
|
|
|
SubExpr<IndexClass,Expr>::SubExpr(const Sptr<IndexClass>& indPtr,
|
2018-12-21 23:02:35 +01:00
|
|
|
std::intptr_t siptr,
|
2019-02-13 21:59:13 +01:00
|
|
|
const vector<size_t>* subset, Expr expr) :
|
2018-12-21 23:02:35 +01:00
|
|
|
mIndPtr(indPtr.get()), mSIPtr(siptr), mSPos(mIndPtr->pos()), mMax(mIndPtr->max()),
|
|
|
|
mExpr(expr),
|
|
|
|
mExt( mkExt(0).extend( mExpr.rootSteps( reinterpret_cast<std::intptr_t>( mIndPtr )) ) ),
|
2018-12-21 23:41:14 +01:00
|
|
|
mSubSet(subset)
|
2018-12-21 18:25:45 +01:00
|
|
|
{
|
|
|
|
assert(mIndPtr != nullptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class IndexClass, class Expr>
|
2018-12-21 23:41:14 +01:00
|
|
|
SubExpr<IndexClass,Expr>::SubExpr(const IndexClass* indPtr, std::intptr_t siptr,
|
2019-02-13 21:59:13 +01:00
|
|
|
const vector<size_t>* subset, Expr expr) :
|
2018-12-21 23:02:35 +01:00
|
|
|
mIndPtr(indPtr), mSIPtr(siptr), mSPos(mIndPtr->pos()), mMax(mIndPtr->max()),
|
|
|
|
mExpr(expr),
|
|
|
|
mExt( mkExt(0).extend( mExpr.rootSteps( reinterpret_cast<std::intptr_t>( mIndPtr )) ) ),
|
2018-12-21 23:41:14 +01:00
|
|
|
mSubSet(subset)
|
2018-12-21 18:25:45 +01:00
|
|
|
{
|
|
|
|
assert(mIndPtr != nullptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class IndexClass, class Expr>
|
2019-02-26 18:56:57 +01:00
|
|
|
inline void SubExpr<IndexClass,Expr>::operator()(size_t mlast, DExt last)
|
2018-12-21 18:25:45 +01:00
|
|
|
{
|
2020-07-07 16:42:41 +02:00
|
|
|
operator()(mlast, std::dynamic_pointer_cast<ExtT<ExtType>>(last)->ext());
|
|
|
|
//operator()(mlast, *reinterpret_cast<ExtType const*>(last.first));
|
2018-12-21 18:25:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class IndexClass, class Expr>
|
|
|
|
inline void SubExpr<IndexClass,Expr>::operator()(size_t mlast,
|
2019-02-26 18:56:57 +01:00
|
|
|
ExtType last)
|
2018-12-21 18:25:45 +01:00
|
|
|
{
|
2018-12-21 23:02:35 +01:00
|
|
|
const size_t pos = (*mSubSet)[last.val()];
|
2018-12-21 23:41:14 +01:00
|
|
|
const size_t mnpos = mlast;
|
2018-12-21 18:25:45 +01:00
|
|
|
const ExtType npos = last + mExt*pos;
|
2021-04-11 16:34:01 +02:00
|
|
|
mExpr(mnpos, getX<1>( npos ));
|
2018-12-21 18:25:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class IndexClass, class Expr>
|
2019-02-26 18:56:57 +01:00
|
|
|
inline void SubExpr<IndexClass,Expr>::operator()(size_t mlast)
|
2018-12-21 18:25:45 +01:00
|
|
|
{
|
2020-07-13 13:40:39 +02:00
|
|
|
ExtType last = rootSteps();
|
|
|
|
last.zero();
|
2018-12-21 23:02:35 +01:00
|
|
|
const size_t pos = (*mSubSet)[last.val()];
|
2018-12-21 23:41:14 +01:00
|
|
|
const size_t mnpos = mlast;
|
2018-12-21 18:25:45 +01:00
|
|
|
const ExtType npos = last + mExt*pos;
|
2021-04-11 16:34:01 +02:00
|
|
|
mExpr(mnpos, getX<1>( npos ));
|
2018-12-21 18:25:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template <class IndexClass, class Expr>
|
|
|
|
auto SubExpr<IndexClass,Expr>::rootSteps(std::intptr_t iPtrNum) const
|
|
|
|
-> ExtType
|
|
|
|
{
|
2018-12-21 23:02:35 +01:00
|
|
|
return mkExt(iPtrNum == mSIPtr ? 1 : 0).extend(mExpr.rootSteps(iPtrNum));
|
2018-12-21 18:25:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class IndexClass, class Expr>
|
|
|
|
auto SubExpr<IndexClass,Expr>::extension() const
|
|
|
|
-> ExtType
|
|
|
|
{
|
|
|
|
return mExt;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class IndexClass, class Expr>
|
|
|
|
DExt SubExpr<IndexClass,Expr>::dRootSteps(std::intptr_t iPtrNum) const
|
|
|
|
{
|
2020-08-12 16:48:07 +02:00
|
|
|
return std::make_shared<ExtT<ExtType>>(rootSteps(iPtrNum));
|
2020-07-07 16:42:41 +02:00
|
|
|
//mRootSteps = rootSteps(iPtrNum);
|
|
|
|
//return std::make_pair<size_t const*,size_t>(reinterpret_cast<size_t const*>(&mRootSteps),
|
|
|
|
//sizeof(ExtType)/sizeof(size_t));
|
2018-12-21 18:25:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class IndexClass, class Expr>
|
|
|
|
DExt SubExpr<IndexClass,Expr>::dExtension() const
|
|
|
|
{
|
2020-08-12 16:48:07 +02:00
|
|
|
return std::make_shared<ExtT<ExtType>>(mExt);
|
2020-07-07 16:42:41 +02:00
|
|
|
//return std::make_pair<size_t const*,size_t>(reinterpret_cast<size_t const*>(&mExt),
|
|
|
|
// sizeof(ExtType)/sizeof(size_t));
|
2018-12-21 18:25:45 +01:00
|
|
|
}
|
|
|
|
|
2018-10-21 22:52:01 +02:00
|
|
|
/***************************
|
2018-10-30 15:06:29 +01:00
|
|
|
* DynamicExpression *
|
2018-10-21 22:52:01 +02:00
|
|
|
***************************/
|
|
|
|
|
2019-02-26 18:56:57 +01:00
|
|
|
inline void DynamicExpression::operator()(size_t mlast, DExt last)
|
2018-10-27 14:58:34 +02:00
|
|
|
{
|
|
|
|
(*mNext)(mlast,last);
|
|
|
|
}
|
|
|
|
|
2019-02-26 18:56:57 +01:00
|
|
|
inline void DynamicExpression::operator()(size_t mlast)
|
2018-10-27 14:58:34 +02:00
|
|
|
{
|
|
|
|
(*mNext)(mlast);
|
|
|
|
}
|
|
|
|
|
2018-10-30 15:06:29 +01:00
|
|
|
inline DExt DynamicExpression::dRootSteps(std::intptr_t iPtrNum) const
|
2018-10-27 14:58:34 +02:00
|
|
|
{
|
|
|
|
return mNext->dRootSteps(iPtrNum);
|
|
|
|
}
|
|
|
|
|
2018-10-30 15:06:29 +01:00
|
|
|
inline DExt DynamicExpression::dExtension() const
|
2018-10-27 14:58:34 +02:00
|
|
|
{
|
|
|
|
return mNext->dExtension();
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************
|
|
|
|
* ExpressionHolder *
|
|
|
|
************************/
|
|
|
|
|
2018-10-21 22:52:01 +02:00
|
|
|
template <class Expr>
|
2018-10-30 15:06:29 +01:00
|
|
|
ExpressionHolder<Expr>::ExpressionHolder(DynamicExpression expr) : mExpr(expr) {}
|
2018-10-21 22:52:01 +02:00
|
|
|
|
|
|
|
template <class Expr>
|
2019-02-26 18:56:57 +01:00
|
|
|
inline void ExpressionHolder<Expr>::operator()(size_t mlast, DExt last)
|
2018-08-07 23:15:31 +02:00
|
|
|
{
|
2018-10-27 14:58:34 +02:00
|
|
|
mExpr(mlast,last);
|
2018-10-21 22:52:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class Expr>
|
2019-02-26 18:56:57 +01:00
|
|
|
inline void ExpressionHolder<Expr>::operator()(size_t mlast, ExtType last)
|
2018-10-21 22:52:01 +02:00
|
|
|
{
|
2018-10-30 15:06:29 +01:00
|
|
|
mExpr(mlast,
|
2020-08-12 16:48:07 +02:00
|
|
|
std::make_shared<ExtT<ExtType>>(last));
|
2018-08-07 23:15:31 +02:00
|
|
|
}
|
|
|
|
|
2018-10-23 20:02:01 +02:00
|
|
|
template <class Expr>
|
2019-02-26 18:56:57 +01:00
|
|
|
inline void ExpressionHolder<Expr>::operator()(size_t mlast)
|
2018-10-23 20:02:01 +02:00
|
|
|
{
|
2018-10-27 14:58:34 +02:00
|
|
|
mExpr(mlast);
|
2018-10-23 20:02:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class Expr>
|
2018-10-27 14:58:34 +02:00
|
|
|
DExt ExpressionHolder<Expr>::dRootSteps(std::intptr_t iPtrNum) const
|
2018-10-23 20:02:01 +02:00
|
|
|
{
|
2018-10-27 14:58:34 +02:00
|
|
|
return mExpr.dRootSteps(iPtrNum);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Expr>
|
|
|
|
DExt ExpressionHolder<Expr>::dExtension() const
|
|
|
|
{
|
|
|
|
return mExpr.dExtension();
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Expr>
|
|
|
|
auto ExpressionHolder<Expr>::rootSteps(std::intptr_t iPtrNum) const
|
|
|
|
-> ExtType
|
|
|
|
{
|
2020-07-08 11:13:19 +02:00
|
|
|
return std::dynamic_pointer_cast<ExtT<ExtType>>(mExpr.dRootSteps(iPtrNum))->ext();
|
2020-07-07 16:42:41 +02:00
|
|
|
//return *reinterpret_cast<ExtType const*>( mExpr.dRootSteps(iPtrNum).first );
|
2018-10-27 14:58:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class Expr>
|
|
|
|
auto ExpressionHolder<Expr>::extension() const
|
|
|
|
-> ExtType
|
|
|
|
{
|
2020-07-08 11:13:19 +02:00
|
|
|
return std::dynamic_pointer_cast<ExtT<ExtType>>(mExpr.dExtension())->ext();
|
2020-07-07 16:42:41 +02:00
|
|
|
//return *reinterpret_cast<ExtType const*>( mExpr.dExtension().first );
|
2018-10-23 20:02:01 +02:00
|
|
|
}
|
|
|
|
|
2018-10-27 14:58:34 +02:00
|
|
|
|
2018-01-13 18:07:52 +01:00
|
|
|
|
2021-07-28 20:29:56 +02:00
|
|
|
} // namespace CNORXZInternal
|
2018-01-05 13:56:16 +01:00
|
|
|
|
|
|
|
#endif
|