From 1347615cb31addb81e5289a2024c8bf668d5890a Mon Sep 17 00:00:00 2001 From: Christian Zimmermann Date: Tue, 5 Dec 2017 17:31:57 +0100 Subject: [PATCH] im com (a-range not finished) --- src/anonymous_range.h | 27 +++++------ src/pack_num.h | 9 +++- src/range_base.h | 12 ++--- src/range_types/spin_range.h | 90 +++++++++++++++++++++++++++++++++--- 4 files changed, 110 insertions(+), 28 deletions(-) diff --git a/src/anonymous_range.h b/src/anonymous_range.h index 4fff219..5bd4953 100644 --- a/src/anonymous_range.h +++ b/src/anonymous_range.h @@ -16,7 +16,7 @@ namespace MultiArrayTools { public: - typedef SingleRange oType; + typedef AnonymousRange oType; AnonymousRangeFactory() = delete; AnonymousRangeFactory(const std::shared_ptr... origs); @@ -33,8 +33,8 @@ namespace MultiArrayTools virtual size_t size() const override; virtual size_t dim() const override; - const size_t& get(size_t pos) const; - size_t getMeta(const size_t& metaPos) const; + size_t get(size_t pos) const; + size_t getMeta(size_t metaPos) const; virtual IndexType begin() const override; virtual IndexType end() const override; @@ -64,9 +64,9 @@ namespace MultiArrayTools namespace MultiArrayTools { - /******************** + /*********************** * AnonymousRange * - ********************/ + ***********************/ AnonymousRangeFactory::AnonymousRangeFactory(const std::shared_ptr... origs) { @@ -79,25 +79,26 @@ namespace MultiArrayTools return mProd; } - /******************** + /*********************** * AnonymousRange * - ********************/ - + ***********************/ + + template AnonymousRange::AnonymousRange(const std::shared_ptr... origs) : RangeInterface() { + mOrig.resize(sizeof...(Ranges)); + PackNum::RangesToVec(); // mOrig !!!! // mSize !!! = (prod origs.size...) } - const size_t& AnonymousRange::get(size_t pos) const + size_t AnonymousRange::get(size_t pos) const { - static size_t x; - x = pos; - return x; + return pos; } - size_t AnonymousRange::getMeta(const size_t& metaPos) const + size_t AnonymousRange::getMeta(size_t metaPos) const { return metaPos; } diff --git a/src/pack_num.h b/src/pack_num.h index bdd3175..e6de26c 100644 --- a/src/pack_num.h +++ b/src/pack_num.h @@ -244,7 +244,14 @@ namespace MultiArrayHelper out << std::get(tp) << ", "; PackNum::printTuple(out, tp); } - + + template + static void RangesToVec(const std::shared_ptr r, + const std::shared_ptr... rs, + std::vector v) + { + + } }; template<> diff --git a/src/range_base.h b/src/range_base.h index c977c99..d4c0437 100644 --- a/src/range_base.h +++ b/src/range_base.h @@ -14,15 +14,11 @@ namespace MultiArrayTools enum class RangeType { - NIL = 0, + NONE = 0, ANY = 1, - SPACE = 2, - MOMENTUM = 3, - LORENTZ = 4, - SPIN = 5, - ENSEMBLE = 6, - VALUE_ERROR = 7, - DISTANCE = 8 +#define include_range_type(x,n) x = n, +#include "range_types/header.h" +#undef include_range_type }; class RangeFactoryBase diff --git a/src/range_types/spin_range.h b/src/range_types/spin_range.h index 3918c4b..209161a 100644 --- a/src/range_types/spin_range.h +++ b/src/range_types/spin_range.h @@ -1,4 +1,9 @@ + +#ifdef include_range_type +include_range_type(SPIN,2) +#else + #ifdef __ranges_header__ // assert, that this is only used within range_types/header.h @@ -32,8 +37,8 @@ namespace MultiArrayTools virtual size_t size() const override; virtual size_t dim() const override; - const U& get(size_t pos) const; - size_t getMeta(const U& metaPos) const; + size_t get(size_t pos) const; + size_t getMeta(size_t metaPos) const; virtual IndexType begin() const override; virtual IndexType end() const override; @@ -43,13 +48,16 @@ namespace MultiArrayTools protected: - SingleRange() = delete; + SingleRange() = default; SingleRange(const SingleRange& in) = delete; SingleRange(size_t spinNum); size_t mSpinNum = 4; }; + + typedef SingleRange SpinRange; + typedef SingleRangeFactory SpinRF; } /* ========================= * @@ -58,8 +66,78 @@ namespace MultiArrayTools namespace MultiArrayTools { - // ... !!!! + /******************** + * SingleRange * + ********************/ + + SingleRangeFactory::SingleRangeFactory(const std::vector& space) + { + mProd = std::shared_ptr( new SingleRange( space ) ); + } + + std::shared_ptr SingleRangeFactory::create() + { + setSelf(); + return mProd; + } + + /******************** + * SingleRange * + ********************/ + + SingleRange::SingleRange(size_t spinNum) : + RangeInterface >() + { + mSpinNum = spinNum; + } + + size_t SingleRange::get(size_t pos) const + { + return pos; + } + + size_t SingleRange::getMeta(size_t metaPos) const + { + return metaPos; + } + + size_t SingleRange::size() const + { + return mSpinNum; + } + + size_t SingleRange::dim() const + { + return 1; + } + + typename SingleRange::IndexType SingleRange::begin() const + { + SingleIndex i( std::dynamic_pointer_cast > + ( std::shared_ptr( RB::mThis ) ) ); + i = 0; + return i; + } + + typename SingleRange::IndexType SingleRange::end() const + { + SingleIndex i( std::dynamic_pointer_cast > + ( std::shared_ptr( RB::mThis ) ) ); + i = size(); + return i; + } + + // put this in the interface class !!! + std::shared_ptr SingleRange::index() const + { + return std::make_shared > + ( std::dynamic_pointer_cast > + ( std::shared_ptr( RB::mThis ) ) ); + } } -#endif -#endif +#endif // #ifndef __spin_range_h__ + +#endif // #ifdef __ranges_header__ + +#endif // #ifdef include_range_type