fixes + anonymous slice option

This commit is contained in:
Christian Zimmermann 2018-08-06 15:20:06 +02:00
parent 86dc006b6f
commit 5ae28f9504
5 changed files with 26 additions and 16 deletions

View file

@ -124,7 +124,7 @@ namespace MultiArrayTools
virtual bool isConst() const override;
virtual bool isSlice() const override;
virtual std::shared_ptr<MultiArrayBase<T,AnonymousRange> > anonymous() const override;
virtual std::shared_ptr<MultiArrayBase<T,AnonymousRange> > anonymous(bool slice = false) const override;
// EVALUTAION CLASS ??!!!!
@ -219,7 +219,7 @@ namespace MultiArrayTools
}
template <typename T, class Function, class... SRanges>
std::shared_ptr<MultiArrayBase<T,AnonymousRange> > FunctionalMultiArray<T,Function,SRanges...>::anonymous() const
std::shared_ptr<MultiArrayBase<T,AnonymousRange> > FunctionalMultiArray<T,Function,SRanges...>::anonymous(bool slice) const
{
assert(0); // think about it carefully
return nullptr;

View file

@ -60,6 +60,9 @@ namespace MultiArrayTools
template <typename T, class... SRanges>
class Slice;
template <typename T, class... SRanges>
class ConstSlice;
// slice.h
template <typename T, class... SRanges>
class SliceDef;

View file

@ -42,7 +42,7 @@ namespace MultiArrayTools
MultiArray(const std::shared_ptr<SRanges>&... ranges, std::vector<T>&& vec);
MultiArray(const typename CRange::Space& space);
MultiArray(const typename CRange::Space& space, std::vector<T>&& vec);
MultiArray(MultiArray<T,AnonymousRange>& ama, SIZET<SRanges>... sizes);
MultiArray(MultiArray<T,AnonymousRange>&& ama, SIZET<SRanges>... sizes);
// Only if ALL ranges have default extensions:
//MultiArray(const std::vector<T>& vec);
@ -73,7 +73,7 @@ namespace MultiArrayTools
virtual std::vector<T>& vdata() { return mCont; }
virtual const std::vector<T>& vdata() const { return mCont; }
virtual std::shared_ptr<MultiArrayBase<T,AnonymousRange> > anonymous() const override;
virtual std::shared_ptr<MultiArrayBase<T,AnonymousRange> > anonymous(bool slice = false) const override;
virtual std::shared_ptr<MultiArrayBase<T,AnonymousRange> > anonymousMove() override;
auto cat() const
@ -202,7 +202,7 @@ namespace MultiArrayTools
}
template <typename T, class... SRanges>
MultiArray<T,SRanges...>::MultiArray(MultiArray<T,AnonymousRange>& ama, SIZET<SRanges>... sizes) :
MultiArray<T,SRanges...>::MultiArray(MultiArray<T,AnonymousRange>&& ama, SIZET<SRanges>... sizes) :
MutableMultiArrayBase<T,SRanges...>
( ama.range()->template get<0>().template scast<SRanges...>(sizes...)->space() ),
mCont( std::move( ama.mCont ) )
@ -296,13 +296,20 @@ namespace MultiArrayTools
}
template <typename T, class... SRanges>
std::shared_ptr<MultiArrayBase<T,AnonymousRange> > MultiArray<T,SRanges...>::anonymous() const
std::shared_ptr<MultiArrayBase<T,AnonymousRange> > MultiArray<T,SRanges...>::anonymous(bool slice) const
{
AnonymousRangeFactory arf(MAB::mRange->space());
if(slice){
return std::make_shared<ConstSlice<T,AnonymousRange> >
( std::dynamic_pointer_cast<AnonymousRange>( arf.create() ),
data() );
}
else {
return std::make_shared<MultiArray<T,AnonymousRange> >
( std::dynamic_pointer_cast<AnonymousRange>( arf.create() ),
mCont );
}
}
template <typename T, class... SRanges>
std::shared_ptr<MultiArrayBase<T,AnonymousRange> > MultiArray<T,SRanges...>::anonymousMove()

View file

@ -57,7 +57,7 @@ namespace MultiArrayTools
virtual bool isConst() const;
virtual std::shared_ptr<MultiArrayBase<T,AnonymousRange> > anonymous() const = 0;
virtual std::shared_ptr<MultiArrayBase<T,AnonymousRange> > anonymous(bool slice = false) const = 0;
virtual ConstOperationRoot<T,SRanges...>
operator()(const std::shared_ptr<typename SRanges::IndexType>&... inds) const;

View file

@ -19,7 +19,7 @@ namespace MultiArrayTools
DEFAULT_MEMBERS(ConstSlice);
ConstSlice(const std::shared_ptr<SRanges>&... ranges, const T* data = nullptr);
ConstSlice(const MultiArray<T,AnonymousRange>& ma, SIZET<SRanges>... sizes);
ConstSlice(const MultiArrayBase<T,AnonymousRange>& ma, SIZET<SRanges>... sizes);
virtual const T& operator[](const IType& i) const override;
virtual const T& at(const typename IType::MetaType& meta) const override;
@ -31,7 +31,7 @@ namespace MultiArrayTools
virtual auto begin() const -> IType override;
virtual auto end() const -> IType override;
virtual std::shared_ptr<MultiArrayBase<T,AnonymousRange> > anonymous() const override;
virtual std::shared_ptr<MultiArrayBase<T,AnonymousRange> > anonymous(bool slice = false) const override;
auto define(const std::shared_ptr<typename SRanges::IndexType>&... inds)
-> SliceDef<T,SRanges...>;
@ -71,7 +71,7 @@ namespace MultiArrayTools
virtual auto begin() const -> IType override;
virtual auto end() const -> IType override;
virtual std::shared_ptr<MultiArrayBase<T,AnonymousRange> > anonymous() const override;
virtual std::shared_ptr<MultiArrayBase<T,AnonymousRange> > anonymous(bool slice = false) const override;
virtual std::shared_ptr<MultiArrayBase<T,AnonymousRange> > anonymousMove() override;
auto define(const std::shared_ptr<typename SRanges::IndexType>&... inds)
@ -137,7 +137,7 @@ namespace MultiArrayTools
}
template <typename T, class... SRanges>
ConstSlice<T,SRanges...>::ConstSlice(const MultiArray<T,AnonymousRange>& ma, SIZET<SRanges>... sizes) :
ConstSlice<T,SRanges...>::ConstSlice(const MultiArrayBase<T,AnonymousRange>& ma, SIZET<SRanges>... sizes) :
MultiArrayBase<T,SRanges...>
( ma.range()->template get<0>().template scast<SRanges...>(sizes...)->space() ),
mData( ma.data() )
@ -192,7 +192,7 @@ namespace MultiArrayTools
}
template <typename T, class... SRanges>
std::shared_ptr<MultiArrayBase<T,AnonymousRange> > ConstSlice<T,SRanges...>::anonymous() const
std::shared_ptr<MultiArrayBase<T,AnonymousRange> > ConstSlice<T,SRanges...>::anonymous(bool slice) const
{
assert(0); // think about carefully!!!!
return nullptr;
@ -290,7 +290,7 @@ namespace MultiArrayTools
}
template <typename T, class... SRanges>
std::shared_ptr<MultiArrayBase<T,AnonymousRange> > Slice<T,SRanges...>::anonymous() const
std::shared_ptr<MultiArrayBase<T,AnonymousRange> > Slice<T,SRanges...>::anonymous(bool slice) const
{
assert(0); // think about carefully!!!!
return nullptr;