ranges: start replacement of rpack_num
This commit is contained in:
parent
7fee5aa45d
commit
13488b9839
3 changed files with 28 additions and 3 deletions
|
@ -17,6 +17,8 @@
|
||||||
#include "ranges/x_to_string.h"
|
#include "ranges/x_to_string.h"
|
||||||
#include "ranges/type_map.h"
|
#include "ranges/type_map.h"
|
||||||
|
|
||||||
|
#include "statics/static_for.h"
|
||||||
|
|
||||||
namespace MultiArrayTools
|
namespace MultiArrayTools
|
||||||
{
|
{
|
||||||
namespace
|
namespace
|
||||||
|
@ -279,10 +281,30 @@ namespace MultiArrayTools
|
||||||
MultiIndex<Indices...>::MultiIndex(const std::shared_ptr<MRange>& range) :
|
MultiIndex<Indices...>::MultiIndex(const std::shared_ptr<MRange>& range) :
|
||||||
IndexInterface<MultiIndex<Indices...>,std::tuple<typename Indices::MetaType...> >(range, 0)
|
IndexInterface<MultiIndex<Indices...>,std::tuple<typename Indices::MetaType...> >(range, 0)
|
||||||
{
|
{
|
||||||
RPackNum<sizeof...(Indices)-1>::construct(mIPack, *range);
|
|
||||||
IB::mPos = RPackNum<sizeof...(Indices)-1>::makePos(mIPack);
|
|
||||||
std::get<sizeof...(Indices)>(mBlockSizes) = 1;
|
std::get<sizeof...(Indices)>(mBlockSizes) = 1;
|
||||||
RPackNum<sizeof...(Indices)-1>::initBlockSizes(mBlockSizes, mIPack); // has one more element!
|
sfor<sizeof...(Indices),0,-1>
|
||||||
|
( [&](auto i) constexpr { return i-1; } ,
|
||||||
|
[&](auto i) {
|
||||||
|
auto r = range->template getPtr<i>();
|
||||||
|
std::get<i>(mIPack) = r->beginPtr();
|
||||||
|
*std::get<i>(mIPack) = 0;
|
||||||
|
|
||||||
|
std::get<i>(mBlockSizes) = sfor<i,sizeof...(Indices),0>
|
||||||
|
( [&](auto j) { return j+1; } ,
|
||||||
|
[&](auto j) { return std::get<j>(mIPack)->max(); } ,
|
||||||
|
[&](auto a, auto b) { return a * b; }
|
||||||
|
);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
},
|
||||||
|
[&](auto a, auto b) { return 0; }
|
||||||
|
);
|
||||||
|
|
||||||
|
IB::mPos = sfor<0,sizeof...(Indices),0>
|
||||||
|
( [&](auto i) {return i+1;},
|
||||||
|
[&](auto i) {return std::get<i>(mIPack);},
|
||||||
|
[&](auto a, auto b) {return a->pos() + b*a->max();},
|
||||||
|
0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class... Indices>
|
template <class... Indices>
|
||||||
|
|
|
@ -116,6 +116,8 @@ namespace MultiArrayTools
|
||||||
|
|
||||||
virtual Index begin() const = 0;
|
virtual Index begin() const = 0;
|
||||||
virtual Index end() const = 0;
|
virtual Index end() const = 0;
|
||||||
|
std::shared_ptr<Index> beginPtr() const { return std::make_shared<Index>(this->begin()); }
|
||||||
|
std::shared_ptr<Index> endPtr() const { return std::make_shared<Index>(this->end()); }
|
||||||
virtual std::shared_ptr<IndexWrapperBase> aindex() const override final
|
virtual std::shared_ptr<IndexWrapperBase> aindex() const override final
|
||||||
{ return mkIndexWrapper(this->begin()); }
|
{ return mkIndexWrapper(this->begin()); }
|
||||||
//{ auto i = std::make_shared<Index>(this->begin()); return std::make_shared<IndexWrapper<Index>>(i); } //!!!
|
//{ auto i = std::make_shared<Index>(this->begin()); return std::make_shared<IndexWrapper<Index>>(i); } //!!!
|
||||||
|
|
|
@ -174,6 +174,7 @@ namespace MultiArrayHelper
|
||||||
|
|
||||||
std::get<N>(ip) = std::shared_ptr<SubIndexType>( new SubIndexType( range.template getPtr<N>() ) );
|
std::get<N>(ip) = std::shared_ptr<SubIndexType>( new SubIndexType( range.template getPtr<N>() ) );
|
||||||
*std::get<N>(ip) = 0;
|
*std::get<N>(ip) = 0;
|
||||||
|
//VCHECK(std::get<N>(ip)->max());
|
||||||
RPackNum<N-1>::construct(ip, range);
|
RPackNum<N-1>::construct(ip, range);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue