From 3fd74cfc4c5a28402ac083002edc7b50657704ab Mon Sep 17 00:00:00 2001 From: Christian Zimmermann Date: Mon, 17 Sep 2018 11:06:24 +0200 Subject: [PATCH] some fixes --- src/include/map_range.h | 14 ++++++++++++++ src/include/ranges/x_to_string.h | 21 +++++++++++++++++++++ src/include/type_operations.h | 23 +++++++++++++++++++++++ 3 files changed, 58 insertions(+) diff --git a/src/include/map_range.h b/src/include/map_range.h index a3aea41..16d17e7 100644 --- a/src/include/map_range.h +++ b/src/include/map_range.h @@ -124,6 +124,9 @@ namespace MultiArrayTools template auto getPtr() const -> decltype( std::get( mIPack ) )&; + template + size_t getBlockSize() const { return std::get(mBlockSizes); } + std::shared_ptr outIndex() const; // raplace instances (in contrast to its analogon in ContainerIndex @@ -262,6 +265,8 @@ namespace MultiArrayTools virtual IndexType end() const final; const MultiArray& mapMultiplicity() const; + MultiArray explMapMultiplicity() const; + template auto cat(const std::shared_ptr >& erange) @@ -762,6 +767,15 @@ namespace MultiArrayTools { return mMapMult; } + + template + auto MapRange::explMapMultiplicity() const + -> MultiArray + { + auto tmp = mMapMult; + return tmp.format( std::dynamic_pointer_cast > + ( std::shared_ptr( RB::mThis )) ); + } template template diff --git a/src/include/ranges/x_to_string.h b/src/include/ranges/x_to_string.h index 77722b2..d3e6ac2 100644 --- a/src/include/ranges/x_to_string.h +++ b/src/include/ranges/x_to_string.h @@ -9,6 +9,27 @@ namespace MultiArrayHelper { + template + inline std::string xToString(const T& x); + + + template <> + inline std::string xToString(const char& x); + + template <> + inline std::string xToString(const std::string& x); + + template + inline std::string xToString(const std::vector& x); + + template + inline std::string xToString(const std::array& x); + + template + inline std::string xToString(const std::tuple& tp); + + // TEMPLATE CODE + template inline std::string xToString(const T& x) { diff --git a/src/include/type_operations.h b/src/include/type_operations.h index 24e634b..6870dac 100644 --- a/src/include/type_operations.h +++ b/src/include/type_operations.h @@ -101,6 +101,29 @@ namespace MultiArrayTools friend OperationClass; }; + inline std::array& operator+=(std::array& a, const std::array& b) + { + std::get<0>(a) += std::get<0>(b); + std::get<1>(a) += std::get<1>(b); + return a; + } + + inline std::array& operator+=(std::array& a, const std::array& b) + { + std::get<0>(a) += std::get<0>(b); + std::get<1>(a) += std::get<1>(b); + std::get<2>(a) += std::get<2>(b); + return a; + } + + inline std::tuple& operator+=(std::tuple& a, const std::tuple& b) + { + std::get<0>(a) += std::get<0>(b); + std::get<1>(a) += std::get<1>(b); + std::get<2>(a) += std::get<2>(b); + return a; + } + } // namespace MultiArrayTools #endif