sub() function in range base
This commit is contained in:
parent
ca2e47b986
commit
f17d807d1a
3 changed files with 37 additions and 4 deletions
|
@ -186,6 +186,8 @@ namespace MultiArrayTools
|
||||||
template <size_t N>
|
template <size_t N>
|
||||||
auto getPtr() const -> decltype( std::get<N>( mSpace ) )&;
|
auto getPtr() const -> decltype( std::get<N>( mSpace ) )&;
|
||||||
|
|
||||||
|
virtual std::shared_ptr<RangeBase> sub(size_t num) const override;
|
||||||
|
|
||||||
virtual size_t dim() const final;
|
virtual size_t dim() const final;
|
||||||
virtual size_t size() const final;
|
virtual size_t size() const final;
|
||||||
|
|
||||||
|
@ -535,6 +537,12 @@ namespace MultiArrayTools
|
||||||
return std::get<N>(mSpace);
|
return std::get<N>(mSpace);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <class... Indices>
|
||||||
|
std::shared_ptr<RangeBase> MultiRange<Indices...>::sub(size_t num) const
|
||||||
|
{
|
||||||
|
return RPackNum<sizeof...(Indices)-1>::getSub(mSpace, num);
|
||||||
|
}
|
||||||
|
|
||||||
template <class... Ranges>
|
template <class... Ranges>
|
||||||
size_t MultiRange<Ranges...>::dim() const
|
size_t MultiRange<Ranges...>::dim() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -85,6 +85,8 @@ namespace MultiArrayTools
|
||||||
|
|
||||||
virtual SpaceType spaceType() const = 0;
|
virtual SpaceType spaceType() const = 0;
|
||||||
virtual DataHeader dataHeader() const = 0;
|
virtual DataHeader dataHeader() const = 0;
|
||||||
|
|
||||||
|
virtual std::shared_ptr<RangeBase> sub(size_t num) const { return std::shared_ptr<RangeBase>(); }
|
||||||
//virtual bool regular() const = 0; // integer distance (e.g. 2,3,4,...)
|
//virtual bool regular() const = 0; // integer distance (e.g. 2,3,4,...)
|
||||||
//virtual bool linear() const = 0; // 1dim valuable (e.g. 2.45, 3.12, 3.56,...)
|
//virtual bool linear() const = 0; // 1dim valuable (e.g. 2.45, 3.12, 3.56,...)
|
||||||
//virtual bool multi() const = 0; // mdim
|
//virtual bool multi() const = 0; // mdim
|
||||||
|
|
|
@ -160,6 +160,17 @@ namespace MultiArrayHelper
|
||||||
RPackNum<N-1>::setMeta(target, source);
|
RPackNum<N-1>::setMeta(target, source);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <class SpaceClass>
|
||||||
|
inline static std::shared_ptr<RangeBase> getSub(const SpaceClass& space, size_t num)
|
||||||
|
{
|
||||||
|
if(num == N){
|
||||||
|
return std::get<N>(space);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return RPackNum<N-1>::getSub(space, num);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
template <class IndexPack>
|
template <class IndexPack>
|
||||||
static void setIndexPack(IndexPack& iPack, size_t pos)
|
static void setIndexPack(IndexPack& iPack, size_t pos)
|
||||||
{
|
{
|
||||||
|
@ -414,6 +425,18 @@ namespace MultiArrayHelper
|
||||||
std::get<0>(target)->at( std::get<0>( source ) );
|
std::get<0>(target)->at( std::get<0>( source ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <class SpaceClass>
|
||||||
|
inline static std::shared_ptr<RangeBase> getSub(const SpaceClass& space, size_t num)
|
||||||
|
{
|
||||||
|
if(num == 0){
|
||||||
|
return std::get<0>(space);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
assert(0);
|
||||||
|
return std::shared_ptr<RangeBase>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
template <class IndexPack>
|
template <class IndexPack>
|
||||||
static void setIndexPack(IndexPack& iPack, size_t pos)
|
static void setIndexPack(IndexPack& iPack, size_t pos)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue