diff --git a/src/include/multi_array_operation.cc.h b/src/include/multi_array_operation.cc.h index 83e1cc0..cd9bb24 100644 --- a/src/include/multi_array_operation.cc.h +++ b/src/include/multi_array_operation.cc.h @@ -251,7 +251,7 @@ namespace MultiArrayTools template template - inline T ConstOperationRoot::get(ET pos) const + inline const T& ConstOperationRoot::get(ET pos) const { return mDataPtr[pos.val()/*+mOff*/]; } @@ -449,7 +449,7 @@ namespace MultiArrayTools template template - inline T OperationRoot::get(ET pos) const + inline T& OperationRoot::get(ET pos) const { return mDataPtr[pos.val()/*+mOff*/]; } @@ -504,7 +504,7 @@ namespace MultiArrayTools template template - inline T OperationValue::get(ET pos) const + inline const T& OperationValue::get(ET pos) const { return mVal; } @@ -595,7 +595,8 @@ namespace MultiArrayTools // forward loop !!!! template template - inline T Contraction::get(ET pos) const + inline auto Contraction::get(ET pos) const + -> decltype(mOp.template get(pos)) { return mOp.template get(pos); } diff --git a/src/include/multi_array_operation.h b/src/include/multi_array_operation.h index 89846d5..450e183 100644 --- a/src/include/multi_array_operation.h +++ b/src/include/multi_array_operation.h @@ -197,6 +197,7 @@ namespace MultiArrayTools typedef ContainerIndex IndexType; static constexpr size_t SIZE = 1; + static constexpr bool CONT = true; ConstOperationRoot(const MultiArrayBase& ma, const std::shared_ptr&... indices); @@ -207,7 +208,7 @@ namespace MultiArrayTools ConstOperationRoot(const T* data, const IndexType& ind); template - inline T get(ET pos) const; + inline const T& get(ET pos) const; template inline ConstOperationRoot& set(ET pos); @@ -243,6 +244,7 @@ namespace MultiArrayTools typedef typename Op::IndexType IndexType; static constexpr size_t SIZE = Op::SIZE; + static constexpr bool CONT = false; StaticCast(const Op& op); @@ -277,7 +279,8 @@ namespace MultiArrayTools typedef OperationBase > OT; static constexpr size_t SIZE = 1; - + static constexpr bool CONT = false; + MetaOperationRoot(const std::shared_ptr& ind); template @@ -310,6 +313,7 @@ namespace MultiArrayTools typedef ContainerIndex IndexType; static constexpr size_t SIZE = 1; + static constexpr bool CONT = true; OperationRoot(MutableMultiArrayBase& ma, const std::shared_ptr&... indices); @@ -336,7 +340,7 @@ namespace MultiArrayTools OperationRoot& par(); template - inline T get(ET pos) const; + inline T& get(ET pos) const; template inline OperationRoot& set(ET pos); @@ -372,11 +376,12 @@ namespace MultiArrayTools typedef ContainerIndex IndexType; static constexpr size_t SIZE = 1; + static constexpr bool CONT = true; OperationValue(const T& val); template - inline T get(ET pos) const; + inline const T& get(ET pos) const; template inline OperationValue& set(ET pos); @@ -441,6 +446,7 @@ namespace MultiArrayTools static constexpr size_t SIZE = RootSum::SIZE; static constexpr bool FISSTATIC = OpFunction::FISSTATIC; + static constexpr bool CONT = false; private: std::tuple mOps; @@ -500,7 +506,6 @@ namespace MultiArrayTools return OpMaker::mkOperation(f, ops...); } - template class Contraction : public OperationTemplate > @@ -511,7 +516,8 @@ namespace MultiArrayTools typedef OperationBase > OT; static constexpr size_t SIZE = Op::SIZE; - + static constexpr bool CONT = Op::CONT; + private: Op mOp; @@ -523,7 +529,8 @@ namespace MultiArrayTools Contraction(const Op& op, std::shared_ptr ind); template - inline T get(ET pos) const; + inline auto get(ET pos) const + -> decltype(mOp.template get(pos)); template inline Contraction& set(ET pos); @@ -547,7 +554,8 @@ namespace MultiArrayTools typedef OperationTemplate > OT; static constexpr size_t SIZE = Op::SIZE; - + static constexpr bool CONT = false; + private: mutable Op mOp; diff --git a/src/include/type_operations.h b/src/include/type_operations.h index 8f970d9..d40d68e 100644 --- a/src/include/type_operations.h +++ b/src/include/type_operations.h @@ -177,17 +177,17 @@ namespace MultiArrayTools } } - inline v256 operator+(v256 a, v256 b) + inline v256 operator+(const v256& a, const v256& b) { v256 o; - xadd<4>( reinterpret_cast(&o), reinterpret_cast(&a), - reinterpret_cast(&b) ); + xadd<4>( o._x, a._x, b._x ); return o; } - inline v256& operator+=(v256& o, v256 a) + inline v256& operator+=(v256& o, const v256& a) { - xsadd<4>( reinterpret_cast(&o), reinterpret_cast(&a) ); + //xsadd<4>( reinterpret_cast(&o), reinterpret_cast(&a) ); + xsadd<4>( o._x, a._x ); return o; } /* diff --git a/src/include/xfor/exttype.h b/src/include/xfor/exttype.h index 65718b3..ffaccf2 100644 --- a/src/include/xfor/exttype.h +++ b/src/include/xfor/exttype.h @@ -36,7 +36,7 @@ namespace MultiArrayHelper template inline MExt(const std::array& arr); - inline size_t val() const; + inline const size_t& val() const; inline const X& next() const; inline MExt operator+(const MExt& in) const; @@ -76,7 +76,7 @@ namespace MultiArrayHelper template inline MExt(const std::array& arr); - inline size_t val() const; + inline const size_t& val() const; inline size_t next() const { return 0; } inline MExt operator+(const MExt& in) const; @@ -151,7 +151,7 @@ namespace MultiArrayHelper mExt(y.val()), mNext(y.next(), z) {} template - inline size_t MExt::val() const + inline const size_t& MExt::val() const { return mExt; } @@ -196,7 +196,7 @@ namespace MultiArrayHelper mExt(std::get(arr)) {} //template <> - inline size_t MExt::val() const + inline const size_t& MExt::val() const { return mExt; }