ContainerRange = MultiRange (NOT FINISHED); TODO: Cast MultiIndex <-> ContainerIndex + Instanciate Prototype of ContainerIndex within each MultiArray(Base)-Instance

This commit is contained in:
Christian Zimmermann 2018-03-01 18:16:12 +01:00
parent ca70cd19f7
commit 516f2ed3a4
5 changed files with 33 additions and 25 deletions

View file

@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 2.8)
project(multi_array) project(multi_array)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror -std=c++11 -Wpedantic -Wno-uninitialized -O3") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror -std=c++11 -Wpedantic -Wno-uninitialized -O3 -g")
enable_testing() enable_testing()

View file

@ -16,7 +16,7 @@ namespace MultiArrayTools
typedef ContainerRange<T,SRanges...> CRange; typedef ContainerRange<T,SRanges...> CRange;
typedef MultiArrayBase<T,SRanges...> MAB; typedef MultiArrayBase<T,SRanges...> MAB;
typedef typename CRange::IndexType IndexType; typedef ContainerIndex<T,typename SRanges::IndexType...> IndexType;
DEFAULT_MEMBERS(MultiArray); DEFAULT_MEMBERS(MultiArray);
MultiArray(const std::shared_ptr<SRanges>&... ranges); MultiArray(const std::shared_ptr<SRanges>&... ranges);
@ -37,8 +37,8 @@ namespace MultiArrayTools
virtual T& operator[](const IndexType& i) override; virtual T& operator[](const IndexType& i) override;
virtual const T& operator[](const IndexType& i) const override; virtual const T& operator[](const IndexType& i) const override;
virtual T& at(const typename CRange::IndexType::MetaType& meta) override; virtual T& at(const typename IndexType::MetaType& meta) override;
virtual const T& at(const typename CRange::IndexType::MetaType& meta) const override; virtual const T& at(const typename IndexType::MetaType& meta) const override;
virtual bool isConst() const override; virtual bool isConst() const override;
virtual bool isSlice() const override; virtual bool isSlice() const override;
@ -131,25 +131,25 @@ namespace MultiArrayTools
} */ } */
template <typename T, class... SRanges> template <typename T, class... SRanges>
T& MultiArray<T,SRanges...>::operator[](const typename CRange::IndexType& i) T& MultiArray<T,SRanges...>::operator[](const IndexType& i)
{ {
return mCont[ i.pos() ]; return mCont[ i.pos() ];
} }
template <typename T, class... SRanges> template <typename T, class... SRanges>
const T& MultiArray<T,SRanges...>::operator[](const typename CRange::IndexType& i) const const T& MultiArray<T,SRanges...>::operator[](const IndexType& i) const
{ {
return mCont[ i.pos() ]; return mCont[ i.pos() ];
} }
template <typename T, class... SRanges> template <typename T, class... SRanges>
T& MultiArray<T,SRanges...>::at(const typename CRange::IndexType::MetaType& meta) T& MultiArray<T,SRanges...>::at(const typename IndexType::MetaType& meta)
{ {
return mCont[ MAB::beginIndex().at(meta).pos() ]; return mCont[ MAB::beginIndex().at(meta).pos() ];
} }
template <typename T, class... SRanges> template <typename T, class... SRanges>
const T& MultiArray<T,SRanges...>::at(const typename CRange::IndexType::MetaType& meta) const const T& MultiArray<T,SRanges...>::at(const typename IndexType::MetaType& meta) const
{ {
return mCont[ MAB::beginIndex().at(meta).pos() ]; return mCont[ MAB::beginIndex().at(meta).pos() ];
} }

View file

@ -24,7 +24,7 @@ namespace MultiArrayTools
typedef T value_type; typedef T value_type;
typedef ContainerRange<T,SRanges...> CRange; typedef ContainerRange<T,SRanges...> CRange;
typedef typename CRange::IndexType IndexType; typedef ContainerIndex<T,typename SRanges::IndexType...> IndexType;
DEFAULT_MEMBERS(MultiArrayBase); DEFAULT_MEMBERS(MultiArrayBase);
MultiArrayBase(const std::shared_ptr<SRanges>&... ranges); MultiArrayBase(const std::shared_ptr<SRanges>&... ranges);
@ -70,7 +70,7 @@ namespace MultiArrayTools
typedef ContainerRange<T,SRanges...> CRange; typedef ContainerRange<T,SRanges...> CRange;
typedef MultiArrayBase<T,SRanges...> MAB; typedef MultiArrayBase<T,SRanges...> MAB;
typedef typename CRange::IndexType IndexType; typedef ContainerIndex<T,typename SRanges::IndexType...> IndexType;
using MultiArrayBase<T,SRanges...>::operator[]; using MultiArrayBase<T,SRanges...>::operator[];
using MultiArrayBase<T,SRanges...>::at; using MultiArrayBase<T,SRanges...>::at;
@ -134,14 +134,14 @@ namespace MultiArrayTools
template <typename T, class... SRanges> template <typename T, class... SRanges>
typename MultiArrayBase<T,SRanges...>::IndexType MultiArrayBase<T,SRanges...>::begin() const typename MultiArrayBase<T,SRanges...>::IndexType MultiArrayBase<T,SRanges...>::begin() const
{ {
auto i = mRange->begin(); IndexType i = mRange->begin();
return i.setData(data()); return i.setData(data());
} }
template <typename T, class... SRanges> template <typename T, class... SRanges>
typename MultiArrayBase<T,SRanges...>::IndexType MultiArrayBase<T,SRanges...>::end() const typename MultiArrayBase<T,SRanges...>::IndexType MultiArrayBase<T,SRanges...>::end() const
{ {
auto i = mRange->end(); IndexType i = mRange->end();
return i.setData(data()); return i.setData(data());
} }
@ -149,7 +149,7 @@ namespace MultiArrayTools
typename MultiArrayBase<T,SRanges...>::IndexType typename MultiArrayBase<T,SRanges...>::IndexType
MultiArrayBase<T,SRanges...>::beginIndex() const MultiArrayBase<T,SRanges...>::beginIndex() const
{ {
auto i = mRange->begin(); IndexType i = mRange->begin();
return i.setData(data()); return i.setData(data());
} }
@ -157,7 +157,7 @@ namespace MultiArrayTools
typename MultiArrayBase<T,SRanges...>::IndexType typename MultiArrayBase<T,SRanges...>::IndexType
MultiArrayBase<T,SRanges...>::endIndex() const MultiArrayBase<T,SRanges...>::endIndex() const
{ {
auto i = mRange->end(); IndexType i = mRange->end();
return i.setData(data()); return i.setData(data());
} }

View file

@ -127,7 +127,7 @@ namespace MultiArrayTools
}; };
/*
template <typename T, class... Ranges> template <typename T, class... Ranges>
class ContainerRangeFactory : public RangeFactoryBase class ContainerRangeFactory : public RangeFactoryBase
{ {
@ -143,8 +143,8 @@ namespace MultiArrayTools
protected: protected:
}; };*/
/*
template <typename T, class... Ranges> template <typename T, class... Ranges>
class ContainerRange : public RangeInterface<ContainerIndex<T,typename Ranges::IndexType...> > class ContainerRange : public RangeInterface<ContainerIndex<T,typename Ranges::IndexType...> >
{ {
@ -187,7 +187,11 @@ namespace MultiArrayTools
static constexpr size_t ISSTATIC = SubProp<Ranges...>::ISSTATIC; static constexpr size_t ISSTATIC = SubProp<Ranges...>::ISSTATIC;
static constexpr size_t SIZE = SubProp<Ranges...>::SIZE; static constexpr size_t SIZE = SubProp<Ranges...>::SIZE;
}; };
*/
//template <typename T, class... Ranges>
//using ContainerRange = MultiRange<Ranges...>;
} // end namespace MultiArrayTools } // end namespace MultiArrayTools
/* ========================= * /* ========================= *
@ -544,7 +548,7 @@ namespace MultiArrayTools
/***************************** /*****************************
* ContainerRangeFactory * * ContainerRangeFactory *
*****************************/ *****************************/
/*
template <typename T, class... Ranges> template <typename T, class... Ranges>
ContainerRangeFactory<T,Ranges...>::ContainerRangeFactory(const std::shared_ptr<Ranges>&... rs) ContainerRangeFactory<T,Ranges...>::ContainerRangeFactory(const std::shared_ptr<Ranges>&... rs)
{ {
@ -564,11 +568,11 @@ namespace MultiArrayTools
setSelf(); setSelf();
return mProd; return mProd;
} }
*/
/********************** /**********************
* ContainerRange * * ContainerRange *
**********************/ **********************/
/*
template <typename T, class... Ranges> template <typename T, class... Ranges>
ContainerRange<T,Ranges...>::ContainerRange(const std::shared_ptr<Ranges>&... rs) : ContainerRange<T,Ranges...>::ContainerRange(const std::shared_ptr<Ranges>&... rs) :
mSpace( std::make_tuple( rs... ) ) {} mSpace( std::make_tuple( rs... ) ) {}
@ -627,7 +631,7 @@ namespace MultiArrayTools
i = size(); i = size();
return i; return i;
} }
*/
} // end namespace MultiArrayTools } // end namespace MultiArrayTools

View file

@ -51,13 +51,17 @@ namespace MultiArrayTools
class MultiIndex; class MultiIndex;
// container_range.h // container_range.h
//template <typename T, class... Ranges>
//class ContainerRangeFactory;
template <typename T, class... Ranges> template <typename T, class... Ranges>
class ContainerRangeFactory; using ContainerRangeFactory = MultiRangeFactory<Ranges...>;
// container_range.h // container_range.h
//template <typename T, class... Ranges>
//class ContainerRange;
template <typename T, class... Ranges> template <typename T, class... Ranges>
class ContainerRange; using ContainerRange = MultiRange<Ranges...>;
// container_range.h // container_range.h
template <typename T, class... Indices> template <typename T, class... Indices>
class ContainerIndex; class ContainerIndex;