minor changes

This commit is contained in:
Christian Zimmermann 2021-01-14 16:26:53 +01:00
parent ec430efcc6
commit 6ecbe5ff27
2 changed files with 51 additions and 5 deletions

View file

@ -174,7 +174,9 @@ namespace MultiArrayTools
{
ExtType last = rootSteps();
last.zero();
mDataPtr[OpIndexResolve<OIA>::get(start,last)] = mSec.get(last.next());
//mDataPtr[OpIndexResolve<OIA>::get(start,last)] = mSec.get(last.next());
IAssign::f(mDataPtr,OpIndexResolve<OIA>::get(start,last),mSec,last.next());
//mDataPtr[last.val()] = mSec.get(last.next());
}
@ -182,7 +184,8 @@ namespace MultiArrayTools
inline void AssignmentExpr2<T,Target,OpClass,OIA>::operator()(size_t start, ExtType last)
{
//CHECK;
mDataPtr[OpIndexResolve<OIA>::get(start,last)] = mSec.get(last.next());
//mDataPtr[OpIndexResolve<OIA>::get(start,last)] = mSec.get(last.next());
IAssign::f(mDataPtr,OpIndexResolve<OIA>::get(start,last),mSec,last.next());
}
template <typename T, class Target, class OpClass, OpIndexAff OIA>
@ -303,7 +306,9 @@ namespace MultiArrayTools
template <typename T, class Target, class OpClass, OpIndexAff OIA>
inline void AddExpr<T,Target,OpClass,OIA>::operator()(size_t start, ExtType last)
{
mDataPtr[OpIndexResolve<OIA>::get(start,last)] += mSec.get(last.next());
//IPlus::f(mDataPtr[OpIndexResolve<OIA>::get(start,last)],mSec.get(last.next()));
IPlus::f(mDataPtr,OpIndexResolve<OIA>::get(start,last),mSec,last.next());
//mDataPtr[OpIndexResolve<OIA>::get(start,last)] += mSec.get(last.next());
//mDataPtr[start] += mSec.get(last.next());
//mDataPtr[start] += mSec.template get<ExtType>(last);
}
@ -313,7 +318,9 @@ namespace MultiArrayTools
{
ExtType last = rootSteps();
last.zero();
mDataPtr[OpIndexResolve<OIA>::get(start,last)] += mSec.get(last.next());
//mDataPtr[OpIndexResolve<OIA>::get(start,last)] += mSec.get(last.next());
//IPlus::f(mDataPtr[OpIndexResolve<OIA>::get(start,last)],mSec.get(last.next()));
IPlus::f(mDataPtr,OpIndexResolve<OIA>::get(start,last),mSec,last.next());
}
template <typename T, class Target, class OpClass, OpIndexAff OIA>

View file

@ -204,6 +204,45 @@ namespace MultiArrayTools
TARGET = 1
};
struct IAssign
{
template <typename T, typename Op, class ExtType>
static inline void f(T*& t, size_t pos, const Op& op, ExtType e)
{
//a = b;
t[pos] = op.get(e);
}
};
template <typename V>
struct IVAssign
{
template <typename T1, typename T2>
static inline void f(T1& a, const T2& b)
{
*reinterpret_cast<V*>(&a) = b;
}
};
struct IPlus
{
template <typename T, typename Op, class ExtType>
static inline void f(T*& t, size_t pos, const Op& op, ExtType e)
{
t[pos] += op.get(e);
}
};
template <typename V>
struct IVPlus
{
template <typename T1, typename T2>
static inline void f(T1& a, const T2& b)
{
*reinterpret_cast<V*>(&a) += b;
}
};
template <typename T, class Target, class OpClass, OpIndexAff OIA=OpIndexAff::EXTERN>
class AssignmentExpr2 : public ExpressionBase