small adjustments

This commit is contained in:
Christian Zimmermann 2018-09-08 18:46:04 +02:00
parent 9e5c51428a
commit 91acb873e1
3 changed files with 67 additions and 1 deletions

View file

@ -58,6 +58,9 @@ namespace MultiArrayTools
virtual bool isConst() const; virtual bool isConst() const;
virtual std::shared_ptr<MultiArrayBase<T,AnonymousRange> > anonymous(bool slice = false) const = 0; virtual std::shared_ptr<MultiArrayBase<T,AnonymousRange> > anonymous(bool slice = false) const = 0;
virtual ConstOperationRoot<T,SRanges...>
op(const std::shared_ptr<IndexType>& ind) const;
virtual ConstOperationRoot<T,SRanges...> virtual ConstOperationRoot<T,SRanges...>
operator()(const std::shared_ptr<typename SRanges::IndexType>&... inds) const; operator()(const std::shared_ptr<typename SRanges::IndexType>&... inds) const;
@ -105,9 +108,15 @@ namespace MultiArrayTools
virtual std::shared_ptr<MultiArrayBase<T,AnonymousRange> > anonymousMove() = 0; virtual std::shared_ptr<MultiArrayBase<T,AnonymousRange> > anonymousMove() = 0;
virtual ConstOperationRoot<T,SRanges...>
op(const std::shared_ptr<IndexType>& ind) const override;
virtual ConstOperationRoot<T,SRanges...> virtual ConstOperationRoot<T,SRanges...>
operator()(const std::shared_ptr<typename SRanges::IndexType>&... inds) const override; operator()(const std::shared_ptr<typename SRanges::IndexType>&... inds) const override;
virtual OperationRoot<T,SRanges...>
op(const std::shared_ptr<IndexType>& ind);
virtual OperationRoot<T,SRanges...> operator()(const std::shared_ptr<typename SRanges::IndexType>&... inds); virtual OperationRoot<T,SRanges...> operator()(const std::shared_ptr<typename SRanges::IndexType>&... inds);
template <class... MappedRanges> template <class... MappedRanges>
@ -212,6 +221,13 @@ namespace MultiArrayTools
return ConstOperationRoot<T,SRanges...>(*this, inds...); return ConstOperationRoot<T,SRanges...>(*this, inds...);
} }
template <typename T, class... SRanges>
ConstOperationRoot<T,SRanges...>
MultiArrayBase<T,SRanges...>::op(const std::shared_ptr<IndexType>& ind) const
{
return ConstOperationRoot<T,SRanges...>(data(), *ind);
}
template <typename T, class... SRanges> template <typename T, class... SRanges>
template <class... MappedRanges> template <class... MappedRanges>
ConstOperationRoot<T,MappedRanges...> ConstOperationRoot<T,MappedRanges...>
@ -275,6 +291,13 @@ namespace MultiArrayTools
{ {
return OperationRoot<T,SRanges...>(*this, inds...); return OperationRoot<T,SRanges...>(*this, inds...);
} }
template <typename T, class... SRanges>
OperationRoot<T,SRanges...>
MutableMultiArrayBase<T,SRanges...>::op(const std::shared_ptr<IndexType>& ind)
{
return OperationRoot<T,SRanges...>(data(), *ind);
}
template <typename T, class... SRanges> template <typename T, class... SRanges>
ConstOperationRoot<T,SRanges...> ConstOperationRoot<T,SRanges...>
@ -283,6 +306,13 @@ namespace MultiArrayTools
return ConstOperationRoot<T,SRanges...>(*this, inds...); return ConstOperationRoot<T,SRanges...>(*this, inds...);
} }
template <typename T, class... SRanges>
ConstOperationRoot<T,SRanges...>
MutableMultiArrayBase<T,SRanges...>::op(const std::shared_ptr<IndexType>& ind) const
{
return ConstOperationRoot<T,SRanges...>(data(), *ind);
}
template <typename T, class... SRanges> template <typename T, class... SRanges>
template <class... MappedRanges> template <class... MappedRanges>
OperationRoot<T,MappedRanges...> OperationRoot<T,MappedRanges...>

View file

@ -120,6 +120,8 @@ namespace MultiArrayTools
const T& operator*() const; const T& operator*() const;
const T* operator->() const; const T* operator->() const;
//T& operator*();
//T* operator->();
ContainerIndex operator++(int); ContainerIndex operator++(int);
ContainerIndex operator--(int); ContainerIndex operator--(int);
@ -476,7 +478,21 @@ namespace MultiArrayTools
//return &mMa[*this]; //return &mMa[*this];
return &mData[IB::mPos]; return &mData[IB::mPos];
} }
/*
template <typename T, class... Indices>
T& ContainerIndex<T,Indices...>::operator*()
{
//return mMa[*this];
return mData[IB::mPos];
}
template <typename T, class... Indices>
T* ContainerIndex<T,Indices...>::operator->()
{
//return &mMa[*this];
return &mData[IB::mPos];
}
*/
template <typename T, class... Indices> template <typename T, class... Indices>
ContainerIndex<T,Indices...> ContainerIndex<T,Indices...>::operator++(int) ContainerIndex<T,Indices...> ContainerIndex<T,Indices...>::operator++(int)
{ {

View file

@ -91,6 +91,19 @@ namespace MultiArrayTools
{ {
public: public:
typedef ContainerIndex<T,typename SRanges::IndexType...> IType; typedef ContainerIndex<T,typename SRanges::IndexType...> IType;
template <class Op>
static ConstSlice<T,SRanges...> mkSlice( const typename ConstSlice<T,SRanges...>::IndexType& ind,
const Op& op )
{
ConstSlice<T,SRanges...> out(ind->range()->space(), &*ind);
std::array<size_t,sizeof...(SRanges)+1> ff;
for(size_t i = 0; i != sizeof...(SRanges)+1; ++i){
PackNum<sizeof...(SRanges)-1>::mkSliceBlocks(ff, ind, op);
}
out.format(ff);
return out;
}
private: private:
IType mIndex; IType mIndex;
@ -108,6 +121,13 @@ namespace MultiArrayTools
template <class... ORanges> template <class... ORanges>
SliceDef& operator=(const OperationRoot<T,ORanges...>& op); SliceDef& operator=(const OperationRoot<T,ORanges...>& op);
}; };
template <typename T, class Op, class... Ranges>
ConstSlice<T,Ranges...> mkSlice( const typename ConstSlice<T,Ranges...>::IndexType& ind,
const Op& op )
{
return SliceDef<T,Ranges...>::mkSlice(ind, op);
}
} // end namespace MultiArrayTools } // end namespace MultiArrayTools