some fixes

This commit is contained in:
Christian Zimmermann 2018-09-17 11:06:24 +02:00
parent 67492e24b7
commit 3fd74cfc4c
3 changed files with 58 additions and 0 deletions

View file

@ -124,6 +124,9 @@ namespace MultiArrayTools
template <size_t N> template <size_t N>
auto getPtr() const -> decltype( std::get<N>( mIPack ) )&; auto getPtr() const -> decltype( std::get<N>( mIPack ) )&;
template <size_t N>
size_t getBlockSize() const { return std::get<N>(mBlockSizes); }
std::shared_ptr<OIType> outIndex() const; std::shared_ptr<OIType> outIndex() const;
// raplace instances (in contrast to its analogon in ContainerIndex // raplace instances (in contrast to its analogon in ContainerIndex
@ -262,6 +265,8 @@ namespace MultiArrayTools
virtual IndexType end() const final; virtual IndexType end() const final;
const MultiArray<size_t,ORType>& mapMultiplicity() const; const MultiArray<size_t,ORType>& mapMultiplicity() const;
MultiArray<size_t,MapRange> explMapMultiplicity() const;
template <class... ERanges> template <class... ERanges>
auto cat(const std::shared_ptr<MapRange<ERanges...> >& erange) auto cat(const std::shared_ptr<MapRange<ERanges...> >& erange)
@ -762,6 +767,15 @@ namespace MultiArrayTools
{ {
return mMapMult; return mMapMult;
} }
template <class MapF, class... Ranges>
auto MapRange<MapF,Ranges...>::explMapMultiplicity() const
-> MultiArray<size_t,MapRange>
{
auto tmp = mMapMult;
return tmp.format( std::dynamic_pointer_cast<MapRange<MapF,Ranges...> >
( std::shared_ptr<RangeBase>( RB::mThis )) );
}
template <class MapF, class... Ranges> template <class MapF, class... Ranges>
template <class... ERanges> template <class... ERanges>

View file

@ -9,6 +9,27 @@
namespace MultiArrayHelper namespace MultiArrayHelper
{ {
template <typename T>
inline std::string xToString(const T& x);
template <>
inline std::string xToString<char>(const char& x);
template <>
inline std::string xToString<std::string>(const std::string& x);
template <typename T>
inline std::string xToString(const std::vector<T>& x);
template <typename T, size_t N>
inline std::string xToString(const std::array<T,N>& x);
template <typename... Ts>
inline std::string xToString(const std::tuple<Ts...>& tp);
// TEMPLATE CODE
template <typename T> template <typename T>
inline std::string xToString(const T& x) inline std::string xToString(const T& x)
{ {

View file

@ -101,6 +101,29 @@ namespace MultiArrayTools
friend OperationClass; friend OperationClass;
}; };
inline std::array<int,2>& operator+=(std::array<int,2>& a, const std::array<int,2>& b)
{
std::get<0>(a) += std::get<0>(b);
std::get<1>(a) += std::get<1>(b);
return a;
}
inline std::array<int,3>& operator+=(std::array<int,3>& a, const std::array<int,3>& 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<int,int,int>& operator+=(std::tuple<int,int,int>& a, const std::tuple<int,int,int>& 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 } // namespace MultiArrayTools
#endif #endif