operations: vget
This commit is contained in:
parent
49812b18e2
commit
ec430efcc6
3 changed files with 118 additions and 1 deletions
|
@ -390,6 +390,13 @@ namespace MultiArrayTools
|
||||||
return mDataPtr[pos.val()/*+mOff*/];
|
return mDataPtr[pos.val()/*+mOff*/];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T, class... Ranges>
|
||||||
|
template <typename V, class ET>
|
||||||
|
inline const V& ConstOperationRoot<T,Ranges...>::vget(ET pos) const
|
||||||
|
{
|
||||||
|
return *reinterpret_cast<const V*>(mDataPtr+pos.val());
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T, class... Ranges>
|
template <typename T, class... Ranges>
|
||||||
template <class ET>
|
template <class ET>
|
||||||
inline ConstOperationRoot<T,Ranges...>& ConstOperationRoot<T,Ranges...>::set(ET pos)
|
inline ConstOperationRoot<T,Ranges...>& ConstOperationRoot<T,Ranges...>::set(ET pos)
|
||||||
|
@ -437,6 +444,14 @@ namespace MultiArrayTools
|
||||||
return static_cast<T>( mOp.get(pos) );
|
return static_cast<T>( mOp.get(pos) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T, class Op>
|
||||||
|
template <typename V, class ET>
|
||||||
|
inline V StaticCast<T,Op>::vget(ET pos) const
|
||||||
|
{
|
||||||
|
assert(0); // !!!
|
||||||
|
return V();
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T, class Op>
|
template <typename T, class Op>
|
||||||
template <class ET>
|
template <class ET>
|
||||||
inline StaticCast<T,Op>& StaticCast<T,Op>::set(ET pos)
|
inline StaticCast<T,Op>& StaticCast<T,Op>::set(ET pos)
|
||||||
|
@ -481,6 +496,15 @@ namespace MultiArrayTools
|
||||||
return (mWorkIndex = pos.val()).meta();
|
return (mWorkIndex = pos.val()).meta();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <class Range>
|
||||||
|
template <typename V, class ET>
|
||||||
|
inline V
|
||||||
|
MetaOperationRoot<Range>::vget(ET pos) const
|
||||||
|
{
|
||||||
|
assert(0); // !!!
|
||||||
|
return V();
|
||||||
|
}
|
||||||
|
|
||||||
template <class Range>
|
template <class Range>
|
||||||
template <class ET>
|
template <class ET>
|
||||||
inline MetaOperationRoot<Range>& MetaOperationRoot<Range>::set(ET pos)
|
inline MetaOperationRoot<Range>& MetaOperationRoot<Range>::set(ET pos)
|
||||||
|
@ -633,6 +657,13 @@ namespace MultiArrayTools
|
||||||
return mDataPtr[pos.val()];
|
return mDataPtr[pos.val()];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T, class... Ranges>
|
||||||
|
template <typename V, class ET>
|
||||||
|
inline V& OperationRoot<T,Ranges...>::vget(ET pos) const
|
||||||
|
{
|
||||||
|
return *reinterpret_cast<V*>(mDataPtr + pos.val());
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T, class... Ranges>
|
template <typename T, class... Ranges>
|
||||||
template <class ET>
|
template <class ET>
|
||||||
inline OperationRoot<T,Ranges...>& OperationRoot<T,Ranges...>::set(ET pos)
|
inline OperationRoot<T,Ranges...>& OperationRoot<T,Ranges...>::set(ET pos)
|
||||||
|
@ -773,6 +804,13 @@ namespace MultiArrayTools
|
||||||
return mDataPtr[pos.val()/*+mOff*/];
|
return mDataPtr[pos.val()/*+mOff*/];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T, class... Ranges>
|
||||||
|
template <typename V, class ET>
|
||||||
|
inline V& ParallelOperationRoot<T,Ranges...>::vget(ET pos) const
|
||||||
|
{
|
||||||
|
return *reinterpret_cast<V*>(mDataPtr+pos.val());
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T, class... Ranges>
|
template <typename T, class... Ranges>
|
||||||
template <class ET>
|
template <class ET>
|
||||||
inline ParallelOperationRoot<T,Ranges...>& ParallelOperationRoot<T,Ranges...>::set(ET pos)
|
inline ParallelOperationRoot<T,Ranges...>& ParallelOperationRoot<T,Ranges...>::set(ET pos)
|
||||||
|
@ -818,6 +856,13 @@ namespace MultiArrayTools
|
||||||
return mVal;
|
return mVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
template <typename V, class ET>
|
||||||
|
inline V OperationValue<T>::vget(ET pos) const
|
||||||
|
{
|
||||||
|
return static_cast<V>(mVal); // implement???!!!
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
template <class ET>
|
template <class ET>
|
||||||
inline OperationValue<T>& OperationValue<T>::set(ET pos)
|
inline OperationValue<T>& OperationValue<T>::set(ET pos)
|
||||||
|
@ -868,6 +913,15 @@ namespace MultiArrayTools
|
||||||
template mkOpExpr<SIZE,ET,OpTuple,OpFunction>(mF, pos, mOps);
|
template mkOpExpr<SIZE,ET,OpTuple,OpFunction>(mF, pos, mOps);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T, class OpFunction, class... Ops>
|
||||||
|
template <typename V, class ET>
|
||||||
|
inline auto Operation<T,OpFunction,Ops...>::vget(ET pos) const
|
||||||
|
{
|
||||||
|
typedef std::tuple<Ops...> OpTuple;
|
||||||
|
return PackNum<sizeof...(Ops)-1>::
|
||||||
|
template mkVOpExpr<SIZE,V,ET,OpTuple,OpFunction>(mF, pos, mOps); // implement!!!
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T, class OpFunction, class... Ops>
|
template <typename T, class OpFunction, class... Ops>
|
||||||
template <class ET>
|
template <class ET>
|
||||||
inline Operation<T,OpFunction,Ops...>& Operation<T,OpFunction,Ops...>::set(ET pos)
|
inline Operation<T,OpFunction,Ops...>& Operation<T,OpFunction,Ops...>::set(ET pos)
|
||||||
|
@ -911,6 +965,14 @@ namespace MultiArrayTools
|
||||||
return mOp.template get<ET>(pos);
|
return mOp.template get<ET>(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T, class Op, class IndexType>
|
||||||
|
template <typename V, class ET>
|
||||||
|
inline auto Contraction<T,Op,IndexType>::vget(ET pos) const
|
||||||
|
-> decltype(mOp.template vget<V,ET>(pos))
|
||||||
|
{
|
||||||
|
return mOp.template vget<V,ET>(pos);
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T, class Op, class IndexType>
|
template <typename T, class Op, class IndexType>
|
||||||
template <class ET>
|
template <class ET>
|
||||||
inline Contraction<T,Op,IndexType>& Contraction<T,Op,IndexType>::set(ET pos)
|
inline Contraction<T,Op,IndexType>& Contraction<T,Op,IndexType>::set(ET pos)
|
||||||
|
|
|
@ -204,6 +204,7 @@ namespace MultiArrayTools
|
||||||
TARGET = 1
|
TARGET = 1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
template <typename T, class Target, class OpClass, OpIndexAff OIA=OpIndexAff::EXTERN>
|
template <typename T, class Target, class OpClass, OpIndexAff OIA=OpIndexAff::EXTERN>
|
||||||
class AssignmentExpr2 : public ExpressionBase
|
class AssignmentExpr2 : public ExpressionBase
|
||||||
{
|
{
|
||||||
|
@ -261,6 +262,10 @@ namespace MultiArrayTools
|
||||||
MOp& operator=(MOp&& in) = default;
|
MOp& operator=(MOp&& in) = default;
|
||||||
|
|
||||||
inline size_t get(ExtType last) const;
|
inline size_t get(ExtType last) const;
|
||||||
|
|
||||||
|
template <typename V>
|
||||||
|
inline size_t vget(ExtType last) const { return get(last); }
|
||||||
|
|
||||||
inline MOp& set(ExtType last);
|
inline MOp& set(ExtType last);
|
||||||
auto rootSteps(std::intptr_t iPtrNum = 0) const -> ExtType;
|
auto rootSteps(std::intptr_t iPtrNum = 0) const -> ExtType;
|
||||||
|
|
||||||
|
@ -301,6 +306,10 @@ namespace MultiArrayTools
|
||||||
|
|
||||||
inline void operator()(size_t start = 0);
|
inline void operator()(size_t start = 0);
|
||||||
inline void get(ExtType last);
|
inline void get(ExtType last);
|
||||||
|
|
||||||
|
template <typename V>
|
||||||
|
inline void vget(ExtType last) { get(last); }
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
|
@ -388,6 +397,9 @@ namespace MultiArrayTools
|
||||||
template <class ET>
|
template <class ET>
|
||||||
inline const T& get(ET pos) const;
|
inline const T& get(ET pos) const;
|
||||||
|
|
||||||
|
template <typename V, class ET>
|
||||||
|
inline const V& vget(ET pos) const;
|
||||||
|
|
||||||
template <class ET>
|
template <class ET>
|
||||||
inline ConstOperationRoot& set(ET pos);
|
inline ConstOperationRoot& set(ET pos);
|
||||||
|
|
||||||
|
@ -427,6 +439,9 @@ namespace MultiArrayTools
|
||||||
template <class ET>
|
template <class ET>
|
||||||
inline T get(ET pos) const;
|
inline T get(ET pos) const;
|
||||||
|
|
||||||
|
template <typename V, class ET>
|
||||||
|
inline V vget(ET pos) const;
|
||||||
|
|
||||||
template <class ET>
|
template <class ET>
|
||||||
inline StaticCast& set(ET pos);
|
inline StaticCast& set(ET pos);
|
||||||
|
|
||||||
|
@ -462,6 +477,9 @@ namespace MultiArrayTools
|
||||||
template <class ET>
|
template <class ET>
|
||||||
inline value_type get(ET pos) const;
|
inline value_type get(ET pos) const;
|
||||||
|
|
||||||
|
template <typename V, class ET>
|
||||||
|
inline V vget(ET pos) const;
|
||||||
|
|
||||||
template <class ET>
|
template <class ET>
|
||||||
inline MetaOperationRoot& set(ET pos);
|
inline MetaOperationRoot& set(ET pos);
|
||||||
|
|
||||||
|
@ -541,6 +559,9 @@ namespace MultiArrayTools
|
||||||
template <class ET>
|
template <class ET>
|
||||||
inline T& get(ET pos) const;
|
inline T& get(ET pos) const;
|
||||||
|
|
||||||
|
template <typename V, class ET>
|
||||||
|
inline V& vget(ET pos) const;
|
||||||
|
|
||||||
template <class ET>
|
template <class ET>
|
||||||
inline OperationRoot& set(ET pos);
|
inline OperationRoot& set(ET pos);
|
||||||
|
|
||||||
|
@ -613,6 +634,9 @@ namespace MultiArrayTools
|
||||||
template <class ET>
|
template <class ET>
|
||||||
inline T& get(ET pos) const;
|
inline T& get(ET pos) const;
|
||||||
|
|
||||||
|
template <typename V, class ET>
|
||||||
|
inline V& vget(ET pos) const;
|
||||||
|
|
||||||
template <class ET>
|
template <class ET>
|
||||||
inline ParallelOperationRoot& set(ET pos);
|
inline ParallelOperationRoot& set(ET pos);
|
||||||
|
|
||||||
|
@ -642,6 +666,9 @@ namespace MultiArrayTools
|
||||||
template <class ET>
|
template <class ET>
|
||||||
inline const T& get(ET pos) const;
|
inline const T& get(ET pos) const;
|
||||||
|
|
||||||
|
template <typename V, class ET>
|
||||||
|
inline V vget(ET pos) const;
|
||||||
|
|
||||||
template <class ET>
|
template <class ET>
|
||||||
inline OperationValue& set(ET pos);
|
inline OperationValue& set(ET pos);
|
||||||
|
|
||||||
|
@ -682,6 +709,9 @@ namespace MultiArrayTools
|
||||||
template <class ET>
|
template <class ET>
|
||||||
inline auto get(ET pos) const;
|
inline auto get(ET pos) const;
|
||||||
|
|
||||||
|
template <typename V, class ET>
|
||||||
|
inline auto vget(ET pos) const;
|
||||||
|
|
||||||
template <class ET>
|
template <class ET>
|
||||||
inline Operation& set(ET pos);
|
inline Operation& set(ET pos);
|
||||||
|
|
||||||
|
@ -754,6 +784,10 @@ namespace MultiArrayTools
|
||||||
inline auto get(ET pos) const
|
inline auto get(ET pos) const
|
||||||
-> decltype(mOp.template get<ET>(pos));
|
-> decltype(mOp.template get<ET>(pos));
|
||||||
|
|
||||||
|
template <typename V, class ET>
|
||||||
|
inline auto vget(ET pos) const
|
||||||
|
-> decltype(mOp.template vget<V,ET>(pos));
|
||||||
|
|
||||||
template <class ET>
|
template <class ET>
|
||||||
inline Contraction& set(ET pos);
|
inline Contraction& set(ET pos);
|
||||||
|
|
||||||
|
|
|
@ -81,6 +81,17 @@ namespace MultiArrayHelper
|
||||||
( f, pos, ops, std::get<N>(ops).get(Getter<NEXT>::template getX<ETuple>( pos )), args...);
|
( f, pos, ops, std::get<N>(ops).get(Getter<NEXT>::template getX<ETuple>( pos )), args...);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <size_t LAST, typename V, class ETuple, class OpTuple, class OpFunction, typename... Args>
|
||||||
|
static inline auto mkVOpExpr(std::shared_ptr<OpFunction> f, const ETuple& pos, const OpTuple& ops, Args... args)
|
||||||
|
{
|
||||||
|
typedef typename std::remove_reference<decltype(std::get<N>(ops))>::type NextOpType;
|
||||||
|
static_assert(LAST >= NextOpType::SIZE, "inconsistent array positions");
|
||||||
|
static constexpr size_t NEXT = LAST - NextOpType::SIZE;
|
||||||
|
typedef decltype(std::get<N>(ops).template vget<V>(Getter<NEXT>::template getX<ETuple>( pos ))) ArgT;
|
||||||
|
return PackNum<N-1>::template mkVOpExpr<NEXT,ETuple,OpTuple,OpFunction,ArgT,Args...>
|
||||||
|
( f, pos, ops, std::get<N>(ops).template vget<V>(Getter<NEXT>::template getX<ETuple>( pos )), args...);
|
||||||
|
}
|
||||||
|
|
||||||
template <class OpTuple, class Expr>
|
template <class OpTuple, class Expr>
|
||||||
static auto mkLoop( const OpTuple& ot, Expr exp )
|
static auto mkLoop( const OpTuple& ot, Expr exp )
|
||||||
-> decltype(std::get<N>(ot).loop( PackNum<N-1>::mkLoop(ot,exp) ))
|
-> decltype(std::get<N>(ot).loop( PackNum<N-1>::mkLoop(ot,exp) ))
|
||||||
|
@ -168,6 +179,16 @@ namespace MultiArrayHelper
|
||||||
//return OpFunction::apply(std::get<0>(ops).get(Getter<0>::template getX<ETuple>( pos )), args...);
|
//return OpFunction::apply(std::get<0>(ops).get(Getter<0>::template getX<ETuple>( pos )), args...);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <size_t LAST, typename V, class ETuple, class OpTuple, class OpFunction, typename... Args>
|
||||||
|
static inline auto mkVOpExpr(std::shared_ptr<OpFunction> f, const ETuple& pos, const OpTuple& ops, const Args&... args)
|
||||||
|
{
|
||||||
|
typedef typename std::remove_reference<decltype(std::get<0>(ops))>::type NextOpType;
|
||||||
|
static constexpr size_t NEXT = LAST - NextOpType::SIZE;
|
||||||
|
static_assert(NEXT == 0, "inconsistent array positions");
|
||||||
|
typedef decltype(std::get<0>(ops).template vget<V>(Getter<0>::template getX<ETuple>( pos ))) ArgT;
|
||||||
|
return Application<OpFunction::FISSTATIC>::template apply<OpFunction,ArgT,Args...>(f, std::get<0>(ops).template vget<V>(Getter<0>::template getX<ETuple>( pos )), args...);
|
||||||
|
}
|
||||||
|
|
||||||
template <class OpTuple, class Expr>
|
template <class OpTuple, class Expr>
|
||||||
static auto mkLoop( const OpTuple& ot, Expr exp )
|
static auto mkLoop( const OpTuple& ot, Expr exp )
|
||||||
-> decltype(std::get<0>(ot).loop( exp ))
|
-> decltype(std::get<0>(ot).loop( exp ))
|
||||||
|
|
Loading…
Reference in a new issue