fix last issue -> non-virtual indices completely work now
This commit is contained in:
parent
e798de6469
commit
499d49d89d
8 changed files with 66 additions and 8 deletions
10
src/block.h
10
src/block.h
|
@ -55,6 +55,16 @@ namespace MultiArrayHelper
|
|||
size_t mSize = 0;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
std::ostream& operator<<(std::ostream& out, const Block<T>& block)
|
||||
{
|
||||
out << block[0];
|
||||
for(size_t i = 1; i != block.size(); ++i){
|
||||
out << ", " << block[i];
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::ostream& operator<<(std::ostream& out, const MBlock<T>& block)
|
||||
{
|
||||
|
|
|
@ -167,6 +167,17 @@ namespace MultiArrayTools
|
|||
}
|
||||
|
||||
static std::string S_id(ContainerIndex const* i) { return std::string("con") + std::to_string(i->mId); }
|
||||
|
||||
static void S_print(ContainerIndex const* i, size_t offset)
|
||||
{
|
||||
if(offset == 0){
|
||||
std::cout << " === " << std::endl;
|
||||
}
|
||||
for(size_t j = 0; j != offset; ++j) { std::cout << "\t"; }
|
||||
std::cout << S_id(i) << "[" << reinterpret_cast<std::intptr_t>(i) << "]"
|
||||
<< "(" << i->mRangePtr << "): " << S_meta(i) << std::endl;
|
||||
PackNum<sizeof...(Indices)-1>::printIndex(i->mIPack, offset+1);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -45,12 +45,12 @@ namespace MultiArrayTools
|
|||
{
|
||||
return std::make_shared<IndexWrapper<I> >(idxPtr);
|
||||
}
|
||||
|
||||
/*
|
||||
template <class I>
|
||||
std::shared_ptr<IndexWrapper<I> > make_viwb(const I& idxPtr)
|
||||
{
|
||||
return make_viwb( std::make_shared<I>(idxPtr) );
|
||||
}
|
||||
}*/
|
||||
|
||||
template <class I>
|
||||
class IndexWrapper : public VirtualIndexWrapperBase
|
||||
|
@ -66,7 +66,8 @@ namespace MultiArrayTools
|
|||
virtual size_t pos() const override { return mIdxPtr->pos(); }
|
||||
virtual size_t max() const override { return mIdxPtr->max(); }
|
||||
virtual std::shared_ptr<RangeBase> rangePtr() const override { return mIdxPtr->vrange(); }
|
||||
virtual std::shared_ptr<VirtualIndexWrapperBase> getPtr(size_t n) const override { return mIdxPtr->getVPtr(n); }
|
||||
virtual std::shared_ptr<VirtualIndexWrapperBase> getPtr(size_t n) const override
|
||||
{ return mIdxPtr->getVPtr(n); }
|
||||
virtual std::intptr_t getPtrNum() const override { return reinterpret_cast<std::intptr_t>( mIdxPtr.get() ); }
|
||||
virtual size_t getStepSize(size_t n) const override { return mIdxPtr->getStepSize(n); }
|
||||
|
||||
|
@ -127,6 +128,7 @@ namespace MultiArrayTools
|
|||
MetaType meta() const { return I::S_meta(THIS()); }
|
||||
I& at(const MetaType& meta) { return I::S_at(THIS(), meta); }
|
||||
|
||||
void print(size_t offset = 0) const { I::S_print(THIS(), offset); }
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -255,9 +255,10 @@ namespace MultiArrayTools
|
|||
// stepSize > 1 => SPLIT :)
|
||||
BTSS out(BlockType::VALUE, 0);
|
||||
size_t lastNum = i->rangePtr()->dim();
|
||||
|
||||
for(size_t inum = 0; inum != lastNum; ++inum){
|
||||
auto ii = i->getPtr(inum);
|
||||
if(ii == j){
|
||||
if(ii->getPtrNum() == j->getPtrNum()){
|
||||
|
||||
if(inum == lastNum - 1 and first){
|
||||
out = BTSS(BlockType::BLOCK, 1);
|
||||
|
|
|
@ -175,6 +175,17 @@ namespace MultiArrayTools
|
|||
}
|
||||
|
||||
static std::string S_id(MultiIndex const* i) { return std::string("mul") + std::to_string(i->mId); }
|
||||
|
||||
static void S_print(MultiIndex const* i, size_t offset)
|
||||
{
|
||||
if(offset == 0){
|
||||
std::cout << " === " << std::endl;
|
||||
}
|
||||
for(size_t j = 0; j != offset; ++j) { std::cout << "\t"; }
|
||||
std::cout << S_id(i) << "[" << reinterpret_cast<std::intptr_t>(i)
|
||||
<< "]" << "(" << i->mRangePtr << "): " << S_meta(i) << std::endl;
|
||||
PackNum<sizeof...(Indices)-1>::printIndex(i->mIPack, offset+1);
|
||||
}
|
||||
};
|
||||
|
||||
/*************************
|
||||
|
|
|
@ -164,7 +164,7 @@ namespace {
|
|||
std::vector<double> cv1;
|
||||
std::vector<double> cv2;
|
||||
};
|
||||
/*
|
||||
|
||||
TEST_F(OpTest_Performance, PCheck)
|
||||
{
|
||||
MultiArray<double,MRange> ma2(mrptr, cv2);
|
||||
|
@ -203,7 +203,7 @@ namespace {
|
|||
//EXPECT_EQ( xround( res.at(mkt(700,900)) ), xround(res2[700*vs1 + 900]) );
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
TEST_F(OpTest_1Dim, ExecOp)
|
||||
{
|
||||
MultiArray<double,SRange> ma1(srptr, v1);
|
||||
|
|
|
@ -251,7 +251,14 @@ namespace MultiArrayHelper
|
|||
std::vector<RangeBase> v)
|
||||
{
|
||||
v[N] = std::get<N>(rst);
|
||||
PackNum<N>::RangesToVec(rst, v);
|
||||
PackNum<N-1>::RangesToVec(rst, v);
|
||||
}
|
||||
|
||||
template <class... Indices>
|
||||
static void printIndex(const std::tuple<std::shared_ptr<Indices>...>& ip, size_t offset)
|
||||
{
|
||||
std::get<N>(ip)->print(offset);
|
||||
PackNum<N-1>::printIndex(ip, offset);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -273,7 +280,7 @@ namespace MultiArrayHelper
|
|||
template <class IndexType>
|
||||
static std::shared_ptr<VIWB> getIndexPtr(const IndexType& in, size_t n)
|
||||
{
|
||||
return make_viwb( in.template get<0>() );
|
||||
return make_viwb( in.template getPtr<0>() );
|
||||
}
|
||||
/*
|
||||
template <class... Indices>
|
||||
|
@ -441,6 +448,12 @@ namespace MultiArrayHelper
|
|||
v[0] = std::get<0>(rst);
|
||||
}
|
||||
|
||||
template <class... Indices>
|
||||
static void printIndex(const std::tuple<std::shared_ptr<Indices>...>& ip, size_t offset)
|
||||
{
|
||||
std::get<0>(ip)->print(offset);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
template <typename... T>
|
||||
|
|
|
@ -117,6 +117,16 @@ namespace MultiArrayTools
|
|||
}
|
||||
|
||||
static std::string S_id(SingleIndex const* i) { return std::string("sin") + std::to_string(i->mId); }
|
||||
|
||||
static void S_print(SingleIndex const* i, size_t offset)
|
||||
{
|
||||
if(offset == 0){
|
||||
std::cout << " === " << std::endl;
|
||||
}
|
||||
for(size_t j = 0; j != offset; ++j) { std::cout << "\t"; }
|
||||
std::cout << S_id(i) << "[" << reinterpret_cast<std::intptr_t>(i)
|
||||
<< "](" << i->mRangePtr << "): " << S_meta(i) << std::endl;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename U, RangeType TYPE>
|
||||
|
|
Loading…
Reference in a new issue