diff --git a/src/block.h b/src/block.h index cf19632..00dd200 100644 --- a/src/block.h +++ b/src/block.h @@ -55,6 +55,16 @@ namespace MultiArrayHelper size_t mSize = 0; }; + template + std::ostream& operator<<(std::ostream& out, const Block& block) + { + out << block[0]; + for(size_t i = 1; i != block.size(); ++i){ + out << ", " << block[i]; + } + return out; + } + template std::ostream& operator<<(std::ostream& out, const MBlock& block) { diff --git a/src/container_range.h b/src/container_range.h index b42698c..bd24469 100644 --- a/src/container_range.h +++ b/src/container_range.h @@ -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(i) << "]" + << "(" << i->mRangePtr << "): " << S_meta(i) << std::endl; + PackNum::printIndex(i->mIPack, offset+1); + } }; diff --git a/src/index_base.h b/src/index_base.h index 47c83d6..1046185 100644 --- a/src/index_base.h +++ b/src/index_base.h @@ -45,12 +45,12 @@ namespace MultiArrayTools { return std::make_shared >(idxPtr); } - + /* template std::shared_ptr > make_viwb(const I& idxPtr) { return make_viwb( std::make_shared(idxPtr) ); - } + }*/ template 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 rangePtr() const override { return mIdxPtr->vrange(); } - virtual std::shared_ptr getPtr(size_t n) const override { return mIdxPtr->getVPtr(n); } + virtual std::shared_ptr getPtr(size_t n) const override + { return mIdxPtr->getVPtr(n); } virtual std::intptr_t getPtrNum() const override { return reinterpret_cast( 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: diff --git a/src/multi_array_operation.h b/src/multi_array_operation.h index d9e4d67..2a6e0ef 100644 --- a/src/multi_array_operation.h +++ b/src/multi_array_operation.h @@ -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); diff --git a/src/multi_range.h b/src/multi_range.h index 6ea23a4..20e637e 100644 --- a/src/multi_range.h +++ b/src/multi_range.h @@ -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(i) + << "]" << "(" << i->mRangePtr << "): " << S_meta(i) << std::endl; + PackNum::printIndex(i->mIPack, offset+1); + } }; /************************* diff --git a/src/op_unit_test.cc b/src/op_unit_test.cc index b3c0e62..ad9228c 100644 --- a/src/op_unit_test.cc +++ b/src/op_unit_test.cc @@ -164,7 +164,7 @@ namespace { std::vector cv1; std::vector cv2; }; - /* + TEST_F(OpTest_Performance, PCheck) { MultiArray 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 ma1(srptr, v1); diff --git a/src/pack_num.h b/src/pack_num.h index 83f674d..01ec623 100644 --- a/src/pack_num.h +++ b/src/pack_num.h @@ -251,7 +251,14 @@ namespace MultiArrayHelper std::vector v) { v[N] = std::get(rst); - PackNum::RangesToVec(rst, v); + PackNum::RangesToVec(rst, v); + } + + template + static void printIndex(const std::tuple...>& ip, size_t offset) + { + std::get(ip)->print(offset); + PackNum::printIndex(ip, offset); } }; @@ -273,7 +280,7 @@ namespace MultiArrayHelper template static std::shared_ptr getIndexPtr(const IndexType& in, size_t n) { - return make_viwb( in.template get<0>() ); + return make_viwb( in.template getPtr<0>() ); } /* template @@ -441,6 +448,12 @@ namespace MultiArrayHelper v[0] = std::get<0>(rst); } + template + static void printIndex(const std::tuple...>& ip, size_t offset) + { + std::get<0>(ip)->print(offset); + } + }; template diff --git a/src/single_range.h b/src/single_range.h index aba795f..d8adf81 100644 --- a/src/single_range.h +++ b/src/single_range.h @@ -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(i) + << "](" << i->mRangePtr << "): " << S_meta(i) << std::endl; + } }; template