From 10f6f755525dc4ea8a5a5c8f77d88302fb512098 Mon Sep 17 00:00:00 2001 From: Christian Zimmermann Date: Fri, 2 Mar 2018 17:45:31 +0100 Subject: [PATCH] completely remove IndexInfo stuff --- src/include/multi_array_operation.h | 24 ------ src/include/ranges/container_range.h | 11 --- src/include/ranges/index_base.h | 5 -- src/include/ranges/index_info.h | 104 ------------------------- src/include/ranges/multi_range.h | 11 --- src/include/ranges/rpack_num.h | 20 ----- src/include/ranges/single_range.h | 8 -- src/lib/CMakeLists.txt | 1 - src/lib/ranges/index_info.cc | 110 --------------------------- 9 files changed, 294 deletions(-) delete mode 100644 src/include/ranges/index_info.h delete mode 100644 src/lib/ranges/index_info.cc diff --git a/src/include/multi_array_operation.h b/src/include/multi_array_operation.h index 521f4e7..ae1f754 100644 --- a/src/include/multi_array_operation.h +++ b/src/include/multi_array_operation.h @@ -12,12 +12,9 @@ #include "base_def.h" #include "mbase_def.h" -//#include "block/block.h" -//#include "operation_utils.h" #include "ranges/rheader.h" #include "pack_num.h" -#include "ranges/index_info.h" #include "arith.h" namespace MultiArrayTools @@ -101,11 +98,6 @@ namespace MultiArrayTools OperationMaster(MutableMultiArrayBase& ma, const OpClass& second, IndexType& index); - OperationMaster(MutableMultiArrayBase& ma, const OpClass& second, - //std::shared_ptr& index, - IndexType& index, - const IndexInfo* blockIndex); - inline void set(size_t pos, T val) { mDataPtr[pos] = val; } inline void add(size_t pos, T val) { mDataPtr[pos] += val; } inline T get(size_t pos) const; @@ -117,7 +109,6 @@ namespace MultiArrayTools MutableMultiArrayBase& mArrayRef; T* mDataPtr; IndexType mIndex; - //IndexInfo mIInfo; }; @@ -150,9 +141,7 @@ namespace MultiArrayTools MultiArrayBase const& mArrayRef; const T* mDataPtr; - //std::shared_ptr mIndex; IndexType mIndex; - //IndexInfo mIInfo; }; template @@ -187,7 +176,6 @@ namespace MultiArrayTools MutableMultiArrayBase& mArrayRef; T* mDataPtr; IndexType mIndex; - //IndexInfo mIInfo; }; template @@ -387,17 +375,6 @@ namespace MultiArrayTools { performAssignment(0); } - - template - OperationMaster:: - OperationMaster(MutableMultiArrayBase& ma, const OpClass& second, - IndexType& index, - const IndexInfo* blockIndex) : - mSecond(second), mArrayRef(ma), mDataPtr(mArrayRef.data()), - mIndex(index) - { - performAssignment(0); - } template void OperationMaster::performAssignment(std::intptr_t blockIndexNum) @@ -424,7 +401,6 @@ namespace MultiArrayTools ConstOperationRoot(const MultiArrayBase& ma, const std::shared_ptr&... indices) : mArrayRef(ma), mDataPtr(mArrayRef.data()), - //mIndex( mkIndex(ma,indices...) ), mIInfo(mIndex) mIndex( ma.begin() ) { mIndex(indices...); diff --git a/src/include/ranges/container_range.h b/src/include/ranges/container_range.h index c8ddef5..a17c4e4 100644 --- a/src/include/ranges/container_range.h +++ b/src/include/ranges/container_range.h @@ -93,8 +93,6 @@ namespace MultiArrayTools size_t getStepSize(size_t n); - std::vector infoVec() const; - std::string id() const; void print(size_t offset); @@ -389,15 +387,6 @@ namespace MultiArrayTools } return mBlockSizes[n+1]; } - - template - std::vector ContainerIndex::infoVec() const - { - std::vector out; - out.reserve(sizeof...(Indices)); - RPackNum::buildInfoVec(out, mIPack, mBlockSizes); - return std::move( out ); - } template std::string ContainerIndex::id() const diff --git a/src/include/ranges/index_base.h b/src/include/ranges/index_base.h index 4642c24..d262306 100644 --- a/src/include/ranges/index_base.h +++ b/src/include/ranges/index_base.h @@ -10,7 +10,6 @@ #include "rbase_def.h" #include "range_base.h" #include "index_type.h" -#include "index_info.h" #include "xfor/xfor.h" @@ -53,8 +52,6 @@ namespace MultiArrayTools std::shared_ptr vrange() const { return mRangePtr; } - - std::vector infoVec() const { return THIS().infoVec(); } size_t getStepSize(size_t n) const { return THIS().getStepSize(n); } @@ -67,8 +64,6 @@ namespace MultiArrayTools void print(size_t offset = 0) const { THIS().print(offset); } - IndexInfo info() const { return IndexInfo(THIS()); } - // CHECK / IMPLEMENT !!!!!! template auto ifor(const Expr ex) const -> decltype(THIS().template ifor(ex)) diff --git a/src/include/ranges/index_info.h b/src/include/ranges/index_info.h deleted file mode 100644 index 1623f37..0000000 --- a/src/include/ranges/index_info.h +++ /dev/null @@ -1,104 +0,0 @@ -// -*- C++ -*- - -#ifndef __index_info_h__ -#define __index_info_h__ - -#include -#include -#include -#include -#include "index_type.h" - -namespace MultiArrayTools -{ - class IndexInfo; - - class IndexInfo - { - public: - - IndexInfo(IndexInfo&& in) = default; - IndexInfo& operator=(IndexInfo&& in) = default; - IndexInfo(const IndexInfo& in) = default; - IndexInfo& operator=(const IndexInfo& in) = default; - - template - IndexInfo(const IndexClass& ind, size_t stepSize = 1); - - template - IndexInfo& reassign(const IndexClass& ind, size_t stepSize = 1); - - bool operator==(const IndexInfo& in) const; - bool operator!=(const IndexInfo& in) const; - - bool operator<=(const IndexInfo& in) const; - bool operator<(const IndexInfo& in) const; - bool operator>(const IndexInfo& in) const; - bool operator>=(const IndexInfo& in) const; - - - const IndexInfo* getPtr(size_t inum) const; - std::intptr_t getPtrNum() const; - size_t dim() const; - size_t max() const; - size_t getStepSize(size_t inum) const; - size_t getStepSize() const; - IndexType type() const; - - private: - - IndexInfo() = default; - - std::vector mNext; - std::intptr_t mPtrNum; - size_t mDim; - size_t mMax; - size_t mStepSize; - IndexType mType; - }; - - template - IndexInfo::IndexInfo(const IndexClass& ind, size_t stepSize) : - mNext(ind.infoVec()), - mPtrNum( reinterpret_cast( &ind ) ), - mDim(ind.vrange()->dim()), - mMax(ind.max()), - mStepSize(stepSize), - mType(ind.type()) - {} - - template - IndexInfo& IndexInfo::reassign(const IndexClass& ind, size_t stepSize) - { - IndexInfo ii(ind, stepSize); - (*this) = std::move(ii); - return *this; - } - - std::vector getRootIndices(const IndexInfo& info); - - /* - inline size_t getStepSize(const IndexInfo& ii, std::intptr_t j) - { - if(ii.type() == IndexType::SINGLE){ - return ii.getPtrNum() == j ? 1 : 0; - } - else { - size_t ss = 0; - size_t sx = 1; - for(size_t i = 0; i != ii.dim(); ++i){ - const IndexInfo& itmp = *ii.getPtr(ii.dim()-i-1); - const size_t max = itmp.max(); - const size_t tmp = getStepSize(itmp, j); - ss += tmp * sx; - sx *= max; - VCHECK(ss); - } - return ss; - } - } - */ - //size_t getStepSize(const std::vector& iv, std::intptr_t j); -} // end namespace MultiArrayTools - -#endif diff --git a/src/include/ranges/multi_range.h b/src/include/ranges/multi_range.h index 8267721..4e8b730 100644 --- a/src/include/ranges/multi_range.h +++ b/src/include/ranges/multi_range.h @@ -100,8 +100,6 @@ namespace MultiArrayTools size_t getStepSize(size_t n); - std::vector infoVec() const; - std::string id() const; void print(size_t offset); @@ -384,15 +382,6 @@ namespace MultiArrayTools } return mBlockSizes[n+1]; } - - template - std::vector MultiIndex::infoVec() const - { - std::vector out; - out.reserve(sizeof...(Indices)); - RPackNum::buildInfoVec(out, mIPack, mBlockSizes); - return std::move( out ); - } template std::string MultiIndex::id() const diff --git a/src/include/ranges/rpack_num.h b/src/include/ranges/rpack_num.h index 5df9641..924e1c0 100644 --- a/src/include/ranges/rpack_num.h +++ b/src/include/ranges/rpack_num.h @@ -3,7 +3,6 @@ #define __rpack_num_h__ #include -#include "index_info.h" namespace MultiArrayHelper { @@ -224,16 +223,6 @@ namespace MultiArrayHelper RPackNum::template checkDefaultable(); } - template - static void buildInfoVec(std::vector& out, - const std::tuple...>& ip, - const std::array& bs) - { - static const size_t POS = sizeof...(Indices)-N-1; - out.emplace_back(*std::get(ip), std::get(bs)); - RPackNum::buildInfoVec(out, ip, bs); - } - template static auto mkFor(const IndexPack& ipack, Exprs exs) -> decltype(std::get::value-N-1>(ipack) @@ -415,15 +404,6 @@ namespace MultiArrayHelper static_assert( Range::defaultable, "not defaultable" ); } - template - static void buildInfoVec(std::vector& out, - const std::tuple...>& ip, - const std::array& bs) - { - static const size_t POS = sizeof...(Indices)-1; - out.emplace_back(*std::get(ip), std::get(bs)); - } - template static auto mkFor(const IndexPack& ipack, Exprs exs) -> decltype(std::get::value-1>(ipack) diff --git a/src/include/ranges/single_range.h b/src/include/ranges/single_range.h index f160a5c..75e2b79 100644 --- a/src/include/ranges/single_range.h +++ b/src/include/ranges/single_range.h @@ -59,8 +59,6 @@ namespace MultiArrayTools void getPtr(); size_t getStepSize(size_t n); - - std::vector infoVec() const; std::string id() const; void print(size_t offset); @@ -219,12 +217,6 @@ namespace MultiArrayTools template template void SingleIndex::getPtr() {} - - template - std::vector SingleIndex::infoVec() const - { - return std::move( std::vector() ); - } template size_t SingleIndex::getStepSize(size_t n) diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index 3ad9ddb..bffe052 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -1,7 +1,6 @@ set(libmultiarray_a_SOURCES ${CMAKE_SOURCE_DIR}/src/lib/ranges/range_base.cc - ${CMAKE_SOURCE_DIR}/src/lib/ranges/index_info.cc ${CMAKE_SOURCE_DIR}/src/lib/ranges/anonymous_range.cc ) diff --git a/src/lib/ranges/index_info.cc b/src/lib/ranges/index_info.cc deleted file mode 100644 index f4f6220..0000000 --- a/src/lib/ranges/index_info.cc +++ /dev/null @@ -1,110 +0,0 @@ - -#include "ranges/index_info.h" -#include "ranges/range_base.h" - -namespace MultiArrayTools -{ - - bool IndexInfo::operator==(const IndexInfo& in) const - { - return mPtrNum == in.mPtrNum; - } - - bool IndexInfo::operator!=(const IndexInfo& in) const - { - return mPtrNum != in.mPtrNum; - } - - bool IndexInfo::operator<=(const IndexInfo& in) const - { - return mPtrNum <= in.mPtrNum; - } - - bool IndexInfo::operator<(const IndexInfo& in) const - { - return mPtrNum < in.mPtrNum; - } - - bool IndexInfo::operator>(const IndexInfo& in) const - { - return mPtrNum > in.mPtrNum; - } - - bool IndexInfo::operator>=(const IndexInfo& in) const - { - return mPtrNum >= in.mPtrNum; - } - - - const IndexInfo* IndexInfo::getPtr(size_t inum) const - { - return &mNext[inum]; - } - - std::intptr_t IndexInfo::getPtrNum() const - { - return mPtrNum; - } - - size_t IndexInfo::dim() const - { - return mDim; - } - - size_t IndexInfo::max() const - { - return mMax; - } - - size_t IndexInfo::getStepSize(size_t inum) const - { - return mNext[inum].getStepSize(); - } - - size_t IndexInfo::getStepSize() const - { - return mStepSize; - } - - IndexType IndexInfo::type() const - { - return mType; - } - - - std::vector getRootIndices(const IndexInfo& info) - { - std::vector out; - out.reserve(info.dim()); - - if(info.type() == IndexType::SINGLE){ - out.push_back(info); - } - else { - for(size_t i = 0; i != info.dim(); ++i){ - auto vv = getRootIndices(*info.getPtr(i)); - out.insert(out.end(), vv.begin(), vv.end()); - } - } - return out; - } - - //inline size_t getStepSize(const IndexInfo& ii, std::intptr_t j) - - size_t getStepSize(const std::vector& iv, std::intptr_t j) - { - size_t ss = 1; - for(auto ii = iv.end() - 1; ii != iv.begin(); --ii){ - if(ii->getPtrNum() == j){ - return ss; - } - ss *= ii->max(); - } - if(iv.begin()->getPtrNum() == j){ - return ss; - } else { - return 0; - } - } - -} // end namespace MultiArrayTools