From 91acb873e1bf7195d947ad82d6bd396ec04388a0 Mon Sep 17 00:00:00 2001 From: Christian Zimmermann Date: Sat, 8 Sep 2018 18:46:04 +0200 Subject: [PATCH] small adjustments --- src/include/multi_array_base.h | 32 +++++++++++++++++++++++++++- src/include/ranges/container_range.h | 16 ++++++++++++++ src/include/slice.h | 20 +++++++++++++++++ 3 files changed, 67 insertions(+), 1 deletion(-) diff --git a/src/include/multi_array_base.h b/src/include/multi_array_base.h index 684dc27..73312f7 100644 --- a/src/include/multi_array_base.h +++ b/src/include/multi_array_base.h @@ -58,6 +58,9 @@ namespace MultiArrayTools virtual bool isConst() const; virtual std::shared_ptr > anonymous(bool slice = false) const = 0; + + virtual ConstOperationRoot + op(const std::shared_ptr& ind) const; virtual ConstOperationRoot operator()(const std::shared_ptr&... inds) const; @@ -105,9 +108,15 @@ namespace MultiArrayTools virtual std::shared_ptr > anonymousMove() = 0; + virtual ConstOperationRoot + op(const std::shared_ptr& ind) const override; + virtual ConstOperationRoot operator()(const std::shared_ptr&... inds) const override; - + + virtual OperationRoot + op(const std::shared_ptr& ind); + virtual OperationRoot operator()(const std::shared_ptr&... inds); template @@ -212,6 +221,13 @@ namespace MultiArrayTools return ConstOperationRoot(*this, inds...); } + template + ConstOperationRoot + MultiArrayBase::op(const std::shared_ptr& ind) const + { + return ConstOperationRoot(data(), *ind); + } + template template ConstOperationRoot @@ -275,6 +291,13 @@ namespace MultiArrayTools { return OperationRoot(*this, inds...); } + + template + OperationRoot + MutableMultiArrayBase::op(const std::shared_ptr& ind) + { + return OperationRoot(data(), *ind); + } template ConstOperationRoot @@ -283,6 +306,13 @@ namespace MultiArrayTools return ConstOperationRoot(*this, inds...); } + template + ConstOperationRoot + MutableMultiArrayBase::op(const std::shared_ptr& ind) const + { + return ConstOperationRoot(data(), *ind); + } + template template OperationRoot diff --git a/src/include/ranges/container_range.h b/src/include/ranges/container_range.h index f55983f..a7d6e4f 100644 --- a/src/include/ranges/container_range.h +++ b/src/include/ranges/container_range.h @@ -120,6 +120,8 @@ namespace MultiArrayTools const T& operator*() const; const T* operator->() const; + //T& operator*(); + //T* operator->(); ContainerIndex operator++(int); ContainerIndex operator--(int); @@ -476,7 +478,21 @@ namespace MultiArrayTools //return &mMa[*this]; return &mData[IB::mPos]; } + /* + template + T& ContainerIndex::operator*() + { + //return mMa[*this]; + return mData[IB::mPos]; + } + template + T* ContainerIndex::operator->() + { + //return &mMa[*this]; + return &mData[IB::mPos]; + } + */ template ContainerIndex ContainerIndex::operator++(int) { diff --git a/src/include/slice.h b/src/include/slice.h index 9e0fd58..e520e7c 100644 --- a/src/include/slice.h +++ b/src/include/slice.h @@ -91,6 +91,19 @@ namespace MultiArrayTools { public: typedef ContainerIndex IType; + + template + static ConstSlice mkSlice( const typename ConstSlice::IndexType& ind, + const Op& op ) + { + ConstSlice out(ind->range()->space(), &*ind); + std::array ff; + for(size_t i = 0; i != sizeof...(SRanges)+1; ++i){ + PackNum::mkSliceBlocks(ff, ind, op); + } + out.format(ff); + return out; + } private: IType mIndex; @@ -108,6 +121,13 @@ namespace MultiArrayTools template SliceDef& operator=(const OperationRoot& op); }; + + template + ConstSlice mkSlice( const typename ConstSlice::IndexType& ind, + const Op& op ) + { + return SliceDef::mkSlice(ind, op); + } } // end namespace MultiArrayTools