diff --git a/src/include/multi_array_operation.cc.h b/src/include/multi_array_operation.cc.h index d1684de..f0d9c32 100644 --- a/src/include/multi_array_operation.cc.h +++ b/src/include/multi_array_operation.cc.h @@ -174,15 +174,18 @@ namespace MultiArrayTools { ExtType last = rootSteps(); last.zero(); - mDataPtr[OpIndexResolve::get(start,last)] = mSec.get(last.next()); - //mDataPtr[last.val()] = mSec.get(last.next()); + //mDataPtr[OpIndexResolve::get(start,last)] = mSec.get(last.next()); + IAssign::f(mDataPtr,OpIndexResolve::get(start,last),mSec,last.next()); + + //mDataPtr[last.val()] = mSec.get(last.next()); } template inline void AssignmentExpr2::operator()(size_t start, ExtType last) { //CHECK; - mDataPtr[OpIndexResolve::get(start,last)] = mSec.get(last.next()); + //mDataPtr[OpIndexResolve::get(start,last)] = mSec.get(last.next()); + IAssign::f(mDataPtr,OpIndexResolve::get(start,last),mSec,last.next()); } template @@ -303,7 +306,9 @@ namespace MultiArrayTools template inline void AddExpr::operator()(size_t start, ExtType last) { - mDataPtr[OpIndexResolve::get(start,last)] += mSec.get(last.next()); + //IPlus::f(mDataPtr[OpIndexResolve::get(start,last)],mSec.get(last.next())); + IPlus::f(mDataPtr,OpIndexResolve::get(start,last),mSec,last.next()); + //mDataPtr[OpIndexResolve::get(start,last)] += mSec.get(last.next()); //mDataPtr[start] += mSec.get(last.next()); //mDataPtr[start] += mSec.template get(last); } @@ -313,7 +318,9 @@ namespace MultiArrayTools { ExtType last = rootSteps(); last.zero(); - mDataPtr[OpIndexResolve::get(start,last)] += mSec.get(last.next()); + //mDataPtr[OpIndexResolve::get(start,last)] += mSec.get(last.next()); + //IPlus::f(mDataPtr[OpIndexResolve::get(start,last)],mSec.get(last.next())); + IPlus::f(mDataPtr,OpIndexResolve::get(start,last),mSec,last.next()); } template diff --git a/src/include/multi_array_operation.h b/src/include/multi_array_operation.h index 280c1cc..742fb72 100644 --- a/src/include/multi_array_operation.h +++ b/src/include/multi_array_operation.h @@ -204,6 +204,45 @@ namespace MultiArrayTools TARGET = 1 }; + struct IAssign + { + template + static inline void f(T*& t, size_t pos, const Op& op, ExtType e) + { + //a = b; + t[pos] = op.get(e); + } + }; + + template + struct IVAssign + { + template + static inline void f(T1& a, const T2& b) + { + *reinterpret_cast(&a) = b; + } + }; + + struct IPlus + { + template + static inline void f(T*& t, size_t pos, const Op& op, ExtType e) + { + t[pos] += op.get(e); + } + }; + + template + struct IVPlus + { + template + static inline void f(T1& a, const T2& b) + { + *reinterpret_cast(&a) += b; + } + }; + template class AssignmentExpr2 : public ExpressionBase