enable anonymous cast (only implemented for multi array itself; remaining classes non-trivial)
This commit is contained in:
parent
c6914831af
commit
edab24b63a
4 changed files with 62 additions and 0 deletions
|
@ -44,6 +44,8 @@ namespace MultiArrayTools
|
|||
virtual bool isConst() const override;
|
||||
virtual bool isSlice() const override;
|
||||
|
||||
virtual std::shared_ptr<MultiArrayBase<T,AnonymousRange> > anonymous() const override;
|
||||
|
||||
// EVALUTAION CLASS ??!!!!
|
||||
|
||||
auto exec(std::shared_ptr<typename SRanges::IndexType>&... inds) const
|
||||
|
@ -142,6 +144,13 @@ namespace MultiArrayTools
|
|||
return false;
|
||||
}
|
||||
|
||||
template <typename T, class Function, class... SRanges>
|
||||
std::shared_ptr<MultiArrayBase<T,AnonymousRange> > FunctionalMultiArray<T,Function,SRanges...>::anonymous() const
|
||||
{
|
||||
assert(0); // think about it carefully
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
template <typename T, class Function, class... SRanges>
|
||||
ConstOperationRoot<T,SRanges...> FunctionalMultiArray<T,Function,SRanges...>::
|
||||
operator()(std::shared_ptr<typename SRanges::IndexType>&... inds) const
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#define __multi_array_h__
|
||||
|
||||
#include "multi_array_base.h"
|
||||
#include "ranges/anonymous_range.h"
|
||||
|
||||
namespace MultiArrayTools
|
||||
{
|
||||
|
@ -68,6 +69,9 @@ 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> > anonymousMove() override;
|
||||
|
||||
auto cat() const
|
||||
-> decltype(ArrayCatter<T>::cat(*this));
|
||||
|
||||
|
@ -256,6 +260,25 @@ namespace MultiArrayTools
|
|||
return mCont.data();
|
||||
}
|
||||
|
||||
template <typename T, class... SRanges>
|
||||
std::shared_ptr<MultiArrayBase<T,AnonymousRange> > MultiArray<T,SRanges...>::anonymous() const
|
||||
{
|
||||
AnonymousRangeFactory arf(MAB::mRange->space());
|
||||
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()
|
||||
{
|
||||
AnonymousRangeFactory arf(MAB::mRange->space());
|
||||
MAB::mInit = false;
|
||||
return std::make_shared<MultiArray<T,AnonymousRange> >
|
||||
( std::dynamic_pointer_cast<AnonymousRange>( arf.create() ),
|
||||
std::move(mCont) );
|
||||
}
|
||||
|
||||
template <typename T, class... SRanges>
|
||||
MultiArray<T,SRanges...>::operator T() const
|
||||
{
|
||||
|
|
|
@ -57,6 +57,8 @@ namespace MultiArrayTools
|
|||
|
||||
virtual bool isConst() const;
|
||||
|
||||
virtual std::shared_ptr<MultiArrayBase<T,AnonymousRange> > anonymous() const = 0;
|
||||
|
||||
virtual ConstOperationRoot<T,SRanges...>
|
||||
operator()(std::shared_ptr<typename SRanges::IndexType>&... inds) const;
|
||||
|
||||
|
@ -97,6 +99,8 @@ namespace MultiArrayTools
|
|||
|
||||
virtual bool isConst() const override;
|
||||
|
||||
virtual std::shared_ptr<MultiArrayBase<T,AnonymousRange> > anonymousMove() = 0;
|
||||
|
||||
virtual ConstOperationRoot<T,SRanges...>
|
||||
operator()(std::shared_ptr<typename SRanges::IndexType>&... inds) const override;
|
||||
virtual OperationRoot<T,SRanges...> operator()(std::shared_ptr<typename SRanges::IndexType>&... inds);
|
||||
|
|
|
@ -30,6 +30,8 @@ namespace MultiArrayTools
|
|||
virtual auto begin() const -> IType override;
|
||||
virtual auto end() const -> IType override;
|
||||
|
||||
virtual std::shared_ptr<MultiArrayBase<T,AnonymousRange> > anonymous() const override;
|
||||
|
||||
auto define(const std::shared_ptr<typename SRanges::IndexType>&... inds)
|
||||
-> SliceDef<T,SRanges...>;
|
||||
|
||||
|
@ -68,6 +70,9 @@ 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> > anonymousMove() override;
|
||||
|
||||
auto define(const std::shared_ptr<typename SRanges::IndexType>&... inds)
|
||||
-> SliceDef<T,SRanges...>;
|
||||
|
||||
|
@ -173,6 +178,13 @@ namespace MultiArrayTools
|
|||
return i.setData(data());
|
||||
}
|
||||
|
||||
template <typename T, class... SRanges>
|
||||
std::shared_ptr<MultiArrayBase<T,AnonymousRange> > ConstSlice<T,SRanges...>::anonymous() const
|
||||
{
|
||||
assert(0); // think about carefully!!!!
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
template <typename T, class... SRanges>
|
||||
auto ConstSlice<T,SRanges...>::define(const std::shared_ptr<typename SRanges::IndexType>&... inds)
|
||||
-> SliceDef<T,SRanges...>
|
||||
|
@ -264,6 +276,20 @@ namespace MultiArrayTools
|
|||
return i.setData(data());
|
||||
}
|
||||
|
||||
template <typename T, class... SRanges>
|
||||
std::shared_ptr<MultiArrayBase<T,AnonymousRange> > Slice<T,SRanges...>::anonymous() const
|
||||
{
|
||||
assert(0); // think about carefully!!!!
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
template <typename T, class... SRanges>
|
||||
std::shared_ptr<MultiArrayBase<T,AnonymousRange> > Slice<T,SRanges...>::anonymousMove()
|
||||
{
|
||||
assert(0); // think about carefully!!!!
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
template <typename T, class... SRanges>
|
||||
auto Slice<T,SRanges...>::define(const std::shared_ptr<typename SRanges::IndexType>&... inds)
|
||||
-> SliceDef<T,SRanges...>
|
||||
|
|
Loading…
Reference in a new issue