This commit is contained in:
Christian Zimmermann 2021-01-14 23:57:06 +01:00
parent 29b1502e60
commit 68ae7d8428
2 changed files with 20 additions and 105 deletions

View file

@ -174,17 +174,12 @@ namespace MultiArrayTools
{
ExtType last = rootSteps();
last.zero();
//mDataPtr[OpIndexResolve<OIA>::get(start,last)] = mSec.get(last.next());
IOp::f(mDataPtr,OpIndexResolve<OIA>::get(start,last),mSec,last.next());
//mDataPtr[last.val()] = mSec.get(last.next());
}
template <typename T, class IOp, class Target, class OpClass, OpIndexAff OIA>
inline void AssignmentExpr<T,IOp,Target,OpClass,OIA>::operator()(size_t start, ExtType last)
{
//CHECK;
//mDataPtr[OpIndexResolve<OIA>::get(start,last)] = mSec.get(last.next());
IOp::f(mDataPtr,OpIndexResolve<OIA>::get(start,last),mSec,last.next());
}
@ -298,57 +293,7 @@ namespace MultiArrayTools
CHECK;
return nullptr; //???!!!
}
/*
template <typename T, class Target, class OpClass, OpIndexAff OIA>
AddExpr<T,Target,OpClass,OIA>::AddExpr(T* dataPtr, const Target& tar, const OpClass& sec) :
mTar(tar), mSec(sec), mDataPtr(dataPtr) {}
template <typename T, class Target, class OpClass, OpIndexAff OIA>
inline void AddExpr<T,Target,OpClass,OIA>::operator()(size_t start, ExtType last)
{
//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);
}
template <typename T, class Target, class OpClass, OpIndexAff OIA>
inline void AddExpr<T,Target,OpClass,OIA>::operator()(size_t start)
{
ExtType last = rootSteps();
last.zero();
//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>
typename AddExpr<T,Target,OpClass,OIA>::ExtType AddExpr<T,Target,OpClass,OIA>::rootSteps(std::intptr_t iPtrNum) const
{
return mTar.rootSteps(iPtrNum).extend( mSec.rootSteps(iPtrNum) );
//return mSec.rootSteps(iPtrNum);
}
template <typename T, class Target, class OpClass, OpIndexAff OIA>
inline void AddExpr<T,Target,OpClass,OIA>::operator()(size_t mlast, DExt last)
{
(*this)(mlast, std::dynamic_pointer_cast<ExtT<ExtType>>(last)->ext());
}
template <typename T, class Target, class OpClass, OpIndexAff OIA>
inline DExt AddExpr<T,Target,OpClass,OIA>::dRootSteps(std::intptr_t iPtrNum) const
{
return std::make_shared<ExtT<ExtType>>(rootSteps(iPtrNum));
}
template <typename T, class Target, class OpClass, OpIndexAff OIA>
inline DExt AddExpr<T,Target,OpClass,OIA>::dExtension() const
{
CHECK;
return nullptr; //???!!!
}
*/
/****************************
* ConstOperationRoot *
****************************/

View file

@ -16,8 +16,8 @@
#include "pack_num.h"
#include "arith.h"
#include "xfor/xfor.h"
#include "type_operations.h"
namespace MultiArrayTools
{
@ -217,10 +217,10 @@ namespace MultiArrayTools
template <typename V>
struct IVAssign
{
template <typename T1, typename T2>
static inline void f(T1& a, const T2& b)
template <typename T, typename Op, class ExtType>
static inline void f(T*& t, size_t pos, const Op& op, ExtType e)
{
*reinterpret_cast<V*>(&a) = b;
reinterpret_cast<V*>(t)[pos] = op.template vget<V>(e);
}
};
@ -236,13 +236,26 @@ namespace MultiArrayTools
template <typename V>
struct IVPlus
{
template <typename T1, typename T2>
static inline void f(T1& a, const T2& b)
template <typename T, typename Op, class ExtType>
static inline void f(T*& t, size_t pos, const Op& op, ExtType e)
{
*reinterpret_cast<V*>(&a) += b;
reinterpret_cast<V*>(t)[pos] += op.template vget<V>(e);
}
};
template <class T>
struct VType
{
typedef T type;
static constexpr size_t MULT = sizeof(type)/sizeof(T);
};
template <>
struct VType<double>
{
typedef v256 type;
static constexpr size_t MULT = sizeof(type)/sizeof(double);
};
template <typename T, class IOp, class Target, class OpClass, OpIndexAff OIA=OpIndexAff::EXTERN>
class AssignmentExpr : public ExpressionBase
@ -376,49 +389,6 @@ namespace MultiArrayTools
return MOp<T,Ops...>(exprs...);
}
//template <typename T, class OpClass>
/*
template <typename T, class Target, class OpClass, OpIndexAff OIA=OpIndexAff::EXTERN>
class AddExpr : public ExpressionBase
{
private:
AddExpr() = default;
Target mTar;
OpClass mSec;
T* mDataPtr;
public:
static constexpr size_t LAYER = 0;
static constexpr size_t SIZE = Target::SIZE + OpClass::SIZE;
typedef decltype(mTar.rootSteps(0).extend( mSec.rootSteps(0) )) ExtType;
// static constexpr size_t LAYER = 0;
//static constexpr size_t SIZE = OpClass::SIZE;
//typedef decltype(mSec.rootSteps()) ExtType;
//AddExpr(T* dataPtr, const OpClass& sec);
AddExpr(T* dataPtr, const Target& tar, const OpClass& sec);
AddExpr(const AddExpr& in) = default;
AddExpr(AddExpr&& in) = default;
AddExpr& operator=(const AddExpr& in) = default;
AddExpr& operator=(AddExpr&& in) = default;
virtual std::shared_ptr<ExpressionBase> deepCopy() const override final
{
return std::make_shared<AddExpr<T,Target,OpClass,OIA>>(*this);
}
inline void operator()(size_t start = 0);
inline void operator()(size_t start, ExtType last);
auto rootSteps(std::intptr_t iPtrNum = 0) const -> ExtType;
inline void operator()(size_t mlast, DExt last) override final;
inline DExt dRootSteps(std::intptr_t iPtrNum = 0) const override final;
inline DExt dExtension() const override final;
};
*/
template <typename T, class... Ranges>
class ConstOperationRoot : public OperationTemplate<T,ConstOperationRoot<T,Ranges...> >
{