NOW ALMOST

This commit is contained in:
Christian Zimmermann 2019-02-27 13:37:53 +01:00
parent 6f320fe9e9
commit 09f8074910
4 changed files with 30 additions and 21 deletions

View file

@ -251,7 +251,7 @@ namespace MultiArrayTools
template <typename T, class... Ranges> template <typename T, class... Ranges>
template <class ET> template <class ET>
inline T ConstOperationRoot<T,Ranges...>::get(ET pos) const inline const T& ConstOperationRoot<T,Ranges...>::get(ET pos) const
{ {
return mDataPtr[pos.val()/*+mOff*/]; return mDataPtr[pos.val()/*+mOff*/];
} }
@ -449,7 +449,7 @@ namespace MultiArrayTools
template <typename T, class... Ranges> template <typename T, class... Ranges>
template <class ET> template <class ET>
inline T OperationRoot<T,Ranges...>::get(ET pos) const inline T& OperationRoot<T,Ranges...>::get(ET pos) const
{ {
return mDataPtr[pos.val()/*+mOff*/]; return mDataPtr[pos.val()/*+mOff*/];
} }
@ -504,7 +504,7 @@ namespace MultiArrayTools
template <typename T> template <typename T>
template <class ET> template <class ET>
inline T OperationValue<T>::get(ET pos) const inline const T& OperationValue<T>::get(ET pos) const
{ {
return mVal; return mVal;
} }
@ -595,7 +595,8 @@ namespace MultiArrayTools
// forward loop !!!! // forward loop !!!!
template <typename T, class Op, class IndexType> template <typename T, class Op, class IndexType>
template <class ET> template <class ET>
inline T Contraction<T,Op,IndexType>::get(ET pos) const inline auto Contraction<T,Op,IndexType>::get(ET pos) const
-> decltype(mOp.template get<ET>(pos))
{ {
return mOp.template get<ET>(pos); return mOp.template get<ET>(pos);
} }

View file

@ -197,6 +197,7 @@ namespace MultiArrayTools
typedef ContainerIndex<T,typename Ranges::IndexType...> IndexType; typedef ContainerIndex<T,typename Ranges::IndexType...> IndexType;
static constexpr size_t SIZE = 1; static constexpr size_t SIZE = 1;
static constexpr bool CONT = true;
ConstOperationRoot(const MultiArrayBase<T,Ranges...>& ma, ConstOperationRoot(const MultiArrayBase<T,Ranges...>& ma,
const std::shared_ptr<typename Ranges::IndexType>&... indices); const std::shared_ptr<typename Ranges::IndexType>&... indices);
@ -207,7 +208,7 @@ namespace MultiArrayTools
ConstOperationRoot(const T* data, const IndexType& ind); ConstOperationRoot(const T* data, const IndexType& ind);
template <class ET> template <class ET>
inline T get(ET pos) const; inline const T& get(ET pos) const;
template <class ET> template <class ET>
inline ConstOperationRoot& set(ET pos); inline ConstOperationRoot& set(ET pos);
@ -243,6 +244,7 @@ namespace MultiArrayTools
typedef typename Op::IndexType IndexType; typedef typename Op::IndexType IndexType;
static constexpr size_t SIZE = Op::SIZE; static constexpr size_t SIZE = Op::SIZE;
static constexpr bool CONT = false;
StaticCast(const Op& op); StaticCast(const Op& op);
@ -277,6 +279,7 @@ namespace MultiArrayTools
typedef OperationBase<value_type,MetaOperationRoot<Range> > OT; typedef OperationBase<value_type,MetaOperationRoot<Range> > OT;
static constexpr size_t SIZE = 1; static constexpr size_t SIZE = 1;
static constexpr bool CONT = false;
MetaOperationRoot(const std::shared_ptr<IndexType>& ind); MetaOperationRoot(const std::shared_ptr<IndexType>& ind);
@ -310,6 +313,7 @@ namespace MultiArrayTools
typedef ContainerIndex<T,typename Ranges::IndexType...> IndexType; typedef ContainerIndex<T,typename Ranges::IndexType...> IndexType;
static constexpr size_t SIZE = 1; static constexpr size_t SIZE = 1;
static constexpr bool CONT = true;
OperationRoot(MutableMultiArrayBase<T,Ranges...>& ma, OperationRoot(MutableMultiArrayBase<T,Ranges...>& ma,
const std::shared_ptr<typename Ranges::IndexType>&... indices); const std::shared_ptr<typename Ranges::IndexType>&... indices);
@ -336,7 +340,7 @@ namespace MultiArrayTools
OperationRoot& par(); OperationRoot& par();
template <class ET> template <class ET>
inline T get(ET pos) const; inline T& get(ET pos) const;
template <class ET> template <class ET>
inline OperationRoot& set(ET pos); inline OperationRoot& set(ET pos);
@ -372,11 +376,12 @@ namespace MultiArrayTools
typedef ContainerIndex<T,NullIndex> IndexType; typedef ContainerIndex<T,NullIndex> IndexType;
static constexpr size_t SIZE = 1; static constexpr size_t SIZE = 1;
static constexpr bool CONT = true;
OperationValue(const T& val); OperationValue(const T& val);
template <class ET> template <class ET>
inline T get(ET pos) const; inline const T& get(ET pos) const;
template <class ET> template <class ET>
inline OperationValue& set(ET pos); inline OperationValue& set(ET pos);
@ -441,6 +446,7 @@ namespace MultiArrayTools
static constexpr size_t SIZE = RootSum<Ops...>::SIZE; static constexpr size_t SIZE = RootSum<Ops...>::SIZE;
static constexpr bool FISSTATIC = OpFunction::FISSTATIC; static constexpr bool FISSTATIC = OpFunction::FISSTATIC;
static constexpr bool CONT = false;
private: private:
std::tuple<Ops...> mOps; std::tuple<Ops...> mOps;
@ -501,7 +507,6 @@ namespace MultiArrayTools
} }
template <typename T, class Op, class IndexType> template <typename T, class Op, class IndexType>
class Contraction : public OperationTemplate<T,Contraction<T,Op,IndexType> > class Contraction : public OperationTemplate<T,Contraction<T,Op,IndexType> >
{ {
@ -511,6 +516,7 @@ namespace MultiArrayTools
typedef OperationBase<T,Contraction<T,Op,IndexType> > OT; typedef OperationBase<T,Contraction<T,Op,IndexType> > OT;
static constexpr size_t SIZE = Op::SIZE; static constexpr size_t SIZE = Op::SIZE;
static constexpr bool CONT = Op::CONT;
private: private:
@ -523,7 +529,8 @@ namespace MultiArrayTools
Contraction(const Op& op, std::shared_ptr<IndexType> ind); Contraction(const Op& op, std::shared_ptr<IndexType> ind);
template <class ET> template <class ET>
inline T get(ET pos) const; inline auto get(ET pos) const
-> decltype(mOp.template get<ET>(pos));
template <class ET> template <class ET>
inline Contraction& set(ET pos); inline Contraction& set(ET pos);
@ -547,6 +554,7 @@ namespace MultiArrayTools
typedef OperationTemplate<T,SliceContraction<T,Op,Indices...> > OT; typedef OperationTemplate<T,SliceContraction<T,Op,Indices...> > OT;
static constexpr size_t SIZE = Op::SIZE; static constexpr size_t SIZE = Op::SIZE;
static constexpr bool CONT = false;
private: private:

View file

@ -177,17 +177,17 @@ namespace MultiArrayTools
} }
} }
inline v256 operator+(v256 a, v256 b) inline v256 operator+(const v256& a, const v256& b)
{ {
v256 o; v256 o;
xadd<4>( reinterpret_cast<double*>(&o), reinterpret_cast<const double*>(&a), xadd<4>( o._x, a._x, b._x );
reinterpret_cast<const double*>(&b) );
return o; return o;
} }
inline v256& operator+=(v256& o, v256 a) inline v256& operator+=(v256& o, const v256& a)
{ {
xsadd<4>( reinterpret_cast<double*>(&o), reinterpret_cast<const double*>(&a) ); //xsadd<4>( reinterpret_cast<double*>(&o), reinterpret_cast<const double*>(&a) );
xsadd<4>( o._x, a._x );
return o; return o;
} }
/* /*

View file

@ -36,7 +36,7 @@ namespace MultiArrayHelper
template <size_t N> template <size_t N>
inline MExt(const std::array<size_t,N>& arr); inline MExt(const std::array<size_t,N>& arr);
inline size_t val() const; inline const size_t& val() const;
inline const X& next() const; inline const X& next() const;
inline MExt operator+(const MExt& in) const; inline MExt operator+(const MExt& in) const;
@ -76,7 +76,7 @@ namespace MultiArrayHelper
template <size_t N> template <size_t N>
inline MExt(const std::array<size_t,N>& arr); inline MExt(const std::array<size_t,N>& arr);
inline size_t val() const; inline const size_t& val() const;
inline size_t next() const { return 0; } inline size_t next() const { return 0; }
inline MExt operator+(const MExt& in) const; inline MExt operator+(const MExt& in) const;
@ -151,7 +151,7 @@ namespace MultiArrayHelper
mExt(y.val()), mNext(y.next(), z) {} mExt(y.val()), mNext(y.next(), z) {}
template <class X> template <class X>
inline size_t MExt<X>::val() const inline const size_t& MExt<X>::val() const
{ {
return mExt; return mExt;
} }
@ -196,7 +196,7 @@ namespace MultiArrayHelper
mExt(std::get<NUM>(arr)) {} mExt(std::get<NUM>(arr)) {}
//template <> //template <>
inline size_t MExt<void>::val() const inline const size_t& MExt<void>::val() const
{ {
return mExt; return mExt;
} }