im com (Operation: remove T?)

This commit is contained in:
Christian Zimmermann 2021-01-15 01:05:58 +01:00
parent 68ae7d8428
commit db92197048
4 changed files with 89 additions and 40 deletions

View file

@ -519,66 +519,91 @@ namespace MultiArrayTools
}
template <typename T, class... Ranges>
template <class OpClass>
auto OperationRoot<T,Ranges...>::assign(const OpClass& in) const
-> decltype(mIndex.ifor(1,in.loop(AssignmentExpr2<T,OperationRoot<T,Ranges...>,OpClass,OpIndexAff::TARGET>
template <class IOp, class OpClass>
auto OperationRoot<T,Ranges...>::asx(const OpClass& in) const
-> decltype(mIndex.ifor(1,in.loop(AssignmentExpr<T,IOp,OperationRoot<T,Ranges...>,OpClass,OpIndexAff::TARGET>
(mOrigDataPtr,*this,in))))
{
static_assert( OpClass::SIZE == decltype(in.rootSteps())::SIZE, "Ext Size mismatch" );
return mIndex.ifor(1,in.loop(AssignmentExpr2<T,OperationRoot<T,Ranges...>,OpClass,OpIndexAff::TARGET>
return mIndex.ifor(1,in.loop(AssignmentExpr<T,IOp,OperationRoot<T,Ranges...>,OpClass,OpIndexAff::TARGET>
(mOrigDataPtr,*this,in)));
}
template <typename T, class... Ranges>
template <class IOp, class OpClass>
auto OperationRoot<T,Ranges...>::asxExpr(const OpClass& in) const
-> decltype(in.loop(AssignmentExpr<T,IOp,OperationRoot<T,Ranges...>,OpClass>
(mOrigDataPtr,*this,in)))
{
static_assert( OpClass::SIZE == decltype(in.rootSteps())::SIZE, "Ext Size mismatch" );
return in.loop(AssignmentExpr<T,IOp,OperationRoot<T,Ranges...>,OpClass>
(mOrigDataPtr,*this,in));
}
template <typename T, class... Ranges>
template <class IOp, class OpClass, class Index>
auto OperationRoot<T,Ranges...>::asx(const OpClass& in, const std::shared_ptr<Index>& i) const
-> decltype(i->ifor(1,in.loop(AssignmentExpr<T,IOp,OperationRoot<T,Ranges...>,OpClass>
(mOrigDataPtr,*this,in))))
{
static_assert( OpClass::SIZE == decltype(in.rootSteps())::SIZE, "Ext Size mismatch" );
return i->ifor(1,in.loop(AssignmentExpr<T,IOp,OperationRoot<T,Ranges...>,OpClass>
(mOrigDataPtr,*this,in)));
}
template <typename T, class... Ranges>
template <class OpClass>
auto OperationRoot<T,Ranges...>::assign(const OpClass& in) const
-> decltype(this->template asx<IAssign>(in))
{
return this->template asx<IAssign>(in);
}
template <typename T, class... Ranges>
template <class OpClass>
auto OperationRoot<T,Ranges...>::assignExpr(const OpClass& in) const
-> decltype(in.loop(AssignmentExpr2<T,OperationRoot<T,Ranges...>,OpClass>
(mOrigDataPtr,*this,in)))
-> decltype(this->template asxExpr<IAssign>(in))
{
static_assert( OpClass::SIZE == decltype(in.rootSteps())::SIZE, "Ext Size mismatch" );
return in.loop(AssignmentExpr2<T,OperationRoot<T,Ranges...>,OpClass>
(mOrigDataPtr,*this,in));
return this->template asxExpr<IAssign>(in);
}
template <typename T, class... Ranges>
template <class OpClass, class Index>
auto OperationRoot<T,Ranges...>::assign(const OpClass& in, const std::shared_ptr<Index>& i) const
-> decltype(i->ifor(1,in.loop(AssignmentExpr2<T,OperationRoot<T,Ranges...>,OpClass>
(mOrigDataPtr,*this,in))))
-> decltype(this->template asx<IAssign>(in,i))
{
static_assert( OpClass::SIZE == decltype(in.rootSteps())::SIZE, "Ext Size mismatch" );
return i->ifor(1,in.loop(AssignmentExpr2<T,OperationRoot<T,Ranges...>,OpClass>
(mOrigDataPtr,*this,in)));
return this->template asx<IAssign>(in,i);
}
template <typename T, class... Ranges>
template <class OpClass>
auto OperationRoot<T,Ranges...>::plus(const OpClass& in) const
-> decltype(mIndex.ifor(1,in.loop(AddExpr<T,OperationRoot<T,Ranges...>,OpClass,OpIndexAff::TARGET>
(mOrigDataPtr,*this,in))))
-> decltype(this->template asx<IPlus>(in))
{
static_assert( OpClass::SIZE == decltype(in.rootSteps())::SIZE, "Ext Size mismatch" );
return mIndex.ifor(1,in.loop(AddExpr<T,OperationRoot<T,Ranges...>,OpClass,OpIndexAff::TARGET>
(mOrigDataPtr,*this,in)));
return this->template asx<IPlus>(in);
}
template <typename T, class... Ranges>
template <class OpClass, class Index>
auto OperationRoot<T,Ranges...>::plus(const OpClass& in, const std::shared_ptr<Index>& i) const
-> decltype(i->ifor(1,in.loop(AddExpr<T,OperationRoot<T,Ranges...>,OpClass>
(mOrigDataPtr,*this,in))))
-> decltype(this->template asx<IPlus>(in,i))
{
static_assert( OpClass::SIZE == decltype(in.rootSteps())::SIZE, "Ext Size mismatch" );
return i->ifor(1,in.loop(AddExpr<T,OperationRoot<T,Ranges...>,OpClass>
(mOrigDataPtr,*this,in)));
return this->template asx<IPlus>(in,i);
}
template <typename T, class... Ranges>
template <class OpClass>
OperationRoot<T,Ranges...>& OperationRoot<T,Ranges...>::operator=(const OpClass& in)
{
auto x = this->template asx<IVAssign<typename VType<T>::type>>(in);
const size_t inum = x.vec(VType<T>::MULT);
if(x.rootSteps(inum) == 1){
x();
}
else {
assign(in)();
}
return *this;
}
@ -613,7 +638,7 @@ namespace MultiArrayTools
template <typename V, class ET>
inline V& OperationRoot<T,Ranges...>::vget(ET pos) const
{
return *(reinterpret_cast<const V*>(mDataPtr)+pos.val());
return *(reinterpret_cast<V*>(mDataPtr)+pos.val());
}
template <typename T, class... Ranges>

View file

@ -538,29 +538,39 @@ namespace MultiArrayTools
OperationRoot(T* data, const IndexType& ind);
template <class IOp, class OpClass>
auto asx(const OpClass& in) const
-> decltype(mIndex.ifor(1,in.loop(AssignmentExpr<T,IOp,OperationRoot<T,Ranges...>,OpClass,OpIndexAff::TARGET>
(mOrigDataPtr,*this,in))));
template <class IOp, class OpClass>
auto asxExpr(const OpClass& in) const
-> decltype(in.loop(AssignmentExpr<T,IOp,OperationRoot<T,Ranges...>,OpClass>(mOrigDataPtr,*this,in)));
template <class IOp, class OpClass, class Index>
auto asx(const OpClass& in, const std::shared_ptr<Index>& i) const
-> decltype(i->ifor(1,in.loop(AssignmentExpr<T,IOp,OperationRoot<T,Ranges...>,OpClass>
(mOrigDataPtr,*this,in))));
template <class OpClass>
auto assign(const OpClass& in) const
-> decltype(mIndex.ifor(1,in.loop(AssignmentExpr2<T,OperationRoot<T,Ranges...>,OpClass,OpIndexAff::TARGET>
(mOrigDataPtr,*this,in))));
-> decltype(this->template asx<IAssign>(in));
template <class OpClass>
auto assignExpr(const OpClass& in) const
-> decltype(in.loop(AssignmentExpr2<T,OperationRoot<T,Ranges...>,OpClass>(mOrigDataPtr,*this,in)));
-> decltype(this->template asxExpr<IAssign>(in));
template <class OpClass, class Index>
auto assign(const OpClass& in, const std::shared_ptr<Index>& i) const
-> decltype(i->ifor(1,in.loop(AssignmentExpr2<T,OperationRoot<T,Ranges...>,OpClass>
(mOrigDataPtr,*this,in))));
-> decltype(this->template asx<IAssign>(in,i));
template <class OpClass>
auto plus(const OpClass& in) const
-> decltype(mIndex.ifor(1,in.loop(AddExpr<T,OperationRoot<T,Ranges...>,OpClass,OpIndexAff::TARGET>
(mOrigDataPtr,*this,in))));
-> decltype(this->template asx<IPlus>(in));
template <class OpClass, class Index>
auto plus(const OpClass& in, const std::shared_ptr<Index>& i) const
-> decltype(i->ifor(1,in.loop(AddExpr<T,OperationRoot<T,Ranges...>,OpClass>
(mOrigDataPtr,*this,in))));
-> decltype(this->template asx<IPlus>(in,i));
template <class OpClass>
OperationRoot& operator=(const OpClass& in);

View file

@ -88,7 +88,7 @@ namespace MultiArrayHelper
static_assert(LAST >= NextOpType::SIZE, "inconsistent array positions");
static constexpr size_t NEXT = LAST - NextOpType::SIZE;
typedef decltype(std::get<N>(ops).template vget<V>(Getter<NEXT>::template getX<ETuple>( pos ))) ArgT;
return PackNum<N-1>::template mkVOpExpr<NEXT,ETuple,OpTuple,OpFunction,ArgT,Args...>
return PackNum<N-1>::template mkVOpExpr<NEXT,V,ETuple,OpTuple,OpFunction,ArgT,Args...>
( f, pos, ops, std::get<N>(ops).template vget<V>(Getter<NEXT>::template getX<ETuple>( pos )), args...);
}

View file

@ -35,6 +35,9 @@ namespace MultiArrayHelper
virtual size_t size() const = 0;
virtual const size_t& val() const = 0;
//virtual size_t rootSteps() const = 0;
virtual bool operator==(const ExtBase& in) const = 0;
virtual bool operator==(size_t in) const = 0;
virtual std::shared_ptr<ExtBase> operator+(const ExtBase& in) const = 0;
virtual std::shared_ptr<ExtBase> operator*(size_t in) const = 0;
virtual void zero() = 0;
@ -75,6 +78,12 @@ namespace MultiArrayHelper
virtual const size_t& val() const override final { return mExt.val(); }
virtual void zero() override final { mExt.zero(); }
virtual bool operator==(const ExtBase& in) const override final
{ return mExt == dynamic_cast<const ExtT<ExtType>&>(in).mExt; }
virtual bool operator==(size_t in) const override final
{ return mExt == in; }
virtual DExt operator+(const ExtBase& in) const override final
{ return std::make_shared<ExtT<ExtType>>( mExt + dynamic_cast<const ExtT<ExtType>&>(in).mExt ); }
virtual DExt operator*(size_t in) const override final
@ -122,6 +131,11 @@ namespace MultiArrayHelper
template <class Y>
DExtTX(const Y& y) : mDExt(std::make_shared<ExtT<Y>>(y)) {}
*/
bool operator==(const DExtTX& in) const
{ return *mDExt == *in.mDExt and mNext == in.mNext; }
bool operator==(size_t in) const
{ return *mDExt == in and mNext == in; }
template <class Y>
DExtTX(const DExtTX<Y>& in) : mDExt(in.mDExt), mNext(in.mNext) {}