diff --git a/orig/include/arith.cc.h b/orig/include/arith.cc.h deleted file mode 100644 index 6eec6f4..0000000 --- a/orig/include/arith.cc.h +++ /dev/null @@ -1,35 +0,0 @@ - -#include "arith.h" - -namespace CNORXZ -{ - - template - template - auto StaticFunctionBase::mk(const Ops&... ops) - { - return Operation(ops...); - } - - template - template - inline auto StaticFunctionBase::xapply(const Tuple& tp, As... as) - { - if constexpr(N > 0){ - return xapply(tp, std::get(tp), as...); - } - else { - return F::apply(std::get<0>(tp), as...); - } - } - - template - template - inline auto StaticFunctionBase::apply(const std::tuple& arg) - { - return xapply(arg); - //return ArgPack::template mk >(arg); - } - - -} diff --git a/orig/include/arith.h b/orig/include/arith.h deleted file mode 100644 index 74b1230..0000000 --- a/orig/include/arith.h +++ /dev/null @@ -1,213 +0,0 @@ - -#ifndef __cxz_arith_h__ -#define __cxz_arith_h__ - -#include - -namespace CNORXZ -{ - - //template - template - struct StaticFunctionBase - { - static constexpr bool FISSTATIC = true; - typedef F function; - //typedef typename F::value_type value_type; - - template - static auto mk(const Ops&... ops); - - template - static inline auto xapply(const Tuple& tp, As... as); - - template - static inline auto apply(const std::tuple& arg); - }; - - - // OPERATIONS (STATIC) - template - struct identity : public StaticFunctionBase> - { - //static constexpr bool FISSTATIC = true; - using StaticFunctionBase>::apply; - typedef T value_type; - - static inline T apply(T a) - { - return a; - } - - static inline T selfApply(T& a1, const T& a2) - { - return a1 = a2; - } - }; - - template - using plusv = decltype(std::declval()+std::declval()); - - template - using minusv = decltype(std::declval()-std::declval()); - - template - using multipliesv = decltype(std::declval()*std::declval()); - - template - using dividesv = decltype(std::declval()/std::declval()); - - template - struct plusx : public StaticFunctionBase> - { - static constexpr bool FISSTATIC = true; - using StaticFunctionBase>::apply; - typedef plusv value_type; - - static inline value_type apply(T a1, U a2) - { - return a1 + a2; - } - - static inline T& selfApply(T& a1, const T& a2) - { - return a1 += a2; - } - }; - - template - struct minusx : public StaticFunctionBase> - { - static constexpr bool FISSTATIC = true; - using StaticFunctionBase>::apply; - typedef minusv value_type; - - static inline value_type apply(T a1, U a2) - { - return a1 - a2; - } - }; - - template - struct multipliesx : public StaticFunctionBase> - { - static constexpr bool FISSTATIC = true; - using StaticFunctionBase>::apply; - typedef multipliesv value_type; - - static inline value_type apply(T a1, U a2) - { - return a1 * a2; - } - }; - - template - struct dividesx : public StaticFunctionBase> - { - static constexpr bool FISSTATIC = true; - using StaticFunctionBase>::apply; - typedef dividesv value_type; - - static inline value_type apply(T a1, U a2) - { - return a1 / a2; - } - - }; - - template - struct negate : public StaticFunctionBase> - { - static constexpr bool FISSTATIC = true; - using StaticFunctionBase>::apply; - typedef T value_type; - - static inline T apply(T a) - { - return -a; - } - - }; - - template - using plus = plusx; - - template - using minus = minusx; - - template - using multiplies = multipliesx; - - template - using divides = dividesx; - - // OPERATIONS (STATIC) - template - class function - { - public: - static constexpr bool FISSTATIC = false; - - private: - std::function mF; - - public: - - function() = default; - function(const std::function& in) : mF(in) {} - - inline R operator()(const Args&... args) - { - return mF(args...); - } - - template - static inline auto xapply(const std::function& ff, const Tuple& tp, As... as) - { - if constexpr(N > 0){ - return xapply(ff, tp, std::get(tp), as...); - } - else { - return ff(std::get<0>(tp), as...); - } - } - - inline R operator()(const std::tuple& args) - { - return xapply(mF, args); - } -}; - -#include -#define regFunc1(fff) template \ - struct x_##fff : public StaticFunctionBase> {\ - static constexpr bool FISSTATIC = true;\ - typedef T value_type; \ - static inline T apply(T a){\ - return fff(a); } }; - -#include "extensions/math.h" -#undef regFunc1 - - template - struct x_ipow - { - static constexpr bool FISSTATIC = true; - - template - static inline T apply(T a) - { - if constexpr(N > 0){ - return a * x_ipow::apply(a); - } - else { - return a; - } - } - }; - -} // end namespace CNORXZInternal - -#include "arith.cc.h" - -#endif diff --git a/orig/include/base_def.h b/orig/include/base_def.h deleted file mode 100644 index 79c38aa..0000000 --- a/orig/include/base_def.h +++ /dev/null @@ -1,38 +0,0 @@ -// -*- C++ -*- - -#ifndef __cxz_base_def_h__ -#define __cxz_base_def_h__ - -#include - -#define DEBUG_MODE_X - -#ifdef DEBUG_MODE_X - -#include -#ifndef CHECK -#define CHECK std::cout << __FILE__ << ": @" << __LINE__ << " in " << __func__ << std::endl; -#endif -#ifndef VCHECK -#define VCHECK(a) std::cout << __FILE__ << ": @" << __LINE__ \ - << " in " << __func__ << ": " << #a << " = " << a << std::endl; -#endif - -#else -#define CHECK -#define VCHECK(a) - -#endif - -#define DEFAULT_C(__class_name__) __class_name__() = default -#define DEFAULT_COPY_C(__class_name__) __class_name__(const __class_name__& a) = default -#define DEFAULT_COPY_A(__class_name__) __class_name__& operator=(const __class_name__& a) = default -#define DEFAULT_MOVE_C(__class_name__) __class_name__(__class_name__&& a) = default -#define DEFAULT_MOVE_A(__class_name__) __class_name__& operator=(__class_name__&& a) = default -#define DEFAULT_COPY(__class_name__) DEFAULT_COPY_C(__class_name__); DEFAULT_COPY_A(__class_name__) -#define DEFAULT_MOVE(__class_name__) DEFAULT_MOVE_C(__class_name__); DEFAULT_MOVE_A(__class_name__) - -#define DEFAULT_MEMBERS_X(__class_name__) DEFAULT_COPY(__class_name__); DEFAULT_MOVE(__class_name__) -#define DEFAULT_MEMBERS(__class_name__) DEFAULT_C(__class_name__); DEFAULT_MEMBERS_X(__class_name__) - -#endif diff --git a/orig/include/container_index.cc.h b/orig/include/container_index.cc.h deleted file mode 100644 index 20e79be..0000000 --- a/orig/include/container_index.cc.h +++ /dev/null @@ -1,440 +0,0 @@ - -#include "container_index.h" - -namespace CNORXZ -{ - - template - ConstContainerIndex::ConstContainerIndex(const ConstContainerIndex& in, bool copy) : - IB(in), - mNonTrivialBlocks(in.mNonTrivialBlocks), - mExternControl(false), - mBlockSizes(in.mBlockSizes), - mData(in.mData), - mObjPtrNum(in.mObjPtrNum), - mCPos(in.mCPos) - { - sfor_pn<0,sizeof...(Indices)> - ( [&](auto i) - { - typedef typename std::remove_reference(mIPack))>::type - SubType; - std::get(mIPack) = std::make_shared( in.template get() ) ; - return true; - }); - } - - template - ConstContainerIndex& ConstContainerIndex::copy(const ConstContainerIndex& in) - { - IB::operator=(in); - mNonTrivialBlocks = in.mNonTrivialBlocks; - mExternControl = false; - mBlockSizes = in.mBlockSizes; - mData = in.mData; - mObjPtrNum = in.mObjPtrNum; - mCPos = in.mCPos; - sfor_pn<0,sizeof...(Indices)> - ( [&](auto i) - { - typedef typename std::remove_reference(mIPack))>::type - SubType; - std::get(mIPack) = std::make_shared( in.template get() ) ; - return true; - }); - return *this; - } - - template - template - ConstContainerIndex::ConstContainerIndex(const std::shared_ptr& range, - std::intptr_t objPtrNum) : - IndexInterface,std::tuple >(range, 0), - mObjPtrNum(objPtrNum) - { - std::get(mBlockSizes) = 1; - sfor_mn - ( [&](auto i) { - auto r = range->template getPtr(); - std::get(mIPack) = r->beginPtr(); - *std::get(mIPack) = 0; - - std::get(mBlockSizes) = sfor_p - ( [&](auto j) { return std::get(mIPack)->max(); } , - [&](auto a, auto b) { return a * b; }); - return 0; - }); - - IB::mPos = sfor_m - ( [&](auto i) { return std::get(mIPack); }, - [&](auto a, auto b) {return a->pos() + b*a->max();}, 0 ); - mCPos = RangeHelper::makePos(mIPack, mBlockSizes); - } - - template - template - ConstContainerIndex::ConstContainerIndex(const std::shared_ptr& range, - std::intptr_t objPtrNum, - const std::array& blockSizes) : - IndexInterface,std::tuple >(range, 0), - mObjPtrNum(objPtrNum) - { - sfor_mn - ( [&](auto i) { - auto r = range->template getPtr(); - std::get(mIPack) = r->beginPtr(); - *std::get(mIPack) = 0; - return 0; - }); - IB::mPos = sfor_m - ( [&](auto i) { return std::get(mIPack); }, - [&](auto a, auto b) {return a->pos() + b*a->max();}, 0 ); - mCPos = RangeHelper::makePos(mIPack, mBlockSizes); - mNonTrivialBlocks = true; - } - - template - template - ConstContainerIndex& - ConstContainerIndex::operator=(const ConstContainerIndex& in) - { - mIPack = in.mIPack; - return (*this)(); - } - - - template - ConstContainerIndex& ConstContainerIndex::sync() - { - if(mExternControl){ - IB::mPos = sfor_m - ( [&](auto i) { return std::get(mIPack); }, - [&](auto a, auto b) {return a->pos() + b*a->max();}, 0 ); - mCPos = RangeHelper::makePos(mIPack, mBlockSizes); - } - return *this; - } - - template - template - auto& ConstContainerIndex::get() const - { - return *std::get( mIPack ); - } - - template - template - auto ConstContainerIndex::getPtr() const - { - return std::get( mIPack ); - } - - template - ConstContainerIndex& ConstContainerIndex::operator()(const std::shared_ptr&... inds) - { - return (*this)(std::make_tuple(inds...)); - } - - template - ConstContainerIndex& ConstContainerIndex::operator()(const std::tuple...>& inds) - { - sfor_pn<0,sizeof...(Indices)> - ( [&](auto i) { std::get(mIPack) = std::get(inds); return 0; } ); - mExternControl = true; - return sync(); - } - - template - ConstContainerIndex& ConstContainerIndex::operator()() - { - return sync(); - } - - template - IndexType ConstContainerIndex::type() const { return IndexType::CONT; } - - template - ConstContainerIndex& ConstContainerIndex::operator++() - { - if(mExternControl){ - IB::mPos = sfor_m - ( [&](auto i) { return std::get(mIPack); }, - [&](auto a, auto b) {return a->pos() + b*a->max();}, 0 ); - } - sfor_m - ( [&](auto i) { - auto& si = *std::get( mIPack ); - if(si.last() and i != 0) { si = 0; return true; } - else { ++si; return false; } - return false; - } ); - mCPos = RangeHelper::makePos(mIPack, mBlockSizes); - ++IB::mPos; - return *this; - } - - template - ConstContainerIndex& ConstContainerIndex::operator--() - { - if(mExternControl){ - IB::mPos = sfor_m - ( [&](auto i) { return std::get(mIPack); }, - [&](auto a, auto b) {return a->pos() + b*a->max();}, 0 ); - } - sfor_m - ( [&](auto i) { - auto& si = *std::get( mIPack ); - if(si.first() and i != 0) { si = si.max()-1; return true; } - else { --si; return false; } - return false; - } ); - mCPos = RangeHelper::makePos(mIPack, mBlockSizes); - --IB::mPos; - return *this; - - } - - template - ConstContainerIndex& ConstContainerIndex::operator=(size_t pos) - { - IB::mPos = pos; - RangeHelper::setIndexPack(mIPack, pos); - mCPos = RangeHelper::makePos(mIPack, mBlockSizes); - return *this; - } - - template - int ConstContainerIndex::pp(std::intptr_t idxPtrNum) - { - const int tmp = RangeHelper::ppx(mIPack, mBlockSizes, idxPtrNum); - IB::mPos += tmp; - return tmp; - } - - template - int ConstContainerIndex::mm(std::intptr_t idxPtrNum) - { - const int tmp = RangeHelper::mmx(mIPack, mBlockSizes, idxPtrNum); - IB::mPos -= tmp; - return tmp; - } - - template - std::string ConstContainerIndex::stringMeta() const - { - return std::dynamic_pointer_cast( IB::mRangePtr )->stringMeta(IB::mPos); - } - - template - typename ConstContainerIndex::MetaType ConstContainerIndex::meta() const - { - MetaType metaTuple; - sfor_pn<0,sizeof...(Indices)> - ( [&](auto i) { std::get(metaTuple) = std::get(mIPack)->meta(); return 0; } ); - return metaTuple; - } - - template - ConstContainerIndex& ConstContainerIndex::at(const MetaType& metaPos) - { - sfor_pn<0,sizeof...(Indices)> - ( [&](auto i) { std::get(mIPack)->at( std::get(metaPos) ); return 0; } ); - IB::mPos = RangeHelper::makePos(mIPack, mBlockSizes); - return *this; - } - - template - size_t ConstContainerIndex::dim() const - { - return sizeof...(Indices); - } - - template - bool ConstContainerIndex::first() const - { - return IB::pos() == 0; - } - - template - bool ConstContainerIndex::last() const - { - return IB::pos() == IB::mMax - 1; - } - - template - bool ConstContainerIndex::sliceMode() const - { - return mNonTrivialBlocks; - } - - template - std::shared_ptr::RangeType> - ConstContainerIndex::range() - { - return std::dynamic_pointer_cast( IB::mRangePtr ); - } - - template - size_t ConstContainerIndex::getStepSize(size_t n) - { - if(n >= sizeof...(Indices)){ - assert(0); - // throw !! - } - return mBlockSizes[n+1]; - } - - template - template - auto ConstContainerIndex::ifor(size_t step, Exprs exs) const - { - return RangeHelper::mkFor<0>(step, mIPack, mBlockSizes, exs); - } - - template - template - auto ConstContainerIndex::iforh(size_t step, Exprs exs) const - { - return RangeHelper::mkForh<0>(step, mIPack, mBlockSizes, exs); - } - - template - template - auto ConstContainerIndex::pifor(size_t step, Exprs exs) const - { - return RangeHelper::mkPFor<0>(step, mIPack, mBlockSizes, exs); - } - - template - std::intptr_t ConstContainerIndex::container() const - { - return mObjPtrNum; - } - - template - ConstContainerIndex& ConstContainerIndex:: - format(const std::array& blocks) - { - mBlockSizes = blocks; - mNonTrivialBlocks = true; - return *this; - } - - template - ConstContainerIndex& ConstContainerIndex::setData(const T* data) - { - mData = data; - return *this; - } - - template - const T& ConstContainerIndex::operator*() const - { - return mData[mCPos]; - } - - template - const T* ConstContainerIndex::operator->() const - { - return &mData[mCPos]; - } - - template - ConstContainerIndex ConstContainerIndex::operator++(int) - { - auto tmp = *this; - ++(*this); - return tmp; - } - - template - ConstContainerIndex ConstContainerIndex::operator--(int) - { - auto tmp = *this; - --(*this); - return tmp; - } - - template - ConstContainerIndex& ConstContainerIndex::operator+=(int diff) - { - if(diff < 0){ - for(int i = 0; i != diff; ++i){ - (*this)--; - } - } - else { - for(int i = 0; i != diff; ++i){ - (*this)++; - } - } - return *this; - } - - template - ConstContainerIndex& ConstContainerIndex::operator-=(int diff) - { - if(diff < 0){ - for(int i = 0; i != diff; ++i){ - (*this)++; - } - } - else { - for(int i = 0; i != diff; ++i){ - (*this)--; - } - } - return *this; - } - - template - ConstContainerIndex ConstContainerIndex::operator+(int num) const - { - auto tmp = *this; - return tmp += num; - } - - template - ConstContainerIndex ConstContainerIndex::operator-(int num) const - { - auto tmp = *this; - return tmp -= num; - } - - template - int ConstContainerIndex::operator-(const ConstContainerIndex& it) const - { - return static_cast( IB::mPos ) - static_cast( it.pos() ); - } - - template - const T& ConstContainerIndex::operator[](int num) const - { - return mData[IB::mPos + num]; - } - - template - bool ConstContainerIndex::operator<(const ConstContainerIndex& it) const - { - return IB::mPos < it.pos(); - } - - template - bool ConstContainerIndex::operator>(const ConstContainerIndex& it) const - { - return IB::mPos > it.pos(); - } - - template - bool ConstContainerIndex::operator<=(const ConstContainerIndex& it) const - { - return IB::mPos <= it.pos(); - } - - template - bool ConstContainerIndex::operator>=(const ConstContainerIndex& it) const - { - return IB::mPos >= it.pos(); - } - -} // namespace CNORXZ diff --git a/orig/include/container_index.h b/orig/include/container_index.h deleted file mode 100644 index 86b6540..0000000 --- a/orig/include/container_index.h +++ /dev/null @@ -1,306 +0,0 @@ -// -*- C++ -*- - -#ifndef __cxz_container_index_h__ -#define __cxz_container_index_h__ - -#include -#include -#include - -#include "ranges/range_base.h" -#include "ranges/index_base.h" -#include "mbase_def.h" -#include "statics/static_for.h" -#include "ranges/range_helper.h" - -namespace CNORXZ -{ - - template - class ConstContainerIndex : public IndexInterface, - std::tuple > - { - public: - - typedef IndexInterface, - std::tuple > IB; - typedef std::tuple MetaType; - typedef std::tuple...> IndexPack; - typedef ContainerRange RangeType; - - static constexpr IndexType sType() { return IndexType::CONT; } - static constexpr size_t sDim() { return sizeof...(Indices); } - static constexpr size_t totalDim() { return (... * Indices::totalDim()); } - - static constexpr SpaceType STYPE = SpaceType::ANY; - static constexpr bool PARALLEL = std::tuple_element<0,std::tuple>::type::PARALLEL; - - template - using CIX = ConstContainerIndex; - - template - friend class CIX; - - private: - - ConstContainerIndex() = default; - - bool mNonTrivialBlocks = false; - bool mExternControl = false; - IndexPack mIPack; - std::array mBlockSizes; - const T* mData = nullptr; - std::intptr_t mObjPtrNum; - - protected: - size_t mCPos; - - public: - - ConstContainerIndex(const ConstContainerIndex& in) = default; - ConstContainerIndex& operator=(const ConstContainerIndex& in) = default; - - ConstContainerIndex(const ConstContainerIndex& in, bool copy); - - ConstContainerIndex& copy(const ConstContainerIndex& in); - - template - ConstContainerIndex& operator=(const ConstContainerIndex& in); - - template - ConstContainerIndex(const std::shared_ptr& range, - std::intptr_t objPtrNum); - - template - ConstContainerIndex(const std::shared_ptr& range, - std::intptr_t objPtrNum, - const std::array& blockSizes); - - - template - size_t getBlockSize() const { return std::get(mBlockSizes); } - - const IndexPack& pack() const { return mIPack; } - - ConstContainerIndex& sync(); // recalculate 'IB::mPos' when externalControl == true - ConstContainerIndex& operator()(const std::shared_ptr&... inds); // control via external indices - ConstContainerIndex& operator()(const std::tuple...>& inds); - ConstContainerIndex& operator()(); // -> sync; just to shorten the code - - // ==== >>>>> STATIC POLYMORPHISM <<<<< ==== - - IndexType type() const; - - ConstContainerIndex& operator++(); - ConstContainerIndex& operator--(); - - ConstContainerIndex& operator=(size_t pos); - - int pp(std::intptr_t idxPtrNum); - int mm(std::intptr_t idxPtrNum); - - std::string stringMeta() const; - MetaType meta() const; - ConstContainerIndex& at(const MetaType& metaPos); - - size_t dim() const; - bool first() const; - bool last() const; - bool sliceMode() const; - - std::shared_ptr range(); - - template - auto& get() const; - - template - auto getPtr() const; - - size_t getStepSize(size_t n); - - template - auto ifor(size_t step, Exprs exs) const; - - template - auto iforh(size_t step, Exprs exs) const; - - template - auto pifor(size_t step, Exprs exs) const; - - std::intptr_t container() const; - ConstContainerIndex& format(const std::array& blocks); - - // Iterator Stuff - - ConstContainerIndex& setData(const T* data); - - const T& operator*() const; - const T* operator->() const; - //T& operator*(); - //T* operator->(); - - ConstContainerIndex operator++(int); - ConstContainerIndex operator--(int); - ConstContainerIndex& operator+=(int diff); - ConstContainerIndex& operator-=(int diff); - ConstContainerIndex operator+(int num) const; - ConstContainerIndex operator-(int num) const; - - int operator-(const ConstContainerIndex& it) const; - const T& operator[](int num) const; - - bool operator<(const ConstContainerIndex& it) const; - bool operator>(const ConstContainerIndex& it) const; - bool operator<=(const ConstContainerIndex& it) const; - bool operator>=(const ConstContainerIndex& it) const; - - }; - - template - class ContainerIndex : public ConstContainerIndex - { - public: - - typedef ConstContainerIndex CCI; - typedef CCI IB; - typedef typename CCI::MetaType MetaType; - typedef typename CCI::IndexPack IndexPack; - typedef typename CCI::RangeType RangeType; - - static constexpr IndexType sType() { return CCI::sType(); } - static constexpr size_t sDim() { return CCI::sDim(); } - static constexpr size_t totalDim() { return CCI::totalDim(); } - - static constexpr SpaceType STYPE = CCI::STYPE; - static constexpr bool PARALLEL = CCI::PARALLEL; - - template - using CIX = ContainerIndex; - - template - friend class CIX; - - private: - - ContainerIndex() = default; - - T* mMData = nullptr; - - public: - - ContainerIndex(const ContainerIndex& in) = default; - ContainerIndex& operator=(const ContainerIndex& in) = default; - - ContainerIndex(const ContainerIndex& in, bool copy) : CCI(in,copy) - { mMData = in.mMData; } - - ContainerIndex(const ConstContainerIndex& in, T* data) : CCI(in) - { mMData = data; } - - ContainerIndex(const ConstContainerIndex& in, T* data, bool copy) : - CCI(in,copy) - { mMData = data; } - - ContainerIndex& copy(const ContainerIndex& in) - { CCI::copy(in); mMData = in.mMData; } - - template - ContainerIndex& operator=(const ContainerIndex& in) - { CCI::operator=(in); return *this; } - - template - ContainerIndex(const std::shared_ptr& range, - std::intptr_t objPtrNum) : CCI(range, objPtrNum) {} - - template - ContainerIndex(const std::shared_ptr& range, - std::intptr_t objPtrNum, - const std::array& blockSizes) - : CCI(range, objPtrNum, blockSizes) {} - - - template - size_t getBlockSize() const { return CCI::template getBlockSize(); } - - const IndexPack& pack() const { CCI::pack(); return *this; } - - ContainerIndex& sync() { return CCI::sync(); return *this; } - ContainerIndex& operator()(const std::shared_ptr&... inds) - { CCI::operator()(inds...); return *this; } - ContainerIndex& operator()(const std::tuple...>& inds) - { CCI::operator()(inds); return *this; } - ContainerIndex& operator()() { CCI::operator()(); return *this; } - - // ==== >>>>> STATIC POLYMORPHISM <<<<< ==== - - IndexType type() const { return CCI::type(); } - - ContainerIndex& operator++() { CCI::operator++(); return *this; } - ContainerIndex& operator--() { CCI::operator--(); return *this; } - - ContainerIndex& operator=(size_t pos) { CCI::operator=(pos); return *this; } - - int pp(std::intptr_t idxPtrNum) { return CCI::pp(idxPtrNum); } - int mm(std::intptr_t idxPtrNum) { return CCI::mm(idxPtrNum); } - - std::string stringMeta() const { return CCI::stringMeta; } - MetaType meta() const { return CCI::meta(); } - ContainerIndex& at(const MetaType& metaPos) { CCI::at(metaPos); return *this; } - - size_t dim() const { return CCI::dim(); } - bool first() const { return CCI::first(); } - bool last() const { return CCI::last(); } - bool sliceMode() const { return CCI::sliceMode(); } - - std::shared_ptr range() { return CCI::range(); } - - template - auto& get() const { return CCI::template get(); } - - template - auto getPtr() const { return CCI::template getPtr(); } - - size_t getStepSize(size_t n) { return getStepSize(n); } - - template - auto ifor(size_t step, Exprs exs) const { return CCI::ifor(step, exs); } - - template - auto iforh(size_t step, Exprs exs) const { return CCI::iforh(step, exs); } - - template - auto pifor(size_t step, Exprs exs) const { return CCI::pifor(step, exs); } - - std::intptr_t container() const { return CCI::container(); } - ContainerIndex& format(const std::array& blocks) - { CCI::format(blocks); return *this; } - - // Iterator Stuff - - ContainerIndex& setData(T* data) { CCI::setData(data); mMData = data; return *this; } - - const T& operator*() const { return CCI::operator*(); } - const T* operator->() const { return CCI::operator->(); } - T& operator*() { return mMData[CCI::mCPos]; } - T* operator->() { return &mMData[CCI::mCPos]; } - - ContainerIndex operator++(int) { auto tmp = *this; ++(*this); return tmp; } - ContainerIndex operator--(int) { auto tmp = *this; --(*this); return tmp; } - ContainerIndex& operator+=(int diff) { CCI::operator+=(diff); return *this; } - ContainerIndex& operator-=(int diff) { CCI::operator-=(diff); return *this; } - ContainerIndex operator+(int num) const { CCI::operator+(num); return *this; } - ContainerIndex operator-(int num) const { CCI::operator-(num); return *this; } - - int operator-(const ContainerIndex& it) const { return CCI::operator-(it); } - const T& operator[](int num) const { return CCI::operator[](num); } - - bool operator<(const ContainerIndex& it) const { return CCI::operator<(it); } - bool operator>(const ContainerIndex& it) const { return CCI::operator>(it); } - bool operator<=(const ContainerIndex& it) const { return CCI::operator<=(it); } - bool operator>=(const ContainerIndex& it) const { return CCI::operator>=(it); } - - }; - -} // end namespace CNORXZ - -#endif diff --git a/orig/include/conversions.h b/orig/include/conversions.h deleted file mode 100644 index 2b1dc78..0000000 --- a/orig/include/conversions.h +++ /dev/null @@ -1,122 +0,0 @@ - -#ifndef __cxz_conversions_h__ -#define __cxz_conversions_h__ - -#include "cxz_array.h" -#include "slice.h" - -namespace CNORXZ -{ - - namespace ConversionSizes - { - template - struct OrigSize - { - template - struct FromTo - { - static void check() { static_assert( not N % (sizeof(T) / sizeof(C)), "conversion does not fit" ); } - static constexpr size_t SIZE = N * sizeof(T) / sizeof(C); - }; - }; - - template <> - struct OrigSize - { - template - struct FromTo - { - static void check() {} - static constexpr size_t SIZE = MUI; - }; - }; - } - - namespace - { - template - using SC = typename ConversionSizes::OrigSize::template FromTo; - - template - using SCR = SC; - - template - using SCRR = GenSingleRange::SIZE>; - } - - template - struct SubTuple - { - template - static inline auto mk(const RTP& rtp, const Ranges&... rs) - -> decltype(SubTuple::mk(rtp, std::get(rtp), rs...)) - { - return SubTuple::mk(rtp, std::get(rtp), rs...); - } - }; - - template <> - struct SubTuple<0> - { - template - static inline auto mk(const RTP& rtp, const Ranges&... rs) - -> decltype(std::make_tuple(std::get<0>(rtp), rs...)) - { - return std::make_tuple(std::get<0>(rtp), rs...); - } - }; - - template - using LastR = typename std::tuple_element>::type; - - template - auto rtcast(const std::tuple...>& rtp) - -> decltype(std::tuple_cat(SubTuple::mk(rtp), - std::make_tuple( std::dynamic_pointer_cast>> - ( SCRR>::factory().create() ) ) )) - { - return std::tuple_cat(SubTuple::mk(rtp), - std::make_tuple( std::dynamic_pointer_cast>> - ( SCRR>::factory().create() ) ) ); - } - - template - inline Slice rangeTpToSlice( const std::tuple...>& rtp, T* data ) - { - return Slice(rtp, data); - } - - template - inline ConstSlice rangeTpToSlice( const std::tuple...>& rtp, const T* data ) - { - return ConstSlice(rtp, data); - } - - template - auto tcast(Array& ma) - -> decltype(rangeTpToSlice - ( rtcast( ma.range()->space() ), - reinterpret_cast( ma.data() ) )) - { - // VCHECK(reinterpret_cast(ma.data()) % 32); - //VCHECK(reinterpret_cast(reinterpret_cast(ma.data())) % 32); - return rangeTpToSlice - ( rtcast( ma.range()->space() ), - reinterpret_cast( ma.data() ) ); - } - - template - auto tcast(const Array& ma) - -> decltype(rangeTpToSlice - ( rtcast( ma.range()->space() ), - reinterpret_cast( ma.data() ) )) - { - //VCHECK(reinterpret_cast(ma.data()) % 32); - //VCHECK(reinterpret_cast(reinterpret_cast(ma.data())) % 32); - return rangeTpToSlice - ( rtcast( ma.range()->space() ), - reinterpret_cast( ma.data() ) ); - } -} -#endif diff --git a/orig/include/cxz_array.cc.h b/orig/include/cxz_array.cc.h deleted file mode 100644 index 797a991..0000000 --- a/orig/include/cxz_array.cc.h +++ /dev/null @@ -1,269 +0,0 @@ - -#include "cxz_array.h" -#include "statics/static_for.h" - -namespace CNORXZ -{ - template - Scalar scalar(const T& in) - { - NullRF nrf; - return Scalar( std::dynamic_pointer_cast( nrf.create() ), vector( { in } ) ); - } - - /******************* - * Array * - *******************/ - - template - Array::Array(const typename CRange::Space& space) : - MutableArrayBase(space), - mCont(MAB::mRange->size()) - { - MAB::mInit = true; - } - - template - Array::Array(const typename CRange::Space& space, - const vector& vec) : - MutableArrayBase(space), - mCont(vec) - { - MAB::mInit = true; - if(mCont.size() > MAB::mRange->size()){ - mCont.erase(mCont.begin() + MAB::mRange->size(), mCont.end()); - } - } - - - template - Array::Array(const std::shared_ptr&... ranges) : - MutableArrayBase(ranges...), - mCont(MAB::mRange->size()) - { - MAB::mInit = true; - } - - template - Array::Array(const std::shared_ptr&... ranges, const T& val) : - MutableArrayBase(ranges...), - mCont(MAB::mRange->size(), val) - { - MAB::mInit = true; - } - - template - Array::Array(const std::shared_ptr&... ranges, const vector& vec) : - MutableArrayBase(ranges...), - mCont(vec) - { - MAB::mInit = true; - if(mCont.size() > MAB::mRange->size()){ - mCont.erase(mCont.begin() + MAB::mRange->size(), mCont.end()); - } - } - - template - Array::Array(const std::shared_ptr&... ranges, vector&& vec) : - MutableArrayBase(ranges...), - mCont(std::forward>(vec)) - { - MAB::mInit = true; - if(mCont.size() > MAB::mRange->size()){ - mCont.erase(mCont.begin() + MAB::mRange->size(), mCont.end()); - } - } - - template - template - Array::Array(const std::shared_ptr&... ranges, Array&& in) : - MutableArrayBase(ranges...), - mCont( std::move( in.mCont ) ) - { - // maybe some checks here in the future... - assert(mCont.size() == MAB::mRange->size()); - MAB::mInit = true; - in.mInit = false; - } - - template - Array::Array(Array&& ama, SIZET... sizes) : - MutableArrayBase - ( ama.range()->template get<0>().template scast(sizes...)->space() ), - mCont( std::move( ama.mCont ) ) - { - MAB::mInit = true; - ama.mInit = false; - } - - template - T& Array::operator[](const IndexType& i) - { - return mCont[ i.pos() ]; - } - - template - const T& Array::operator[](const IndexType& i) const - { - return mCont[ i.pos() ]; - } - - template - T& Array::at(const typename IndexType::MetaType& meta) - { - return mCont[ MAB::cbegin().at(meta).pos() ]; - } - - template - const T& Array::at(const typename IndexType::MetaType& meta) const - { - return mCont[ MAB::cbegin().at(meta).pos() ]; - } - - template - bool Array::isConst() const - { - return false; - } - - template - bool Array::isSlice() const - { - return false; - } - - template - template - Array Array::format(const std::shared_ptr&... nrs) - { - //MAB::mInit = false; - return Array( nrs... , mCont ); - } - - template - template - Array Array::format(const std::tuple...>& nrs) - { - //MAB::mInit = false; - return Array( nrs , mCont ); - } - - template - template - Slice Array::slformat(const std::shared_ptr&... nrs) - { - return Slice( nrs..., mCont.data() ); - } - - template - template - ConstSlice Array::slformat(const std::shared_ptr&... nrs) const - { - return ConstSlice( nrs..., mCont.data() ); - } - - template - const T* Array::data() const - { - return mCont.data(); - } - - template - T* Array::data() - { - return mCont.data(); - } - - template - std::shared_ptr > Array::anonymous(bool slice) const - { - AnonymousRangeFactory arf(MAB::mRange->space()); - if(slice){ - return std::make_shared > - ( std::dynamic_pointer_cast( arf.create() ), - data() ); - } - else { - return std::make_shared > - ( std::dynamic_pointer_cast( arf.create() ), - mCont ); - } - } - - template - Array& Array::operator=(const T& in) - { - for(auto& x: mCont){ - x = in; - } - return *this; - } - - template - Array& Array::operator+=(const Array& in) - { - if(not MAB::mInit){ // not initialized by default constructor !! - (*this) = in; - } - else { - sfor_p<0,sizeof...(SRanges),0> - ( [&](auto i) { return std::get(MAB::mRange->space()).get() == std::get(in.mRange->space()).get(); }, - [&](auto a, auto b) { return a and b; }); - for(size_t i = 0; i != mCont.size(); ++i){ - mCont[i] += in.mCont[i]; - } - } - return *this; - } - - template - Array& Array::operator-=(const Array& in) - { - if(not MAB::mInit){ // not initialized by default constructor !! - (*this) = in; - } - else { - sfor_p<0,sizeof...(SRanges),0> - ( [&](auto i) { return std::get(MAB::mRange->space()).get() == std::get(in.mRange->space()).get(); }, - [&](auto a, auto b) { return a and b; }); - for(size_t i = 0; i != mCont.size(); ++i){ - mCont[i] -= in.mCont[i]; - } - } - return *this; - } - - template - Array& Array::operator*=(const T& in) - { - for(auto& x: mCont){ - x *= in; - } - return *this; - } - - template - Array& Array::operator/=(const T& in) - { - for(auto& x: mCont){ - x /= in; - } - return *this; - } - - template - Array::operator T() const - { - //static_assert( sizeof...(SRanges) == 1, "try to cast non-scalar type into scalar" ); - // TODO: check that SIZE is statically = 1 !!! - return mCont[0]; - } - - template - auto Array::cat() const - -> decltype(ArrayCatter::cat(*this)) - { - return ArrayCatter::cat(*this); - } -} - diff --git a/orig/include/cxz_array.h b/orig/include/cxz_array.h deleted file mode 100644 index 7b5471f..0000000 --- a/orig/include/cxz_array.h +++ /dev/null @@ -1,151 +0,0 @@ -// -*- C++ -*- - -#ifndef __cxz_array_h__ -#define __cxz_array_h__ - -#include - -#include "cxz_array_base.h" -#include "ranges/anonymous_range.h" - -namespace CNORXZ -{ - template - struct ArrayCatter; - - - template - struct ArrayCatter - { - template - static auto cat(const Array& ma) - -> Array - { - return ma; - } - }; - - template - class Array : public MutableArrayBase - { - public: - - typedef ContainerRange CRange; - typedef ArrayBase MAB; - typedef ConstContainerIndex IndexType; - - using ArrayBase::operator[]; - using MutableArrayBase::operator[]; - - DEFAULT_MEMBERS(Array); - Array(const std::shared_ptr&... ranges); - Array(const std::shared_ptr&... ranges, const T& val); - Array(const std::shared_ptr&... ranges, const vector& vec); - Array(const std::shared_ptr&... ranges, vector&& vec); - - template - Array(const std::shared_ptr&... ranges, Array&& in); // same effect as format - - Array(const typename CRange::Space& space); - Array(const typename CRange::Space& space, const vector& vec); - Array(Array&& ama, SIZET... sizes); - - // Only if ALL ranges have default extensions: - //Array(const vector& vec); - //Array(vector&& vec); - - // template - // Array(const Array,Range3> in); - - // implement contstructor using FunctionalArray as Input !!! - - //template - //Array& operator=(const Array,Range3> in); - - virtual T& operator[](const IndexType& i) final; - virtual const T& operator[](const IndexType& i) const final; - virtual T& at(const typename IndexType::MetaType& meta) override; - virtual const T& at(const typename IndexType::MetaType& meta) const override; - - virtual bool isConst() const override; - virtual bool isSlice() const override; - - template - Array format(const std::shared_ptr&... nrs); // reformat array using 'nr' which in - // total must have the same size as mRange - - template - Array format(const std::tuple...>& nrs); - - template - Slice slformat(const std::shared_ptr&... nrs); - - template - ConstSlice slformat(const std::shared_ptr&... nrs) const; - - virtual const T* data() const override; - virtual T* data() override; - virtual vector& vdata() { return mCont; } - virtual const vector& vdata() const { return mCont; } - vector&& vmove() { MAB::mInit = false; return std::move(mCont); } - - virtual std::shared_ptr > anonymous(bool slice = false) const override; - //virtual std::shared_ptr > anonymousMove() override; - - auto cat() const - -> decltype(ArrayCatter::cat(*this)); - - operator T() const; - - Array& operator=(const T& in); - - Array& operator+=(const Array& in); - Array& operator-=(const Array& in); - Array& operator*=(const T& in); - Array& operator/=(const T& in); - - template - friend class Array; - - private: - - vector mCont; - }; - - template - using Scalar = Array; - - template - Scalar scalar(const T& in); - - template - struct ArrayCatter > - { - template - static auto cat(const Array,Ranges...>& ma) - -> Array - { - auto sma = *ma.begin(); - const size_t smas = sma.size(); - const size_t mas = ma.size(); - auto cr = ma.range()->cat(sma.range()); - vector ov; - ov.reserve(mas * smas); - - for(auto& x: ma){ - assert(x.size() == smas); - ov.insert(ov.end(), x.vdata().begin(), x.vdata().end()); - } - return Array(cr->space(), std::move(ov)); - } - }; - - -} - -/* ========================= * - * --- TEMPLATE CODE --- * - * ========================= */ - - -#endif diff --git a/orig/include/cxz_array_base.cc.h b/orig/include/cxz_array_base.cc.h deleted file mode 100644 index 2f5552b..0000000 --- a/orig/include/cxz_array_base.cc.h +++ /dev/null @@ -1,274 +0,0 @@ - -#include "cxz_array_base.h" - -namespace CNORXZ -{ - - /********************** - * ArrayBase * - **********************/ - - template - ArrayBase::ArrayBase(const ArrayBase& in) : - mInit(in.mInit), - mRange(in.mRange) - { - if(mRange){ - mProtoI = std::make_shared( mRange, reinterpret_cast(this) ); - } - } - - - template - ArrayBase::ArrayBase(ArrayBase&& in) : - mInit(in.mInit), - mRange(in.mRange) - { - if(mRange){ - mProtoI = std::make_shared( mRange, reinterpret_cast(this) ); - } - } - - template - ArrayBase& ArrayBase::operator=(const ArrayBase& in) - { - mInit = in.mInit; - mRange = in.mRange; - if(mRange){ - mProtoI = std::make_shared( mRange, reinterpret_cast(this) ); - } - return *this; - } - - template - ArrayBase& ArrayBase::operator=(ArrayBase&& in) - { - mInit = in.mInit; - mRange = in.mRange; - if(mRange){ - mProtoI = std::make_shared( mRange, reinterpret_cast(this) ); - } - return *this; - } - - template - ArrayBase::ArrayBase(const std::shared_ptr&... ranges) - { - ContainerRangeFactory crf(ranges...); - mRange = std::dynamic_pointer_cast >( crf.create() ); - mProtoI = std::make_shared( mRange, reinterpret_cast(this) ); - } - - template - ArrayBase::ArrayBase(const typename CRange::Space& space) - { - ContainerRangeFactory crf(space); - mRange = std::dynamic_pointer_cast >( crf.create() ); - mProtoI = std::make_shared( mRange, reinterpret_cast(this) ); - } - - template - template - const T& ArrayBase::operator[](const ConstContainerIndex& i) - { - IndexType ii(*mProtoI); - ii = i; - return (*this)[ii]; - } - - template - const T& ArrayBase::operator[](const std::tuple...>& is) const - { - IndexType ii(*mProtoI); - ii(is); - return (*this)[ii]; - } - - template - size_t ArrayBase::size() const - { - return mRange->size(); - } - - template - typename ArrayBase::CIndexType ArrayBase::begin() const - { - return cbegin(); - } - - template - typename ArrayBase::CIndexType ArrayBase::end() const - { - return end(); - } - - template - typename ArrayBase::CIndexType ArrayBase::cbegin() const - { - CIndexType i(*mProtoI,true); - i = 0; - return i.setData(data()); - } - - template - typename ArrayBase::CIndexType ArrayBase::cend() const - { - CIndexType i(*mProtoI,true); - i = i.max(); - return i.setData(data()); - } - - template - const std::shared_ptr::CRange>& - ArrayBase::range() const - { - return mRange; - } - - template - bool ArrayBase::isConst() const - { - return true; - } - - template - ConstOperationRoot - ArrayBase::operator()(const std::shared_ptr&... inds) const - { - return ConstOperationRoot(*this, inds...); - } - - template - ConstOperationRoot - ArrayBase::op(const std::shared_ptr& ind) const - { - return ConstOperationRoot(data(), *ind); - } - - template - template - ConstOperationRoot - ArrayBase::m(const std::shared_ptr&... inds) const - { - static_assert(sizeof...(SRanges) == sizeof...(MappedRanges), - "number of mapped ranges must be equal to number of original ranges"); - return ConstOperationRoot(*this, inds...); - } - - template - bool ArrayBase::isInit() const - { - return mInit; - } - - template - template - auto ArrayBase::getRangePtr() const - -> decltype(mRange->template getPtr()) - { - return mRange->template getPtr(); - } - - - /****************************** - * MutableArrayBase * - ******************************/ - - template - MutableArrayBase::MutableArrayBase(const std::shared_ptr&... ranges) : - ArrayBase(ranges...) {} - - template - MutableArrayBase::MutableArrayBase(const typename CRange::Space& space) : - ArrayBase(space) {} - - template - template - T& MutableArrayBase::operator[](const ConstContainerIndex& i) - { - IndexType ii(*MAB::mProtoI); - ii = i; - return (*this)[ii]; - } - - template - T& MutableArrayBase::operator[](const std::tuple...>& is) - { - IndexType ii(*MAB::mProtoI,this->data()); - ii(is); - return (*this)[ii]; - } - - template - typename MutableArrayBase::IndexType MutableArrayBase::begin() - { - IndexType i(*MAB::mProtoI,this->data(),true); - i = 0; - return i.setData(data()); - } - - template - typename MutableArrayBase::IndexType MutableArrayBase::end() - { - IndexType i(*MAB::mProtoI,this->data(),true); - i = i.max(); - return i.setData(data()); - } - - - template - bool MutableArrayBase::isConst() const - { - return false; - } - - template - OperationRoot - MutableArrayBase::operator()(const std::shared_ptr&... inds) - { - return OperationRoot(*this, inds...); - } - - template - OperationRoot - MutableArrayBase::op(const std::shared_ptr& ind) - { - return OperationRoot(data(), *ind); - } - - template - ConstOperationRoot - MutableArrayBase::operator()(const std::shared_ptr&... inds) const - { - return ConstOperationRoot(*this, inds...); - } - - template - ConstOperationRoot - MutableArrayBase::op(const std::shared_ptr& ind) const - { - return ConstOperationRoot(data(), *ind); - } - - template - template - OperationRoot - MutableArrayBase::m(const std::shared_ptr&... inds) - { - static_assert(sizeof...(SRanges) == sizeof...(MappedRanges), - "number of mapped ranges must be equal to number of original ranges"); - return OperationRoot(*this, inds...); - } - - template - template - ConstOperationRoot - MutableArrayBase::m(const std::shared_ptr&... inds) const - { - static_assert(sizeof...(SRanges) == sizeof...(MappedRanges), - "number of mapped ranges must be equal to number of original ranges"); - return ConstOperationRoot(*this, inds...); - } - -} // end namespace CNORXZ - diff --git a/orig/include/cxz_array_base.h b/orig/include/cxz_array_base.h deleted file mode 100644 index 8a56a62..0000000 --- a/orig/include/cxz_array_base.h +++ /dev/null @@ -1,187 +0,0 @@ - -#ifndef __cxz_array_base_h__ -#define __cxz_array_base_h__ - -#include -#include -#include -#include - -#include "base_def.h" -#include "mbase_def.h" - -#include "ranges/rheader.h" - -namespace CNORXZ -{ - - template - using IPTR = std::shared_ptr; - - template - inline auto operator|(const IPTR& i1, const IPTR& i2) - -> decltype(std::make_tuple(i1,i2)) - { - return std::make_tuple(i1,i2); - } - - template - inline auto operator|(const IPTR& i1, - const std::tuple...>& i2) - -> decltype(std::tuple_cat(std::make_tuple(i1),i2)) - { - return std::tuple_cat(std::make_tuple(i1),i2); - } - - template - inline auto operator|(const std::tuple...>& i1, - const IPTR& i2) - -> decltype(std::tuple_cat(i1,std::make_tuple(i2))) - { - return std::tuple_cat(i1,std::make_tuple(i2)); - } - - template - inline auto operator~(const IPTR& i) - -> decltype(std::make_tuple(i)) - { - return std::make_tuple(i); - } - - // Explicitely specify subranges in template argument !!! - template - class ArrayBase - { - public: - - typedef T value_type; - typedef ContainerRange CRange; - typedef ConstContainerIndex CIndexType; - typedef ContainerIndex IndexType; - - protected: - bool mInit = false; - std::shared_ptr mRange; - std::shared_ptr mProtoI; - - public: - - //DEFAULT_MEMBERS(ArrayBase); - ArrayBase(const std::shared_ptr&... ranges); - ArrayBase(const typename CRange::Space& space); - - ArrayBase() = default; - ArrayBase(const ArrayBase& in); - ArrayBase(ArrayBase&& in); - ArrayBase& operator=(const ArrayBase& in); - ArrayBase& operator=(ArrayBase&& in); - - virtual ~ArrayBase() = default; - - template - const T& operator[](const ConstContainerIndex& i); - const T& operator[](const std::tuple...>& is) const; - - virtual const T& operator[](const CIndexType& i) const = 0; - virtual const T& at(const typename CRange::IndexType::MetaType& meta) const = 0; - - virtual const T* data() const = 0; - - virtual size_t size() const; - virtual bool isSlice() const = 0; - - virtual CIndexType begin() const; - virtual CIndexType end() const; - virtual CIndexType cbegin() const; - virtual CIndexType cend() const; - - virtual const std::shared_ptr& range() const; - - virtual bool isConst() const; - - virtual std::shared_ptr > anonymous(bool slice = false) const = 0; - - virtual ConstOperationRoot - op(const std::shared_ptr& ind) const; - - virtual ConstOperationRoot - operator()(const std::shared_ptr&... inds) const; - - template - ConstOperationRoot - m(const std::shared_ptr&... inds) const; - - virtual bool isInit() const; - - template - auto getRangePtr() const - -> decltype(mRange->template getPtr()); - - }; - - template - class MutableArrayBase : public ArrayBase - { - public: - - typedef ContainerRange CRange; - typedef ArrayBase MAB; - typedef ContainerIndex IndexType; - typedef ConstContainerIndex CIndexType; - - using ArrayBase::operator[]; - using ArrayBase::at; - using ArrayBase::data; - using ArrayBase::begin; - using ArrayBase::end; - using ArrayBase::cbegin; - using ArrayBase::cend; - - DEFAULT_MEMBERS(MutableArrayBase); - MutableArrayBase(const std::shared_ptr&... ranges); - MutableArrayBase(const typename CRange::Space& space); - - template - T& operator[](const ConstContainerIndex& i); - T& operator[](const std::tuple...>& is); - - virtual T& operator[](const CIndexType& i) = 0; - virtual T& at(const typename CRange::IndexType::MetaType& meta) = 0; - - virtual T* data() = 0; - - virtual IndexType begin(); - virtual IndexType end(); - - virtual bool isConst() const override; - - virtual ConstOperationRoot - op(const std::shared_ptr& ind) const override; - - virtual ConstOperationRoot - operator()(const std::shared_ptr&... inds) const override; - - virtual OperationRoot - op(const std::shared_ptr& ind); - - virtual OperationRoot operator()(const std::shared_ptr&... inds); - - template - OperationRoot - m(const std::shared_ptr&... inds); - - template - ConstOperationRoot - m(const std::shared_ptr&... inds) const; - - }; - - -} // end namespace CNORXZ - -/* ========================= * - * --- TEMPLATE CODE --- * - * ========================= */ - - -#endif diff --git a/orig/include/high_level_operation.cc.h b/orig/include/high_level_operation.cc.h deleted file mode 100644 index b66440c..0000000 --- a/orig/include/high_level_operation.cc.h +++ /dev/null @@ -1,448 +0,0 @@ - -#include "high_level_operation.h" - -namespace CNORXZ -{ - - template - DynamicO mkDynOp1(const Op& op) - { - return DynamicO(op); - } - - template - template - template - void HighLevelOpBase::RetT::appendOuterM(const Op& op, const Ops&... ops) - { - // does not check anything regarding input !!! - if(outer.init()){ - outer = mkDynOp1(mkMOp(outer,op,ops...)); - } - else { - outer = mkDynOp1(mkMOp(op,ops...)); - } - } - - template - template - void HighLevelOpBase::RetT::appendOuterM() - {} - - template - template - void HighLevelOpBase::RetT::appendOuter(const DynamicO& in) - { - if(in.init()){ - if(outer.init()){ - outer = mkDynOp1(mkMOp(outer,in)); - } - else { - outer = in; - } - } - } - - template - template - void HighLevelOpBase::RetT::appendOuter(const RetT& in) - { - appendOuter(in.outer); - } - - template - HighLevelOpRoot::HighLevelOpRoot(const ROP& op) : mOp(op) {} - - template - bool HighLevelOpRoot::root() const - { - return true; - } - - template - template - auto HighLevelOpRoot::xcreate(const std::shared_ptr&... inds) - -> typename B::template RetT - { - assert(0); - return typename B::template RetT(); - } - - template - ROP* HighLevelOpRoot::get() - { - return &mOp; - } - - template - auto HighLevelOpRoot::vget() - -> VOP* - { - return nullptr; - } - - template - HighLevelOpValue::HighLevelOpValue(const VOP& op) : mOp(op) {} - - template - bool HighLevelOpValue::root() const - { - return true; - } - - template - template - auto HighLevelOpValue::xcreate(const std::shared_ptr&... inds) - -> typename B::template RetT - { - assert(0); - return typename B::template RetT(); - } - - template - ROP* HighLevelOpValue::get() - { - return nullptr; - } - - template - auto HighLevelOpValue::vget() - -> VOP* - { - return &mOp; - } - - namespace - { - template - struct Create - { - template - struct ccx - { - template - static inline void - cccx(typename HighLevelOpBase::template RetT& res, - const std::array>,M>& in, - const std::shared_ptr&... inds, - const OPs&... ops, - const DOPs&... dops) - { - //static_assert(N > 0, "N > 0 failed"); - auto& inn = std::get(in); - if(not inn->root()){ - auto dop = inn->create(inds...); - auto op = *dop.op.data()->mOp; - res.appendOuter(dop); - assert(dop.op.init()); - if constexpr(N > 0){ - typedef decltype(op) OP; - Create::template ccx::template cccx - (res, in, inds..., op, ops..., dop, dops...); - } - else { - res.op = mkDynOutOp(mkFOp(op,ops...), inds...); - res.appendOuterM(dop.op,dops.op...); - } - } - else { - auto op = inn->get(); - auto vop = inn->vget(); - if constexpr(N > 0){ - typedef typename std::remove_reference::type OP; - typedef typename std::remove_reference::type VOP; - if(op != nullptr){ - Create::template ccx::template cccx - (res, in, inds..., *op, ops..., dops...); - } - else { - Create::template ccx::template cccx - (res, in, inds..., *vop, ops..., dops...); - } - } - else { - if(op != nullptr){ - res.op = mkDynOutOp(mkFOp(*op,ops...), inds...); - } - else { - res.op = mkDynOutOp(mkFOp(*vop,ops...), inds...); - } - res.appendOuterM(dops.op...); - } - } - } - }; - }; - - } - - template - HighLevelOp::HighLevelOp(std::array>,N> in) : mIn(in) {} - - template - bool HighLevelOp::root() const - { - return false; - } - - template - ROP* HighLevelOp::get() - { - assert(0); - return nullptr; - } - - template - auto HighLevelOp::vget() - -> VOP* - { - assert(0); - return nullptr; - } - - template - template - auto HighLevelOp::xcreate(const std::shared_ptr&... inds) - -> typename B::template RetT - { - typename B::template RetT res; - Create::template ccx::template cccx - (res,mIn,inds...); - return res; - } - - template - HighLevelOpHolder::HighLevelOpHolder(const std::shared_ptr>& op) : mOp(op) {} - - template - bool HighLevelOpHolder::root() const - { - return mOp->root(); - } - - template - template - auto HighLevelOpHolder::create(const std::shared_ptr&... inds) const - -> decltype(mOp->create(inds...)) - { - return mOp->create(inds...); - } - - template - auto HighLevelOpHolder::get() - -> decltype(mOp->get()) - { - return mOp->get(); - } - - template - std::shared_ptr> HighLevelOpHolder::op() const - { - return mOp; - } - - template - HighLevelOpHolder HighLevelOpHolder::operator*(const HighLevelOpHolder& in) const - { - return HighLevelOpHolder - ( std::make_shared,2>> - ( std::array>,2>({mOp, in.mOp}) ) ); - } - - template - HighLevelOpHolder HighLevelOpHolder::operator+(const HighLevelOpHolder& in) const - { - return HighLevelOpHolder - ( std::make_shared,2>> - ( std::array>,2>({mOp, in.mOp}) ) ); - } - - template - HighLevelOpHolder HighLevelOpHolder::operator-(const HighLevelOpHolder& in) const - { - return HighLevelOpHolder - ( std::make_shared,2>> - ( std::array>,2>({mOp, in.mOp}) ) ); - } - - template - HighLevelOpHolder HighLevelOpHolder::operator/(const HighLevelOpHolder& in) const - { - return HighLevelOpHolder - ( std::make_shared,2>> - ( std::array>,2>({mOp, in.mOp}) ) ); - } - - template - HighLevelOpHolder mkSFunc(const HighLevelOpHolder& a, const HighLevelOpHolder&... as) - { - constexpr size_t N = sizeof...(ROPs)+1; - return HighLevelOpHolder - ( std::make_shared> - ( std::array>,N>({a.op(), as.op()...}) ) ); - } - - template - template - HighLevelOpHolder& HighLevelOpHolder::xassign(const HighLevelOpHolder& in, - const std::shared_ptr& di, - const std::shared_ptr&... is) - { - const size_t dim = di->dim(); - if(dim > 2){ - auto ci1 = di->getP(dim-2)->reduced(); - auto ci2 = di->getP(dim-1)->reduced(); - assert(ci1 != nullptr); - assert(ci2 != nullptr); - auto odi = mkSubSpaceX(di, dim-2); - auto mi = mkMIndex(is..., odi); - this->assign(in, mi, ci1, ci2); - } - else { - assert(dim == 2 or dim == 1); - auto ci1 = di->getP(dim-1)->reduced(); - assert(ci1 != nullptr); - auto odi = mkSubSpaceX(di, dim-1); - auto mi = mkMIndex(is..., odi); - this->assign(in, mi, ci1); - } - return *this; - } - - template - template - HighLevelOpHolder& HighLevelOpHolder::xplus(const HighLevelOpHolder& in, - const std::shared_ptr& di, - const std::shared_ptr&... is) - { - const size_t dim = di->dim(); - if(dim > 2){ - auto ci1 = di->getP(dim-2)->reduced(); - auto ci2 = di->getP(dim-1)->reduced(); - assert(ci1 != nullptr); - assert(ci2 != nullptr); - auto odi = mkSubSpaceX(di, dim-2); - auto mi = mkMIndex(is..., odi); - this->plus(in, mi, ci1, ci2); - } - else { - assert(dim == 2 or dim == 1); - auto ci1 = di->getP(dim-1)->reduced(); - assert(ci1 != nullptr); - auto odi = mkSubSpaceX(di, dim-1); - auto mi = mkMIndex(is..., odi); - this->plus(in, mi, ci1); - } - return *this; - } - - template - std::string printInd(const std::shared_ptr& ind1, const std::shared_ptr& ind2, - const std::shared_ptr&... inds) - { - return std::to_string(reinterpret_cast(ind1.get())) + "(" + - std::to_string(ind1->max()) + "), " + printInd(ind2, inds...); - } - - template - std::string printInd(const std::shared_ptr& ind1) - { - return std::to_string(reinterpret_cast(ind1.get())) + "(" + std::to_string(ind1->max()) + ")"; - } - - template - template - HighLevelOpHolder& HighLevelOpHolder::assign(const HighLevelOpHolder& in, - const std::shared_ptr& mi, - const std::shared_ptr&... inds) - { - auto xx = mkArrayPtr(nullr()); - ROP& opr = *mOp->get(); - if(in.root()){ - auto inx = in; - opr.par().assign( *inx.get(), mkMIndex(mi,inds...) )(); - return *this; - } - auto loop = mkPILoop - ( [&opr,&in,&xx,&inds...,this](){ - auto inx = in; - auto dop = inx.create(inds...); - DynamicO gexp; - if(dop.outer.init()){ - gexp = mkDynOp1(mkMOp(dop.outer,dop.op)); - } - else { - gexp = mkDynOp1(mkMOp(dop.op)); - } - auto xloop = mkILoop(std::make_tuple(*dop.op.data()->mOp), - std::make_tuple(inds...), - std::make_tuple(xx), - std::make_tuple(opr.assign( *dop.op.data()->mOp, - mkMIndex(inds...) )), - std::array({1}), std::array({0})); - return mkGetExpr(gexp, xloop); }); - mi->pifor(1,loop)(); - return *this; - } - - template - template - HighLevelOpHolder& HighLevelOpHolder::plus(const HighLevelOpHolder& in, - const std::shared_ptr& mi, - const std::shared_ptr&... inds) - { - auto xx = mkArrayPtr(nullr()); - ROP& opr = *mOp->get(); - if(in.root()){ - auto inx = in; - opr.par().plus( *inx.get(), mkMIndex(mi,inds...) )(); - return *this; - } - auto loop = mkPILoop - ( [&opr,&in,&xx,&inds...,this](){ - auto inx = in; - auto dop = inx.create(inds...); - DynamicO gexp; - if(dop.outer.init()){ - gexp = mkDynOp1(mkMOp(dop.outer,dop.op)); - } - else { - gexp = mkDynOp1(mkMOp(dop.op)); - } - auto xloop = mkILoop(std::make_tuple(*dop.op.data()->mOp), - std::make_tuple(inds...), - std::make_tuple(xx), - std::make_tuple(opr.plus( *dop.op.data()->mOp, - mkMIndex(inds...) )), - std::array({1}), std::array({0})); - return mkGetExpr(gexp, xloop); }); - mi->pifor(1,loop)(); - return *this; - } - - template - HighLevelOpHolder mkHLO(const ROP& op) - { - return HighLevelOpHolder(std::make_shared>( op ) ); - } - - template - HighLevelOpHolder mkHLOV(double val) - { - return HighLevelOpHolder(std::make_shared> - ( OperationValue(val) ) ); - } - - -#define SP " " -#define regFunc1(fff) template \ - HighLevelOpHolder hl_##fff (const HighLevelOpHolder& in) \ - { return HighLevelOpHolder( std::make_shared,1>> \ - ( std::array>,1>( {in.op()} ) ) ); } \ - -#include "extensions/math.h" -#undef regFunc1 -#undef SP - -} - diff --git a/orig/include/high_level_operation.h b/orig/include/high_level_operation.h deleted file mode 100644 index b2fafa8..0000000 --- a/orig/include/high_level_operation.h +++ /dev/null @@ -1,279 +0,0 @@ - -#ifndef __cxz_high_level_operation_h__ -#define __cxz_high_level_operation_h__ - -#include "base_def.h" -#include "ranges/rheader.h" -#include "dynamic_operation.h" - -namespace CNORXZ -{ - - typedef ClassicRange CR; - typedef CR::IndexType CI; - typedef std::shared_ptr CIP; - - typedef OperationRoot OpCD; - typedef OperationRoot OpD; - extern template class OperationRoot; - extern template class OperationRoot; - - template - DynamicO mkDynOp1(const Op& op); - - std::shared_ptr mkSubSpaceX(const std::shared_ptr& di, size_t max); - - template - class HighLevelOpBase - { - public: - - typedef OperationValue VOP; - - template - struct RetT - { - DynamicO>> op; - DynamicO outer; - - template - void appendOuterM(const Op& op, const Ops&... ops); - - void appendOuterM(); - void appendOuter(const DynamicO& in); - void appendOuter(const RetT& in); - - }; - - virtual bool root() const = 0; - -#define reg_ind1(I1) virtual RetT create \ - (const std::shared_ptr& ind1) = 0 -#define reg_ind2(I1,I2) virtual RetT create \ - (const std::shared_ptr& ind1,const std::shared_ptr& ind2) = 0 -#define reg_ind3(I1,I2,I3) virtual RetT create \ - (const std::shared_ptr& ind1,const std::shared_ptr& ind2,const std::shared_ptr& ind3) = 0 - - //#include "hl_reg_ind.h" - reg_ind1(ClassicRange::IndexType); - reg_ind2(ClassicRange::IndexType,ClassicRange::IndexType); - reg_ind3(ClassicRange::IndexType,ClassicRange::IndexType,ClassicRange::IndexType); - -#undef reg_ind1 -#undef reg_ind2 -#undef reg_ind3 - - virtual ROP* get() = 0; - virtual VOP* vget() = 0; - - }; - - template - class HighLevelOpRoot : public HighLevelOpBase - { - private: - typedef HighLevelOpBase B; - typedef typename B::VOP VOP; - - template - typename B::template RetT xcreate(const std::shared_ptr&... inds); - - ROP mOp; - public: - - HighLevelOpRoot(const ROP& op); - - virtual bool root() const override final; - -#define reg_ind1(I1) virtual typename B::template RetT create \ - (const std::shared_ptr& ind1) \ - override final { return xcreate(ind1); } -#define reg_ind2(I1,I2) virtual typename B::template RetT create \ - (const std::shared_ptr& ind1, const std::shared_ptr& ind2) \ - override final { return xcreate(ind1,ind2); } -#define reg_ind3(I1,I2,I3) virtual typename B::template RetT create \ - (const std::shared_ptr& ind1, const std::shared_ptr& ind2, const std::shared_ptr& ind3) \ - override final { return xcreate(ind1,ind2,ind3); } - - //#include "hl_reg_ind.h" - reg_ind1(ClassicRange::IndexType); - reg_ind2(ClassicRange::IndexType,ClassicRange::IndexType); - reg_ind3(ClassicRange::IndexType,ClassicRange::IndexType,ClassicRange::IndexType); - - virtual ROP* get() override final; - virtual VOP* vget() override final; - - }; - - extern template class HighLevelOpBase; - extern template class HighLevelOpBase; - extern template class HighLevelOpRoot; - extern template class HighLevelOpRoot; - - template - class HighLevelOpValue : public HighLevelOpBase - { - private: - typedef HighLevelOpBase B; - typedef typename B::VOP VOP; - - template - typename B::template RetT xcreate(const std::shared_ptr&... inds); - - VOP mOp; - public: - - HighLevelOpValue(const VOP& vop); - - virtual bool root() const override final; - - //#include "hl_reg_ind.h" - reg_ind1(ClassicRange::IndexType); - reg_ind2(ClassicRange::IndexType,ClassicRange::IndexType); - reg_ind3(ClassicRange::IndexType,ClassicRange::IndexType,ClassicRange::IndexType); - - virtual ROP* get() override final; - virtual VOP* vget() override final; - - }; - - template - auto mkFOp(const Ops&... ops) - { - return Operation(ops...); - } - - - - template - class HighLevelOp : public HighLevelOpBase - { - public: - typedef HighLevelOpBase B; - typedef typename B::VOP VOP; - - private: - std::array>,N> mIn; - - template - auto xcreate(const std::shared_ptr&... inds) - -> typename B::template RetT; - - public: - HighLevelOp(std::array>,N> in); - - virtual bool root() const override final; - - virtual ROP* get() override final; - virtual VOP* vget() override final; - - //#include "hl_reg_ind.h" - reg_ind1(ClassicRange::IndexType); - reg_ind2(ClassicRange::IndexType,ClassicRange::IndexType); - reg_ind3(ClassicRange::IndexType,ClassicRange::IndexType,ClassicRange::IndexType); - -#undef reg_ind1 -#undef reg_ind2 -#undef reg_ind3 - }; - - extern template class HighLevelOp,2>; - extern template class HighLevelOp,2>; - extern template class HighLevelOp,2>; - extern template class HighLevelOp,2>; - extern template class HighLevelOp,2>; - extern template class HighLevelOp,2>; - extern template class HighLevelOp,2>; - extern template class HighLevelOp,2>; - -#define regFunc1(fff) \ - extern template class HighLevelOp,1>; \ - extern template class HighLevelOp,1>; -#include "extensions/math.h" -#undef regFunc1 - - template - class HighLevelOpHolder - { - private: - std::shared_ptr> mOp; - - public: - HighLevelOpHolder() = default; - HighLevelOpHolder(const HighLevelOpHolder& in) = default; - HighLevelOpHolder(HighLevelOpHolder&& in) = default; - HighLevelOpHolder& operator=(const HighLevelOpHolder& in) = default; - HighLevelOpHolder& operator=(HighLevelOpHolder&& in) = default; - - HighLevelOpHolder(const std::shared_ptr>& op); - - bool root() const; - - template - auto create(const std::shared_ptr&... inds) const - -> decltype(mOp->create(inds...)); - - auto get() -> decltype(mOp->get()); - - std::shared_ptr> op() const; - HighLevelOpHolder operator*(const HighLevelOpHolder& in) const; - HighLevelOpHolder operator+(const HighLevelOpHolder& in) const; - HighLevelOpHolder operator-(const HighLevelOpHolder& in) const; - HighLevelOpHolder operator/(const HighLevelOpHolder& in) const; - - - template - HighLevelOpHolder& xassign(const HighLevelOpHolder& in, - const std::shared_ptr& di, - const std::shared_ptr&... is); - - template - HighLevelOpHolder& xplus(const HighLevelOpHolder& in, - const std::shared_ptr& di, - const std::shared_ptr&... is); - - template - HighLevelOpHolder& assign(const HighLevelOpHolder& in, - const std::shared_ptr& mi, - const std::shared_ptr&... inds); - - template - HighLevelOpHolder& plus(const HighLevelOpHolder& in, - const std::shared_ptr& mi, - const std::shared_ptr&... inds); - }; - - extern template class HighLevelOpHolder; - extern template class HighLevelOpHolder; - - template - HighLevelOpHolder mkSFunc(const HighLevelOpHolder& a, const HighLevelOpHolder&... as); - - - template - HighLevelOpHolder mkHLO(const ROP& op); - - template - HighLevelOpHolder mkHLOV(double val); - - extern template HighLevelOpHolder mkHLO(const OpCD& op); - extern template HighLevelOpHolder mkHLO(const OpD& op); - extern template HighLevelOpHolder mkHLOV(double val); - extern template HighLevelOpHolder mkHLOV(double val); - -#define regFunc1(fff) template \ - HighLevelOpHolder hl_##fff (const HighLevelOpHolder& in); -#include "extensions/math.h" -#undef regFunc1 - -#define regFunc1(fff) template \ - HighLevelOpHolder hl_##fff (const HighLevelOpHolder& in); \ - extern template HighLevelOpHolder hl_##fff (const HighLevelOpHolder& in); \ - extern template HighLevelOpHolder hl_##fff (const HighLevelOpHolder& in); -#include "extensions/math.h" -#undef regFunc1 - - -} - -#endif diff --git a/orig/include/hl_cnorxz.h b/orig/include/hl_cnorxz.h deleted file mode 100644 index e831a63..0000000 --- a/orig/include/hl_cnorxz.h +++ /dev/null @@ -1,3 +0,0 @@ -#include "high_level_operation.h" - -#include "high_level_operation.cc.h" diff --git a/orig/include/map_range.cc.h b/orig/include/map_range.cc.h deleted file mode 100644 index d9c0cd5..0000000 --- a/orig/include/map_range.cc.h +++ /dev/null @@ -1,704 +0,0 @@ - -#include "map_range.h" -#include - -namespace CNORXZ -{ - - namespace - { - using namespace CNORXZInternal; - } - - /************** - * OpExpr * - **************/ - - template - OpExpr::OpExpr(const Op& mapf, const Index* ind, - size_t step, Expr ex) : - mIndPtr(ind), mSPos(mIndPtr->pos()), mMax(mIndPtr->max()), - mStep(step), mExpr( ex ), - mOp(mapf), - //mExt(ex.rootSteps( reinterpret_cast( mIndPtr ))) - mExt( mOp.rootSteps( reinterpret_cast( mIndPtr ) ).extend - ( ex.rootSteps( reinterpret_cast( mIndPtr ) ) ) ) - { - assert(mIndPtr != nullptr); - } - - template - std::shared_ptr OpExpr::deepCopy() const - { - return std::make_shared>(*this); - } - - template - inline void OpExpr::operator()(size_t mlast, DExt last) - { - operator()(mlast, std::dynamic_pointer_cast>(last)->ext()); - } - - template - inline void OpExpr::operator()(size_t mlast, - ExtType last) - { - constexpr size_t NEXT = Op::SIZE; - const ExtType nxpos = last; - const size_t pos = mIndPtr->posAt( mOp.get( nxpos ) ); - if(pos != mIndPtr->max()){ - const ExtType npos = last + mExt*pos; - const size_t mnpos = PosForward::valuex(mlast, mStep, pos); - mExpr(mnpos, getX( npos ) ); - } - } - - template - inline void OpExpr::operator()(size_t mlast) - { - const ExtType last; - constexpr size_t NEXT = Op::SIZE; - const ExtType nxpos = last; - const size_t pos = mIndPtr->posAt( mOp.get( nxpos ) ); - if(pos != mIndPtr->max()){ - const ExtType npos = last + mExt*pos; - const size_t mnpos = PosForward::valuex(mlast, mStep, pos); - mExpr(mnpos, getX( npos )); - } - } - - template - auto OpExpr::rootSteps(std::intptr_t iPtrNum) const - -> ExtType - { - return mOp.rootSteps(iPtrNum).extend( mExpr.rootSteps(iPtrNum) ); - //return mExpr.rootSteps(iPtrNum).extend( mOp.rootSteps(iPtrNum) ); - } - - template - DExt OpExpr::dRootSteps(std::intptr_t iPtrNum) const - { - return std::make_shared>(rootSteps(iPtrNum)); - } - - template - DExt OpExpr::dExtension() const - { - return std::make_shared>(mExt); - } - - /****************** - * MapIndex * - ******************/ - - template - template - GenMapIndex::GenMapIndex(const std::shared_ptr& range) : - IndexInterface,typename Op::value_type>(range, 0) - { - std::get(mBlockSizes) = 1; - sfor_mn - ( [&](auto i) { - auto r = range->template getPtr(); - std::get(mIPack) = r->beginPtr(); - *std::get(mIPack) = 0; - - std::get(mBlockSizes) = sfor_p - ( [&](auto j) { return std::get(mIPack)->max(); } , - [&](auto a, auto b) { return a * b; }); - return 0; - }); - - IB::mPos = sfor_m - ( [&](auto i) { return std::get(mIPack); }, - [&](auto a, auto b) {return a->pos() + b*a->max();}, 0 ); - mOutIndex = std::make_shared - ( std::dynamic_pointer_cast( IB::mRangePtr )->outRange()->begin() ); - } - - template - template - GenMapIndex& GenMapIndex::up() - { - static_assert(DIR < sizeof...(Indices), "DIR exceeds number of sub-indices"); - IB::mPos += sfor_p - ( [&](auto i) { return std::get(mIPack)->max(); }, - [&](auto a, auto b) { return a * b; } ); - sfor_m - ( [&](auto i) { - auto& si = *std::get( mIPack ); - if(si.last() and i != 0) { si = 0; return true; } - else { ++si; return false; } - return false; - } ); - return *this; - } - - template - template - GenMapIndex& GenMapIndex::down() - { - static_assert(DIR < sizeof...(Indices), "DIR exceeds number of sub-indices"); - IB::mPos -= sfor_p - ( [&](auto i) { return std::get(mIPack)->max(); }, - [&](auto a, auto b) { return a * b; } ); - sfor_m - ( [&](auto i) { - auto& si = *std::get( mIPack ); - if(si.first() and i != 0) { si = si.max()-1; return true; } - else { --si; return false; } - return false; - } ); - return *this; - } - - template - template - auto GenMapIndex::get() const -> decltype( *std::get( mIPack ) )& - { - return *std::get(mIPack); - } - - template - template - auto GenMapIndex::getPtr() const -> decltype( std::get( mIPack ) )& - { - return std::get(mIPack); - } - - template - auto GenMapIndex::outIndex() const -> std::shared_ptr - { - return mOutIndex; - } - - template - GenMapIndex& GenMapIndex::operator()(const std::shared_ptr&... indices) - { - return (*this)(std::make_tuple(indices...)); - } - - template - GenMapIndex& GenMapIndex::operator()(const std::tuple...>& indices) - { - sfor_pn<0,sizeof...(Indices)> - ( [&](auto i) { std::get(mIPack) = std::get(indices); return 0; } ); - RangeHelper::setIndexPack(mIPack, IB::mPos); - return *this; - } - - template - IndexType GenMapIndex::type() const - { - return IndexType::MULTI; - } - - template - GenMapIndex& GenMapIndex::operator=(size_t pos) - { - (*mOutIndex) = pos; - IB::mPos = mOutIndex->pos(); - return *this; - } - - template - GenMapIndex& GenMapIndex::operator++() - { - ++(*mOutIndex); - IB::mPos = mOutIndex->pos(); - return *this; - } - - template - GenMapIndex& GenMapIndex::operator--() - { - --(*mOutIndex); - IB::mPos = mOutIndex->pos(); - return *this; - } - - template - int GenMapIndex::pp(std::intptr_t idxPtrNum) - { - mOutIndex->pp(idxPtrNum); - IB::mPos = mOutIndex->pos(); - return 1; - } - - template - int GenMapIndex::mm(std::intptr_t idxPtrNum) - { - mOutIndex->mm(idxPtrNum); - IB::mPos = mOutIndex->pos(); - return 1; - } - - template - std::string GenMapIndex::stringMeta() const - { - return std::dynamic_pointer_cast( IB::mRangePtr )->stringMeta(IB::mPos); - } - - template - typename GenMapIndex::MetaType GenMapIndex::meta() const - { - return mOutIndex->meta(); - } - - template - GenMapIndex& GenMapIndex::at(const MetaType& metaPos) - { - mOutIndex->at(metaPos); - IB::mPos = mOutIndex->pos(); - return *this; - } - - template - size_t GenMapIndex::posAt(const MetaType& metaPos) const - { - return range()->outRange()->getMeta(metaPos); - } - - template - size_t GenMapIndex::dim() const - { - return sizeof...(Indices); - } - - template - bool GenMapIndex::first() const - { - return IB::mPos == 0; - } - - template - bool GenMapIndex::last() const - { - return IB::mPos == IB::mMax - 1; - } - - template - std::shared_ptr::RangeType> - GenMapIndex::range() const - { - return std::dynamic_pointer_cast( IB::mRangePtr ); - } - - template - template - auto GenMapIndex::getPtr() -> decltype( std::get( mIPack ) )& - { - return std::get(mIPack); - } - - template - size_t GenMapIndex::getStepSize(size_t n) const - { - if(n >= sizeof...(Indices)){ - assert(0); - // throw !! - } - return mBlockSizes[n+1]; - } - - template - template - auto GenMapIndex::ifor(size_t step, Exprs exs) const - { - return RangeHelper::mkFor<0> - (0, mIPack, mBlockSizes, - OpExpr,Exprs,XSTYPE> - ( range()->map(), this, step, exs )); - } - - template - template - auto GenMapIndex::pifor(size_t step, Exprs exs) const - { - return ifor(step, exs); - } - - template - template - auto GenMapIndex::iforh(size_t step, Exprs exs) const - { - return ifor(step, exs); - } - - /************************* - * MapRangeFactory * - *************************/ - - template - template - GenMapRangeFactory::GenMapRangeFactory(const std::shared_ptr& outr, - const std::tuple& mapf, - const std::shared_ptr&... rs) - { - mProd = std::shared_ptr< GenMapRange > - ( new GenMapRange( outr, mapf, rs... ) ); - } - - template - template - GenMapRangeFactory::GenMapRangeFactory(const std::shared_ptr& outr, - const std::tuple& mapf, - const typename GenMapRange::Space& st) - { - mProd = std::shared_ptr< GenMapRange > - ( new GenMapRange( outr, mapf, st ) ); - } - - template - template - GenMapRangeFactory::GenMapRangeFactory(const std::tuple& mapf, - const std::shared_ptr&... rs) - { - mProd = std::shared_ptr< GenMapRange > - ( new GenMapRange( mapf, rs... ) ); - } - - template - template - GenMapRangeFactory::GenMapRangeFactory(const std::tuple& mapf, - const typename GenMapRange::Space& st) - { - mProd = std::shared_ptr< GenMapRange > - ( new GenMapRange( mapf, st ) ); - } - - template - std::shared_ptr GenMapRangeFactory::create() - { - mProd = checkIfCreated( std::dynamic_pointer_cast( mProd )->mSpace ); - setSelf(); - return mProd; - } - - template - std::shared_ptr GenMapRangeFactory::checkIfCreated(const std::tuple...>& ptp) - { - std::shared_ptr out; - bool check = false; - for(auto& x: MapRangeFactoryProductMap::mAleadyCreated){ - if(x.second.size() == sizeof...(Ranges)){ - check = sfor_p<0,sizeof...(Ranges)> - ( [&](auto i) { return reinterpret_cast( std::get(ptp).get() ) == x.second[i]; }, - [&](auto a, auto b) { return a and b; } ); - if(check){ - out = x.first; - break; - } - } - } - if(not check){ - vector pv(sizeof...(Ranges)); - sfor_pn<0,sizeof...(Ranges)> - ( [&](auto i) { pv[i] = reinterpret_cast( std::get(ptp).get() ); return 0; } ); - pv.push_back( reinterpret_cast - ( &std::dynamic_pointer_cast( mProd )->mMapf ) ); - MapRangeFactoryProductMap::mAleadyCreated[mProd] = pv; - out = mProd; - } - return out; - } - - /****************** - * MapRange * - ******************/ - - template - struct OutRangeMaker - {}; - - template <> - struct OutRangeMaker - { - template - static void mk(std::shared_ptr& outRange, Array& mapMult, const MapF& mapf) - { - std::map mult; - for(auto ii = mapf.begin(); ii.max() != ii.pos(); ++ii) { - mult[mapf[ii]]++; - } - - vector outmeta(mult.size()); - vector outmult(mult.size()); - - size_t cnt = 0; - for(auto& x: mult){ - outmeta[cnt] = x.first; - outmult[cnt] = x.second; - ++cnt; - } - - typename ORType::FType orf(outmeta); - outRange = std::dynamic_pointer_cast( orf.create() ); - mapMult = Array( outRange, outmult ); - } - }; - - template <> - struct OutRangeMaker - { - template - static void mk(std::shared_ptr& outRange, Array& mapMult, const MapF& mapf) - { - static_assert( std::is_same::value, - "out range value type for NONE must be size_t" ); - size_t max = 0; - for(auto ii = mapf.begin(); ii.max() != ii.pos(); ++ii) { - max = mapf[ii]+1 > max ? mapf[ii]+1 : max; - } - vector mult(max,0); - for(auto ii = mapf.begin(); ii.max() != ii.pos(); ++ii) { - mult[mapf[ii]]++; - } - - vector outmult(mult.size()); - - size_t cnt = 0; - for(auto& x: mult){ - outmult[cnt++] = x; - } - - typename ORType::FType orf(max); - outRange = std::dynamic_pointer_cast( orf.create() ); - mapMult = Array( outRange, outmult ); - } - }; - - template - template - void GenMapRange::mkOutRange(const MA& mapf) - { - //FunctionalArray fma(mSpace, mMapf); - OutRangeMaker::mk(mOutRange,mMapMult,mapf); - auto i = mapf.begin(); - mMapPos.resize(i.max()); - for(; i.pos() != i.max(); ++i){ - mMapPos[i.pos()] = mOutRange->getMeta( mapf[i] ); - } - - } - - template - template - GenMapRange::GenMapRange(const std::shared_ptr& outr, const std::tuple& mapf, - const std::shared_ptr&... rs) : - mSpace(std::make_tuple(rs...)), - mMapf(std::get<0>(mapf)), - mOutRange(outr), - mMapMult(mOutRange,0), - mMapPos(std::get<1>(mapf).size(),mOutRange->size()) - { - auto& ma = std::get<1>(mapf); - auto jj = mMapMult.begin(); - for(auto ii = ma.begin(); ii.pos() != ii.max(); ++ii){ - ++mMapMult[jj.at(ma[ii])]; - mMapPos[ii.pos()] = jj.pos(); - } - } - - template - template - GenMapRange::GenMapRange(const std::shared_ptr& outr, const std::tuple& mapf, - const Space& space) : - mSpace(space), - mMapf(std::get<0>(mapf)), - mOutRange(outr), - mMapMult(mOutRange,0), - mMapPos(std::get<1>(mapf).size(),mOutRange->size()) - { - auto& ma = std::get<1>(mapf); - auto jj = mMapMult.begin(); - for(auto ii = ma.begin(); ii.pos() != ii.max(); ++ii){ - ++mMapMult[jj.at(ma[ii])]; - mMapPos[ii.pos()] = jj.pos(); - } - } - - template - template - GenMapRange::GenMapRange(const std::tuple& mapf, - const std::shared_ptr&... rs) : - mSpace(std::make_tuple(rs...)), - mMapf(std::get<0>(mapf)) - { - mkOutRange(std::get<1>(mapf)); - } - - template - template - GenMapRange::GenMapRange(const std::tuple& mapf, const Space& space) : - mSpace( space ), - mMapf(std::get<0>(mapf)) - { - mkOutRange(std::get<1>(mapf)); - } - - template - template - auto GenMapRange::get() const -> decltype( *std::get( mSpace ) )& - { - return *std::get(mSpace); - } - - template - template - auto GenMapRange::getPtr() const -> decltype( std::get( mSpace ) )& - { - return std::get(mSpace); - } - - template - auto GenMapRange::outRange() const -> std::shared_ptr - { - return mOutRange; - } - - template - const Op& GenMapRange::map() const - { - return mMapf; - } - - template - size_t GenMapRange::dim() const - { - return sdim; - } - - template - size_t GenMapRange::size() const - { - return mOutRange->size(); - } - - template - SpaceType GenMapRange::spaceType() const - { - return SpaceType::ANY; - } - - template - const typename GenMapRange::Space& GenMapRange::space() const - { - return mSpace; - } - - template - vector GenMapRange::typeNum() const - { - vector o; - RangeHelper::getTypeNum(o,mSpace); - return o; - } - - template - size_t GenMapRange::cmeta(char* target, size_t pos) const - { - //MetaType* xtarget = reinterpret_cast(target); - assert(0); - return 0; - } - - template - size_t GenMapRange::cmetaSize() const - { - return RangeHelper::getCMetaSize<0>(mSpace); - } - - template - std::string GenMapRange::stringMeta(size_t pos) const - { - auto i = begin(); - i = pos; - return "[ " + RangeHelper::getStringMeta<0>(i) + " ]"; - } - - template - vector GenMapRange::data() const - { - DataHeader h = dataHeader(); - vector out; - //out.reserve(h.metaSize + sizeof(DataHeader)); - char* hcp = reinterpret_cast(&h); - out.insert(out.end(), hcp, hcp + sizeof(DataHeader)); - sfor_pn<0,sizeof...(Ranges)> - ( [&](auto i) { - vector part = std::get(mSpace)->data(); - out.insert(out.end(), part.begin(), part.end()); - return 0; - } ); - return out; - } - - template - DataHeader GenMapRange::dataHeader() const - { - DataHeader h; - h.spaceType = static_cast( SpaceType::ANY ); - h.metaSize = sizeof...(Ranges); - h.multiple = 1; - return h; - } - - template - typename GenMapRange::IndexType GenMapRange::begin() const - { - GenMapIndex - i( std::dynamic_pointer_cast > - ( std::shared_ptr( RB::mThis ) ) ); - i = 0; - return i; - } - - template - typename GenMapRange::IndexType GenMapRange::end() const - { - GenMapIndex - i( std::dynamic_pointer_cast > - ( std::shared_ptr( RB::mThis )) ); - i = size(); - return i; - } - - template - auto GenMapRange::mapMultiplicity() const - -> const Array& - { - return mMapMult; - } - - template - auto GenMapRange::explMapMultiplicity() const - -> ConstSlice - { - /* - auto tmp = mMapMult; - return tmp.format( std::dynamic_pointer_cast > - ( std::shared_ptr( RB::mThis )) ); - */ - return mMapMult.slformat(std::dynamic_pointer_cast > - ( std::shared_ptr( RB::mThis ))); - } - - template - vector GenMapRange::mapPos() const - { - return mMapPos; - } - - /* - template - template - auto GenMapRange::cat(const std::shared_ptr >& erange) - -> std::shared_ptr > - { - auto crange = std::tuple_cat(mSpace, erange->space()); - MapRangeFactory rf(crange); - return std::dynamic_pointer_cast >(rf.create()); - } - */ -} diff --git a/orig/include/map_range.h b/orig/include/map_range.h deleted file mode 100644 index 024a7f5..0000000 --- a/orig/include/map_range.h +++ /dev/null @@ -1,354 +0,0 @@ -// -*- C++ -*- - -#ifndef __cxz_map_range_h__ -#define __cxz_map_range_h__ - -#include -#include -#include -#include - -#include "mbase_def.h" -#include "ranges/range_base.h" -#include "ranges/index_base.h" - -#include "map_range_factory_product_map.h" -#include "ranges/x_to_string.h" -#include "ranges/type_map.h" - -#include "xfor/xfor.h" - -namespace CNORXZ -{ - namespace - { - using namespace CNORXZInternal; - } - - - template - auto mkMapOp(const std::shared_ptr& func, - const std::shared_ptr&... is) - -> decltype(std::make_tuple(FunctionalArray().exec(is...), - FunctionalArray())) - { - typedef FunctionalArray FMA; - if(Func::FISSTATIC){ - FMA fma(is->range()...); - return std::make_tuple(fma.exec(is...),fma); - } - else { - FMA fma(is->range()...,func); - return std::make_tuple(fma.exec(is...),fma); - } - } - - - - template - //template - class OpExpr : public ExpressionBase - { - public: - //typedef typename Index::OIType OIType; - //typedef SingleIndex OIType; - static constexpr size_t LAYER = Expr::LAYER + 1; - static constexpr size_t SIZE = Expr::SIZE + Op::SIZE; - static constexpr size_t NHLAYER = Expr::NHLAYER + 1; - - private: - OpExpr() = default; - - const Index* mIndPtr; - //const OIType* mIndPtr; - size_t mSPos; - size_t mMax; - size_t mStep; - Expr mExpr; - Op mOp; - - typedef decltype(mOp.rootSteps(std::declval()).extend( mExpr.rootSteps(std::declval()) )) ExtType; - ExtType mExt; - - public: - OpExpr(const OpExpr& in) = default; - OpExpr(OpExpr&& in) = default; - OpExpr& operator=(const OpExpr& in) = default; - OpExpr& operator=(OpExpr&& in) = default; - - OpExpr(const Op& mapf, const Index* ind, size_t step, Expr ex); - - virtual std::shared_ptr deepCopy() const override final; - - template - inline auto vec() const { return *this; } - - inline void operator()(size_t mlast, DExt last) override final; - inline void operator()(size_t mlast, ExtType last); - inline void operator()(size_t mlast = 0) override final; - - auto rootSteps(std::intptr_t iPtrNum = 0) const -> ExtType; - - virtual DExt dRootSteps(std::intptr_t iPtrNum = 0) const override final; - virtual DExt dExtension() const override final; - - }; - - template - class GenMapIndex : public IndexInterface, - typename Op::value_type> - //std::tuple > - { - public: - - typedef IndexInterface, - typename Op::value_type> IB; - //std::tuple > IB; - typedef std::tuple...> IndexPack; - //typedef std::tuple MetaType; - typedef typename Op::value_type MetaType; - typedef GenMapRange RangeType; - typedef GenMapIndex IType; - //typedef SingleIndex OIType; - - static constexpr IndexType sType() { return IndexType::SINGLE; } - static constexpr size_t sDim() { return sizeof...(Indices); } - static constexpr size_t totalDim() { return (... * Indices::totalDim()); } - static void check_type() { static_assert( std::is_same::value, "inconsitent value types" ); } - - static constexpr SpaceType STYPE = XSTYPE; - static constexpr bool PARALLEL = false; - - private: - - IndexPack mIPack; - std::array mBlockSizes; - std::shared_ptr mOutIndex; - - public: - - const IndexPack& pack() const { return mIPack; } - - GenMapIndex() = delete; - - // NO DEFAULT HERE !!! - // ( have to assign sub-indices (ptr!) correctly ) - //MapIndex(const MapIndex& in); - //MapIndex& operator=(const MapIndex& in); - - template - GenMapIndex(const std::shared_ptr& range); - - template - GenMapIndex& up(); - - template - GenMapIndex& down(); - - template - auto get() const -> decltype( *std::get( mIPack ) )&; - - 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 ConstContainerIndex - // MultiIndices CANNOT be influences be its subindices, so there is - // NO foreign/external controll) - // Do NOT share index instances between two or more MapIndex instances - GenMapIndex& operator()(const std::shared_ptr&... indices); - GenMapIndex& operator()(const std::tuple...>& indices); - - // ==== >>>>> STATIC POLYMORPHISM <<<<< ==== - - IndexType type() const; - - GenMapIndex& operator=(size_t pos); - - GenMapIndex& operator++(); - GenMapIndex& operator--(); - - int pp(std::intptr_t idxPtrNum); - int mm(std::intptr_t idxPtrNum); - - std::string stringMeta() const; - MetaType meta() const; - GenMapIndex& at(const MetaType& metaPos); - size_t posAt(const MetaType& metaPos) const; - - size_t dim() const; - bool first() const; - bool last() const; - std::shared_ptr range() const; - - template - auto getPtr() -> decltype( std::get( mIPack ) )&; - - size_t getStepSize(size_t n) const; - - template - auto ifor(size_t step, Exprs exs) const; // first step arg not used! - - template - auto pifor(size_t step, Exprs exs) const; // NO MULTITHREADING - - template - auto iforh(size_t step, Exprs exs) const; - - }; - - - /************************* - * MapRangeFactory * - *************************/ - - // NOT THREAD SAVE - template - class GenMapRangeFactory : public RangeFactoryBase - { - public: - //typedef SingleRange ORType; - typedef GenMapRange oType; - - GenMapRangeFactory() = delete; - - template - GenMapRangeFactory(const std::shared_ptr& outr, const std::tuple& mapf, - const std::shared_ptr&... rs); - - template - GenMapRangeFactory(const std::shared_ptr& outr, const std::tuple& mapf, - const typename GenMapRange::Space& st); - - template - GenMapRangeFactory(const std::tuple& mapf, const std::shared_ptr&... rs); - - template - GenMapRangeFactory(const std::tuple& mapf, - const typename GenMapRange::Space& space); - - virtual std::shared_ptr create() override; - - private: - - std::shared_ptr checkIfCreated(const std::tuple...>& ptp); - - }; - - /****************** - * MapRange * - ******************/ - - template - class GenMapRange : public RangeInterface > - { - public: - typedef RangeBase RB; - typedef std::tuple...> Space; - typedef GenMapIndex IndexType; - typedef typename Op::value_type MetaType; - - protected: - GenMapRange() = delete; - GenMapRange(const GenMapRange& in) = delete; - GenMapRange& operator=(const GenMapRange& in) = delete; - - template - GenMapRange(const std::shared_ptr& outr, const std::tuple& mapf, - const std::shared_ptr&... rs); - - template - GenMapRange(const std::shared_ptr& outr, const std::tuple& mapf, - const Space& space); - - template - GenMapRange(const std::tuple& mapf, const Space& space); - - template - GenMapRange(const std::tuple& mapf, const std::shared_ptr&... rs); - - Space mSpace; - Op mMapf; - //Op mMapf; - std::shared_ptr mOutRange; - Array mMapMult; - vector mMapPos; - - private: - template - void mkOutRange(const MA& mapf); - - public: - - static constexpr size_t sdim = sizeof...(Ranges); - - template - auto get() const -> decltype( *std::get( mSpace ) )&; - - template - auto getPtr() const -> decltype( std::get( mSpace ) )&; - - std::shared_ptr outRange() const; - const Op& map() const; - - virtual size_t dim() const final; - virtual size_t size() const final; - - virtual SpaceType spaceType() const final; - virtual DataHeader dataHeader() const final; - - virtual vector typeNum() const final; - virtual size_t cmeta(char* target, size_t pos) const final; - virtual size_t cmetaSize() const final; - virtual std::string stringMeta(size_t pos) const final; - virtual vector data() const final; - - const Space& space() const; - - virtual IndexType begin() const final; - virtual IndexType end() const final; - - const Array& mapMultiplicity() const; - ConstSlice explMapMultiplicity() const; - - vector mapPos() const; - - /* - template - auto cat(const std::shared_ptr >& erange) - -> std::shared_ptr >; - */ - friend GenMapRangeFactory; - - static constexpr bool HASMETACONT = false; - static constexpr bool defaultable = false; - static constexpr size_t ISSTATIC = Op::ISSTATIC & (... & Ranges::ISSTATIC); - static constexpr size_t SIZE = Op::SIZE * (... * Ranges::SIZE); - }; - - // for legacy - template - using MapIndex = GenMapIndex; - - template - using MapRangeFactory = GenMapRangeFactory; - - template - using MapRange = GenMapRange; - - template - auto mapResult/* >*/(const std::shared_ptr >& ind) - -> decltype(ind->outIndex()) - { - return ind->outIndex(); - } -} - - -#endif diff --git a/orig/include/map_range_factory_product_map.h b/orig/include/map_range_factory_product_map.h deleted file mode 100644 index 8406e07..0000000 --- a/orig/include/map_range_factory_product_map.h +++ /dev/null @@ -1,26 +0,0 @@ - -#ifndef __cxz_map_range_factory_product_map_h__ -#define __cxz_map_range_factory_product_map_h__ - -#include -#include -#include -#include "ranges/rbase_def.h" -#include "mbase_def.h" - -namespace CNORXZ -{ - class MapRangeFactoryProductMap - { - public: - - template - friend class GenMapRangeFactory; - - private: - static std::map,vector > mAleadyCreated; - }; - -} - -#endif diff --git a/orig/include/mbase_def.h b/orig/include/mbase_def.h deleted file mode 100644 index 16b07cd..0000000 --- a/orig/include/mbase_def.h +++ /dev/null @@ -1,104 +0,0 @@ - -#ifndef __cxz_mbase_def_h__ -#define __cxz_mbase_def_h__ - -#include "ranges/rbase_def.h" -#include "allocator.h" - -namespace CNORXZ -{ - /*********************** - * Provided Types * - ***********************/ - - template - using ContainerRangeFactory = MultiRangeFactory; - - template - using ContainerRange = MultiRange; - - // container_index.h - template - class ConstContainerIndex; - - // cxz_array.h - template - class ArrayBase; - - // cxz_array.h - template - class MutableArrayBase; - - // cxz_array.h - template - class Array; - - // cxz_operation.h - template - class OperationBase; - - // cxz_operation.h - template - class OperationTemplate; - - // cxz_operation.h - template - class OperationRoot; - - // cxz_operation.h - template - class ParallelOperationRoot; - - // cxz_operation.h - template - class OperationValue; - - // cxz_operation.h - template - class ConstOperationRoot; - - // cxz_operation.h - template - class OperationPointer; - - // cxz_operation.h - template - class Operation; - - // cxz_operation.h - template - class Contraction; - - // cxz_operation.h - template - class SliceContraction; - - // slice.h - template - class Slice; - - template - class ConstSlice; - - // slice.h - template - class SliceDef; - - // slice.h - template - class ConstSliceDef; - - // map_range.h - template - class GenMapIndex; - - // map_range.h - template - class GenMapRangeFactory; - - // map_range.h - template - class GenMapRange; -} - -#endif diff --git a/orig/include/ranges/anonymous_range.h b/orig/include/ranges/anonymous_range.h deleted file mode 100644 index 643a159..0000000 --- a/orig/include/ranges/anonymous_range.h +++ /dev/null @@ -1,261 +0,0 @@ -// -*- C++ -*- - -#ifndef __cxz_anonymous_range_h__ -#define __cxz_anonymous_range_h__ - -#include -#include -#include "rbase_def.h" -#include "ranges/range_base.h" -#include "ranges/rpheader.h" -#include "ranges/x_to_string.h" -#include "ranges/type_map.h" - -namespace CNORXZ -{ - - typedef GenSingleIndex AnonymousIndex; - - //template - //using SIZET = size_t; - - typedef GenSingleRange AnonymousRange; - - // NOT THREAD SAVE!! - class AnonymousRangeFactory : public RangeFactoryBase - { - public: - - typedef AnonymousRange oType; - - AnonymousRangeFactory(); - - template - AnonymousRangeFactory(const std::tuple...>& origs); - - template - AnonymousRangeFactory(std::shared_ptr... origs); - - AnonymousRangeFactory(const vector>& origs); - - template - void append(std::shared_ptr r); - - std::shared_ptr create(); - - private: - - std::shared_ptr checkIfCreated(const vector >& pvec); - - static std::map,vector > mAleadyCreated; - - bool mProductCreated = false; - }; - - template <> - class GenSingleRange : public RangeInterface - { - public: - - static constexpr bool defaultable = true; - static constexpr size_t ISSTATIC = 0; - static constexpr size_t SIZE = MUI; - static constexpr bool HASMETACONT = false; - - typedef RangeBase RB; - typedef typename RangeInterface::IndexType IndexType; - typedef GenSingleRange RangeType; - typedef size_t MetaType; - typedef AnonymousRangeFactory FType; - - virtual size_t size() const final; - virtual size_t dim() const final; - - size_t anonymousDim() const; - size_t get(size_t pos) const; - size_t getMeta(size_t metaPos) const; - - virtual IndexType begin() const final; - virtual IndexType end() const final; - - virtual SpaceType spaceType() const final; - virtual DataHeader dataHeader() const final; - - virtual vector typeNum() const final; - virtual size_t cmeta(char* target, size_t pos) const final; - virtual size_t cmetaSize() const final; - virtual std::string stringMeta(size_t pos) const final; - virtual vector data() const final; - - std::shared_ptr sub(size_t num) const; - - template - std::shared_ptr fullsub(size_t num) const; - - template - std::shared_ptr > scast(SIZET... sizes) const; // save cast - - const vector >& orig() const; - - std::shared_ptr sreplace(const std::shared_ptr in, size_t num) const; - std::shared_ptr sreplace(const vector>& in, size_t num) const; - std::shared_ptr sreplace(const std::shared_ptr& in, - const vector& num) const; - - bool isEmpty() const; - - friend AnonymousRangeFactory; - - static AnonymousRangeFactory factory() - { return AnonymousRangeFactory(); } - - protected: - - GenSingleRange() = default; - GenSingleRange(const AnonymousRange& in) = default; - - template - GenSingleRange(const std::tuple...>& origs); - - template - GenSingleRange(std::shared_ptr... origs); - - GenSingleRange(const vector>& origs); - - size_t mSize = 1; - bool mEmpty = true; - - vector > mOrig; - }; -} - -/* ========================= * - * --- TEMPLATE CODE --- * - * ========================= */ - -namespace CNORXZ -{ - - /*********************** - * AnonymousRange * - ***********************/ - - template - AnonymousRangeFactory::AnonymousRangeFactory(const std::tuple...>& origs) - { - mProd = std::shared_ptr( new AnonymousRange( origs ) ); - } - - template - AnonymousRangeFactory::AnonymousRangeFactory(std::shared_ptr... origs) - { - mProd = std::shared_ptr( new AnonymousRange( origs... ) ); - } - - template - void AnonymousRangeFactory::append(std::shared_ptr r) - { - if(mProductCreated){ - - mProd = std::shared_ptr( new AnonymousRange( *std::dynamic_pointer_cast(mProd) ) ); - mProductCreated = false; - } - std::dynamic_pointer_cast(mProd)->mOrig.push_back(r); - std::dynamic_pointer_cast(mProd)->mSize *= r->size(); - std::dynamic_pointer_cast(mProd)->mEmpty = false; - } - - /***************** - * Functions * - *****************/ - - std::shared_ptr defaultRange(size_t size = 0); -} -namespace CNORXZ -{ - namespace RangeHelper - { - template <> - inline void resolveSetRange(std::shared_ptr& rp, - const vector >& orig, - size_t origpos, size_t size) - { - AnonymousRangeFactory arf; - for(size_t op = origpos; op != origpos + size; ++op){ - //VCHECK(op); - arf.append(orig[op]); - } - rp = std::dynamic_pointer_cast( arf.create() ); - } - - - template <> - inline void setRangeToVec(vector >& v, - std::shared_ptr r) - { - if(not r->isEmpty()){ - for(size_t i = r->anonymousDim(); i != 0; --i){ - v.insert(v.begin(), r->sub(i-1)); - } - } - } - } -} - -namespace CNORXZ -{ - /*********************** - * AnonymousRange * - ***********************/ - - template - GenSingleRange::GenSingleRange(const std::tuple...>& origs) : - RangeInterface() - { - mOrig.resize(sizeof...(RangeTypes)); - sfor_pn<0,sizeof...(RangeTypes)> - ( [&](auto i) { mOrig[i] = std::get(origs); return 0; } ); - mSize = sfor_p<0,sizeof...(RangeTypes)> - ( [&](auto i) { return std::get(origs)->size(); }, - [&](auto a, auto b) { return a * b; } ); - if(sizeof...(RangeTypes)){ - mEmpty = false; - } - } - - template - GenSingleRange::GenSingleRange(std::shared_ptr... origs) : - RangeInterface() - { - auto rst = std::make_tuple(origs...); - mOrig.resize(sizeof...(RangeTypes)); - sfor_pn<0,sizeof...(RangeTypes)> - ( [&](auto i) { mOrig[i] = std::get(rst); return 0; } ); - mSize = sfor_p<0,sizeof...(RangeTypes)> - ( [&](auto i) { return std::get(rst)->size(); }, - [&](auto a, auto b) { return a * b; } ); - if(sizeof...(RangeTypes)){ - mEmpty = false; - } - } - - template - std::shared_ptr GenSingleRange::fullsub(size_t num) const - { - return std::dynamic_pointer_cast( mOrig.at(num) ); - } - - template - std::shared_ptr > GenSingleRange::scast(SIZET... sizes) const - { - std::tuple...> rtp; - RangeHelper::resolveRangeType<0>(mOrig, rtp, 0, sizes...); - MultiRangeFactory mrf(rtp); - return std::dynamic_pointer_cast >( mrf.create() ); - } - - - -} - -#endif diff --git a/orig/include/ranges/dynamic_range.cc.h b/orig/include/ranges/dynamic_range.cc.h deleted file mode 100644 index 77bc659..0000000 --- a/orig/include/ranges/dynamic_range.cc.h +++ /dev/null @@ -1,238 +0,0 @@ - -#include "ranges/dynamic_range.h" - -namespace CNORXZ -{ - namespace - { - using namespace CNORXZInternal; - } - - - /**************************** - * DynamicRangeFactory * - ****************************/ - - - template - DynamicRangeFactory::DynamicRangeFactory(const std::tuple...>& origs) - { - mProd = std::shared_ptr( new DynamicRange( origs ) ); - } - - - template - DynamicRangeFactory::DynamicRangeFactory(std::shared_ptr... origs) - { - mProd = std::shared_ptr( new DynamicRange( origs... ) ); - } - - - - template - void DynamicRangeFactory::append(std::shared_ptr r) - { - if(mProductCreated){ - - mProd = std::shared_ptr( new DynamicRange( *std::dynamic_pointer_cast(mProd) ) ); - mProductCreated = false; - } - std::dynamic_pointer_cast(mProd)->mOrig.push_back(r); - std::dynamic_pointer_cast(mProd)->mSize *= r->size(); - std::dynamic_pointer_cast(mProd)->mEmpty = false; - } - - - /********************* - * DynamicIndex * - *********************/ - - - - template - DynamicIndex& DynamicIndex::operator()(const std::shared_ptr&... is) - { - mIvecInit = true; - vector> tmp = - { std::make_shared>(is)... }; - - assert(mIVec.size() == tmp.size()); - for(size_t i = 0; i != mIVec.size(); ++i){ - mIVec[i].first = tmp[i]; - } - sync(); - return *this; - } - - - template - void DynamicIndex::getPtr() {} - - - struct ForMaker - { - template - static inline auto mk(size_t i, size_t step, DynamicExpression ex, - const IVecT& ivec, bool hidden = false) - -> DynamicExpression - { - if(i == 0) { - auto& ii = *ivec[0].first; - return hidden ? ii.iforh(step*ivec[i].second, ex) : - ii.ifor(step*ivec[i].second, ex); - } - else { - auto& ii = *ivec[i].first; - return mk(i-1, step, - (hidden ? ii.iforh(step*ivec[i].second, ex) : - ii.ifor(step*ivec[i].second, ex)), - ivec, hidden); - - } - } - }; - - - template - DynamicExpression DynamicIndex::ifor(size_t step, Expr ex) const - { - if(mIVec.size() == 0){ - return ex; - } - else if(mIVec.size() == 1){ - return mIVec.back().first->ifor(step,ex); - } - else { - return ForMaker::mk(mIVec.size()-2, step, - mIVec.back().first->ifor(step,ex),mIVec); - } - } - - - template - DynamicExpression DynamicIndex::iforh(size_t step, Expr ex) const - { - if(mIVec.size() == 0){ - return ex; - } - else if(mIVec.size() == 1){ - return mIVec.back().first->iforh(step,ex); - } - else { - return ForMaker::mk(mIVec.size()-2, step, - mIVec.back().first->iforh(step,ex), - mIVec, true); - } - } - - - template - DynamicExpression DynamicIndex::pifor(size_t step, Expr ex) const - { - return ifor(step, ex); // no multithreading here at the moment... - } - - /*********************** - * DynamicRange * - ***********************/ - - template - DynamicRange::DynamicRange(const std::tuple...>& origs) : - RangeInterface() - { - mOrig.resize(sizeof...(RangeTypes)); - sfor_pn<0,sizeof...(RangeTypes)> - ( [&](auto i) { mOrig[i] = std::get(origs); return 0; } ); - mSize = sfor_p<0,sizeof...(RangeTypes)> - ( [&](auto i) { return std::get(origs)->size(); }, - [&](auto a, auto b) { return a * b; } ); - if(sizeof...(RangeTypes)){ - mEmpty = false; - } - } - - - template - DynamicRange::DynamicRange(std::shared_ptr... origs) : - RangeInterface() - { - auto rst = std::make_tuple(origs...); - mOrig.resize(sizeof...(RangeTypes)); - sfor_pn<0,sizeof...(RangeTypes)> - ( [&](auto i) { mOrig[i] = std::get(rst); return 0; } ); - mSize = sfor_p<0,sizeof...(RangeTypes)> - ( [&](auto i) { return std::get(rst)->size(); }, - [&](auto a, auto b) { return a * b; } ); - if(sizeof...(RangeTypes)){ - mEmpty = false; - } - } - - - template - std::shared_ptr DynamicRange::fullsub(size_t num) const - { - return std::dynamic_pointer_cast( mOrig.at(num) ); - } - - - template - std::shared_ptr > DynamicRange::scast(SIZET... sizes) const - { - std::tuple...> rtp; - RangeHelper::resolveRangeType<0>(mOrig, rtp, 0, sizes...); - MultiRangeFactory mrf(rtp); - return std::dynamic_pointer_cast >( mrf.create() ); - } - - -} // end namespace CNORXZ - -namespace CNORXZ -{ - namespace RangeHelper - { - template <> - inline void resolveSetRange(std::shared_ptr& rp, - const vector >& orig, - size_t origpos, size_t size) - { - DynamicRangeFactory arf; - for(size_t op = origpos; op != origpos + size; ++op){ - //VCHECK(op); - arf.append(orig[op]); - } - rp = std::dynamic_pointer_cast( arf.create() ); - } - - - template <> - inline void setRangeToVec(vector >& v, - std::shared_ptr r) - { - if(not r->isEmpty()){ - for(size_t i = r->dim(); i != 0; --i){ - v.insert(v.begin(), r->sub(i-1)); - } - } - } - - template <> - inline size_t getStepSize(const DynamicIndex& ii, std::intptr_t j) - { - size_t ss = 0; - size_t sx = 1; - for(size_t k = ii.dim(); k != 0; --k){ - const size_t i = k-1; - const auto& ni = ii.get(i); - const size_t max = ni.max(); - const size_t tmp = ni.getStepSizeComp(j); - ss += tmp * ii.getStepSize(i); - sx *= max; - } - return ss; - - } - } -} - diff --git a/orig/include/ranges/dynamic_range.h b/orig/include/ranges/dynamic_range.h deleted file mode 100644 index e69f487..0000000 --- a/orig/include/ranges/dynamic_range.h +++ /dev/null @@ -1,250 +0,0 @@ - -#ifndef __cxz_dynamic_range_h__ -#define __cxz_dynamic_range_h__ - -#include -#include - -#include "ranges/rbase_def.h" -#include "ranges/range_base.h" -#include "ranges/index_base.h" - -#include "xfor/xfor.h" - -#include "ranges/x_to_string.h" -#include "ranges/type_map.h" -#include "ranges/dynamic_meta.h" - -#include "index_wrapper.h" - -namespace CNORXZ -{ - namespace - { - using namespace CNORXZInternal; - } - - class DynamicIndex : public IndexInterface> - { - private: - typedef vector,size_t>> IVecT; - typedef std::map> IMapT; - - static IMapT sIMap; - - IVecT mIVec; - bool mIvecInit = false; - - public: - typedef IndexInterface> IB; - typedef vector MetaType; - typedef DynamicRange RangeType; - typedef DynamicIndex IType; - - DynamicIndex(const std::shared_ptr& range); - - static void clearIMap() { sIMap.clear(); } - - template - static std::shared_ptr getIndexFromMap(const std::string& name) - { - auto tmp = std::dynamic_pointer_cast>(sIMap.at(name)); - assert(tmp); - return tmp->getIndex(); - } - - static const std::shared_ptr& getIndexWFromMap(const std::string& name) - { - return sIMap.at(name); - } - - static bool checkIndexMap(const std::string& name) - { - return sIMap.count(name) != 0; - } - - static constexpr IndexType sType() { return IndexType::SINGLE; } - static constexpr size_t totalDim() { return 1; } - static constexpr size_t sDim() { return 1; } - - static constexpr SpaceType STYPE = SpaceType::DYN; - - IndexType type() const; - - DynamicIndex& operator=(size_t pos); - DynamicIndex& operator++(); - DynamicIndex& operator--(); - - DynamicIndex& operator()(const IVecT& ivec); - DynamicIndex& operator()(const vector>& ivec); - DynamicIndex& operator()(const vector& inames); - - template - DynamicIndex& operator()(const std::shared_ptr&... is); - - DynamicIndex& sync(); - - int pp(std::intptr_t idxPtrNum); - int mm(std::intptr_t idxPtrNum); - - std::string stringMeta() const; - MetaType meta() const; - const MetaType* metaPtr() const; - DynamicIndex& at(const MetaType& metaPos); - size_t posAt(const MetaType& metaPos) const; - - //bool isMeta(const MetaType& metaPos) const; - - size_t dim() const; - bool last() const; - bool first() const; - - const IndexW& get(size_t n) const; - const std::shared_ptr& getP(size_t n) const; - - std::shared_ptr range(); - - template - void getPtr(); - - size_t getStepSize(size_t n) const; - - template - DynamicExpression ifor(size_t step, Expr ex) const; - - template - DynamicExpression iforh(size_t step, Expr ex) const; - - template - DynamicExpression pifor(size_t step, Expr ex) const; - - }; - - - // NOT THREAD SAVE!! - class DynamicRangeFactory : public RangeFactoryBase - { - public: - - typedef DynamicRange oType; - - DynamicRangeFactory(); - - template - DynamicRangeFactory(const std::tuple...>& origs); - - template - DynamicRangeFactory(std::shared_ptr... origs); - - DynamicRangeFactory(const vector>& origs); - - template - void append(std::shared_ptr r); - - std::shared_ptr create(); - - private: - - std::shared_ptr checkIfCreated(const vector >& pvec); - - static std::map,vector > mAleadyCreated; - - bool mProductCreated = false; - }; - - class DynamicRange : public RangeInterface - { - public: - static constexpr bool defaultable = true; - static constexpr size_t ISSTATIC = 0; - static constexpr size_t SIZE = -1; - static constexpr bool HASMETACONT = false; - - typedef RangeBase RB; - typedef DynamicIndex IndexType; - typedef DynamicRange RangeType; - typedef vector MetaType; - typedef DynamicRangeFactory FType; - - private: - DynamicRange() = default; - DynamicRange(const DynamicRange& in) = default; - - template - DynamicRange(const std::tuple...>& origs); - - template - DynamicRange(std::shared_ptr... origs); - - DynamicRange(const vector>& origs); - - size_t mSize = 1; - bool mEmpty = true; - - vector > mOrig; - - public: - virtual size_t size() const final; - virtual size_t dim() const final; - - MetaType get(size_t pos) const; - size_t getMeta(const MetaType& metaPos) const; - - virtual IndexType begin() const final; - virtual IndexType end() const final; - - virtual SpaceType spaceType() const final; - virtual DataHeader dataHeader() const final; - - virtual vector typeNum() const final; - virtual size_t cmeta(char* target, size_t pos) const final; - virtual size_t cmetaSize() const final; - virtual std::string stringMeta(size_t pos) const final; - virtual vector data() const final; - - std::shared_ptr sub(size_t num) const; - - template - std::shared_ptr fullsub(size_t num) const; - - template - std::shared_ptr > scast(SIZET... sizes) const; // save cast - - const vector >& orig() const; - - void sreplace(const std::shared_ptr in, size_t num); - - bool isEmpty() const; - - friend DynamicRangeFactory; - - static DynamicRangeFactory factory() - { return DynamicRangeFactory(); } - - }; - -} // namespace CNORXZ - - -namespace CNORXZ -{ - namespace RangeHelper - { - - template <> - inline void resolveSetRange(std::shared_ptr& rp, - const vector >& orig, - size_t origpos, size_t size); - - template <> - inline void setRangeToVec(vector >& v, - std::shared_ptr r); - - template <> - inline size_t getStepSize(const DynamicIndex& ii, std::intptr_t j); - } -} - -//#include "dynamic_range.cc.h" - -#endif diff --git a/orig/include/ranges/index_type.h b/orig/include/ranges/index_type.h deleted file mode 100644 index c57938f..0000000 --- a/orig/include/ranges/index_type.h +++ /dev/null @@ -1,14 +0,0 @@ - -#ifndef __cxz_index_type_h__ -#define __cxz_index_type_h__ - -namespace CNORXZ -{ - enum class IndexType{ - SINGLE = 0, - MULTI = 1, - CONT = 2 - }; -} - -#endif diff --git a/orig/include/ranges/index_wrapper.cc.h b/orig/include/ranges/index_wrapper.cc.h deleted file mode 100644 index 20d180d..0000000 --- a/orig/include/ranges/index_wrapper.cc.h +++ /dev/null @@ -1,176 +0,0 @@ - -#include "index_wrapper.h" -#include "range_helper.h" - -namespace CNORXZ -{ - - template - IndexWrapper::IndexWrapper(const std::shared_ptr& i) : mI(i) - { - ClassicRF crf(mI->max()); - mCI = std::make_shared - ( std::dynamic_pointer_cast( crf.create() ) ); - (*mCI) = mI->pos(); - } - - template - IndexType IndexWrapper::type() const - { - return mI->type(); - } - - template - IndexWrapper& IndexWrapper::operator=(size_t pos) - { - (*mI) = pos; - return *this; - } - - template - IndexWrapper& IndexWrapper::operator++() - { - ++(*mI); - return *this; - } - - template - IndexWrapper& IndexWrapper::operator--() - { - --(*mI); - return *this; - } - - template - size_t IndexWrapper::pos() const - { - return mI->pos(); - } - - template - size_t IndexWrapper::max() const - { - return mI->max(); - } - - template - int IndexWrapper::pp(std::intptr_t idxPtrNum) - { - return mI->pp(idxPtrNum); - } - - template - int IndexWrapper::mm(std::intptr_t idxPtrNum) - { - return mI->mm(idxPtrNum); - } - - template - std::string IndexWrapper::stringMeta() const - { - return mI->stringMeta(); - } - - template - IndexWrapper& IndexWrapper::at(const typename Index::MetaType& metaPos) - { - mI->at(metaPos); - return *this; - } - - template - size_t IndexWrapper::posAt(const typename Index::MetaType& metaPos) - { - return mI->posAt(metaPos); - } - - template - size_t IndexWrapper::dim() const - { - return mI->dim(); - } - - template - bool IndexWrapper::last() const - { - return mI->last(); - } - - template - bool IndexWrapper::first() const - { - return mI->first(); - } - - template - std::shared_ptr IndexWrapper::range() const - { - return mI->range(); - } - - template - size_t IndexWrapper::getStepSize(size_t n) const - { - return mI->getStepSize(n); - } - - template - size_t IndexWrapper::getStepSizeComp(std::intptr_t j) const - { - size_t out = RangeHelper::getStepSize(*mI, j); - if(out == 0){ - out = RangeHelper::getStepSize(*mCI, j); - } - return out; - } - - template - std::intptr_t IndexWrapper::get() const - { - return reinterpret_cast(mI.get()); - } - - template - std::intptr_t IndexWrapper::ptrNum() const - { - return mI->ptrNum(); - } - - template - DynamicExpression IndexWrapper::ifor(size_t step, DynamicExpression ex) const - { - return mI->ifor(step, ex); - } - - template - DynamicExpression IndexWrapper::iforh(size_t step, DynamicExpression ex) const - { - return mI->iforh(step, ex); - } - - template - std::shared_ptr IndexWrapper::duplicate() const - { - return std::make_shared( std::make_shared( *mI ) ); - } - - template - std::shared_ptr IndexWrapper::getIndex() const - { - return mI; - } - - template - std::shared_ptr IndexWrapper::reduced() const - { - (*mCI) = mI->pos(); - return mCI; - } - - template - inline std::shared_ptr mkIndexWrapper(const Index& i) - { - return std::make_shared>(std::make_shared(i)); - } - -} diff --git a/orig/include/ranges/index_wrapper.h b/orig/include/ranges/index_wrapper.h deleted file mode 100644 index 28efcf6..0000000 --- a/orig/include/ranges/index_wrapper.h +++ /dev/null @@ -1,157 +0,0 @@ - -#ifndef __cxz_index_wrapper_h__ -#define __cxz_index_wrapper_h__ - -#include "ranges/rbase_def.h" -#include "xfor/xfor.h" -#include "ranges/rheader.h" - -namespace CNORXZ -{ - namespace - { - using namespace CNORXZInternal; - } - - class IndexWrapperBase - { - public: - - IndexWrapperBase() = default; - IndexWrapperBase(const IndexWrapperBase& in) = default; - IndexWrapperBase(IndexWrapperBase&& in) = default; - IndexWrapperBase& operator=(const IndexWrapperBase& in) = default; - IndexWrapperBase& operator=(IndexWrapperBase&& in) = default; - - virtual IndexType type() const = 0; - - virtual IndexWrapperBase& operator=(size_t pos) = 0; - virtual IndexWrapperBase& operator++() = 0; - virtual IndexWrapperBase& operator--() = 0; - - virtual int pp(std::intptr_t idxPtrNum) = 0; - virtual int mm(std::intptr_t idxPtrNum) = 0; - - virtual std::string stringMeta() const = 0; - - virtual size_t pos() const = 0; - virtual size_t max() const = 0; - virtual size_t dim() const = 0; - virtual bool last() const = 0; - virtual bool first() const = 0; - - virtual std::shared_ptr range() const = 0; - - virtual size_t getStepSize(size_t n) const = 0; - virtual size_t getStepSizeComp(std::intptr_t j) const = 0; - - virtual std::intptr_t get() const = 0; - virtual std::intptr_t ptrNum() const = 0; - - virtual std::shared_ptr duplicate() const = 0; - - inline IndexWrapperBase& at(const std::string smeta) - { - // ignore spaces, " and ' (string identifiers) - auto rem = [](unsigned char x) - { - bool out = false; - if(x == ' ' or x == '"' or x == '\'') out = true; - return out; - }; - std::string redmeta = smeta; - redmeta.erase(std::remove_if(redmeta.begin(), redmeta.end(), rem), redmeta.end()); - for((*this) = 0; this->pos() != this->max(); ++(*this)){ - std::string red = this->stringMeta(); - red.erase(std::remove_if(red.begin(), red.end(), rem), red.end()); - if(red == redmeta){ - break; - } - } - return *this; - } - - virtual DynamicExpression ifor(size_t step, DynamicExpression ex) const = 0; - virtual DynamicExpression iforh(size_t step, DynamicExpression ex) const = 0; - /* - std::shared_ptr duplicateI() const - { return std::dynamic_pointer_cast( this->duplicate() ); } - */ - - virtual std::shared_ptr reduced() const = 0; - }; - - typedef IndexWrapperBase IndexW; - - template - class IndexWrapper : public IndexWrapperBase - { - public: - typedef IndexWrapperBase IWB; - typedef typename Index::MetaType MetaType; - - static constexpr IndexType sType() { return IndexType::SINGLE; } - - protected: - IndexWrapper() = default; - - private: - std::shared_ptr mI; - std::shared_ptr mCI; // reduced; - public: - - IndexWrapper(const IndexWrapper& in) = default; - IndexWrapper(IndexWrapper&& in) = default; - IndexWrapper& operator=(const IndexWrapper& in) = default; - IndexWrapper& operator=(IndexWrapper&& in) = default; - - IndexWrapper(const std::shared_ptr& i); - - virtual IndexType type() const final; - - virtual IndexWrapper& operator=(size_t pos) override final; - virtual IndexWrapper& operator++() override final; - virtual IndexWrapper& operator--() override final; - - virtual size_t pos() const override final; - virtual size_t max() const override final; - - virtual int pp(std::intptr_t idxPtrNum) override final; - virtual int mm(std::intptr_t idxPtrNum) override final; - - virtual std::string stringMeta() const override final; - //virtual DynamicMetaT meta() const final { return DynamicMetaT(mI->meta()); } - //virtual const DynamicMetaT* metaPtr() const final { return nullptr; } - IndexWrapper& at(const typename Index::MetaType& metaPos); - size_t posAt(const typename Index::MetaType& metaPos); - - //virtual bool isMeta(const U& metaPos) const final { return mI->isMeta(); } - - virtual size_t dim() const override final; - virtual bool last() const override final; - virtual bool first() const override final; - - virtual std::shared_ptr range() const override final; - - virtual size_t getStepSize(size_t n) const override final; - virtual size_t getStepSizeComp(std::intptr_t j) const override final; - - virtual std::intptr_t get() const override final; - virtual std::intptr_t ptrNum() const override final; - - virtual DynamicExpression ifor(size_t step, DynamicExpression ex) const override final; - virtual DynamicExpression iforh(size_t step, DynamicExpression ex) const override final; - - virtual std::shared_ptr duplicate() const override final; - - std::shared_ptr getIndex() const; - virtual std::shared_ptr reduced() const override final; - - }; - /* - template - std::shared_ptr mkIndexWrapper(const Index& i); - */ -} - -#endif diff --git a/orig/include/ranges/multi_range_factory_product_map.h b/orig/include/ranges/multi_range_factory_product_map.h deleted file mode 100644 index adba8ce..0000000 --- a/orig/include/ranges/multi_range_factory_product_map.h +++ /dev/null @@ -1,25 +0,0 @@ - -#ifndef __cxz_multi_range_factory_product_map_h__ -#define __cxz_multi_range_factory_product_map_h__ - -#include -#include -#include -#include "ranges/rbase_def.h" - -namespace CNORXZ -{ - class MultiRangeFactoryProductMap - { - public: - - template - friend class MultiRangeFactory; - - private: - static std::map,vector > mAleadyCreated; - }; - -} - -#endif diff --git a/orig/include/ranges/multi_range_register.h b/orig/include/ranges/multi_range_register.h deleted file mode 100644 index 4b888db..0000000 --- a/orig/include/ranges/multi_range_register.h +++ /dev/null @@ -1,9 +0,0 @@ - -#ifdef register_multi3 - -typedef SingleRange SCRange; - -register_multi3(PSpaceRange,PSpaceRange,PSpaceRange) -register_multi3(SCRange,SCRange,SCRange) - -#endif diff --git a/orig/include/ranges/range_types/header.h b/orig/include/ranges/range_types/header.h deleted file mode 100644 index 2026d20..0000000 --- a/orig/include/ranges/range_types/header.h +++ /dev/null @@ -1,27 +0,0 @@ - -#ifdef include_range_type -#define __cxz_incl_this__ -#endif -#ifdef __cxz_single_range_h__ -// singel_range is template which is specialized here -// therefore it must be defined before... -#define __cxz_incl_this__ -#endif - -#ifdef __cxz_incl_this__ - - -#define __cxz_ranges_header__ -//#ifndef __cxz_ranges_header__ -//#define __cxz_ranges_header__ - -#include "null_range.h" -#include "spin_range.h" -#include "space_range.h" -#include "classic_range.h" - -#undef __ranges_header__ - -#endif - -#undef __incl_this__ diff --git a/orig/include/ranges/range_types/space_range.h b/orig/include/ranges/range_types/space_range.h deleted file mode 100644 index 3c3c6a5..0000000 --- a/orig/include/ranges/range_types/space_range.h +++ /dev/null @@ -1,135 +0,0 @@ - -#ifdef include_range_type -include_range_type(PSPACE,3) // Periodic 1dim space -#else - -#ifdef __cxz_ranges_header__ - -#ifndef __cxz_range_type_space_def__ -#define __cxz_range_type_space_def__ - -namespace CNORXZ -{ - // Periodic 1dim space - typedef GenSingleIndex XSpaceIndex; - - template <> - class GenSingleRangeFactory : public RangeFactoryBase - { - public: - - typedef GenSingleRange oType; - - GenSingleRangeFactory(size_t size = 0); - std::shared_ptr create(); - - }; - - template <> - class GenSingleRange : public RangeInterface - { - public: - typedef RangeBase RB; - typedef typename RangeInterface >::IndexType IndexType; - typedef GenSingleRange RangeType; - typedef int MetaType; - typedef GenSingleRangeFactory FType; - - virtual size_t size() const final; - virtual size_t dim() const final; - - virtual vector typeNum() const final; - virtual size_t cmeta(char* target, size_t pos) const final; - virtual size_t cmetaSize() const final; - virtual std::string stringMeta(size_t pos) const final; - virtual vector data() const final; - - virtual SpaceType spaceType() const final; - virtual DataHeader dataHeader() const final; - - int get(size_t pos) const; - size_t getMeta(int metaPos) const; - - virtual IndexType begin() const final; - virtual IndexType end() const final; - - friend GenSingleRangeFactory; - - static constexpr bool defaultable = true; - static constexpr size_t ISSTATIC = 0; - static constexpr size_t SIZE = MUI; - static constexpr bool HASMETACONT = false; - - static GenSingleRangeFactory factory(size_t size = 0) - { return GenSingleRangeFactory(size); } - - protected: - - size_t mSize = 0; - - GenSingleRange() = default; - GenSingleRange(const GenSingleRange& in) = delete; - - GenSingleRange(size_t size); - }; - - typedef GenSingleRange PSpaceRange; - typedef GenSingleRangeFactory PSpaceRF; - - std::shared_ptr mkPSPACE(const char* dp, size_t size); - - template - struct PromoteMSpaceRange - { - template - static auto mk(const MultiRange&) - -> MultiRange; - - template - static auto mkf(const MultiRangeFactory&) - -> MultiRangeFactory; - - }; - - template - struct CreateNDimSpaceRange - { - template - static auto mk() - -> decltype(PromoteMSpaceRange:: - template mk(CreateNDimSpaceRange:: - template mk())); - - template - static auto mkf() - -> decltype(PromoteMSpaceRange:: - template mkf(CreateNDimSpaceRange:: - template mkf())); - - }; - - template <> - struct CreateNDimSpaceRange<1> - { - template - static auto mk() - -> MultiRange; - - template - static auto mkf() - -> MultiRangeFactory; - - }; - - template - using MSpaceRange = decltype(CreateNDimSpaceRange::template mk()); - - template - using MSpaceRF = decltype(CreateNDimSpaceRange::template mkf()); -} - -#endif // #ifndef __cxz_range_type_space_def__ - -#endif // #ifdef __cxz_ranges_header__ - -#endif // #ifdef include_range_type diff --git a/orig/include/ranges/range_types/spin_range.h b/orig/include/ranges/range_types/spin_range.h deleted file mode 100644 index c88dcb7..0000000 --- a/orig/include/ranges/range_types/spin_range.h +++ /dev/null @@ -1,89 +0,0 @@ - - -#ifdef include_range_type -include_range_type(SPIN,2) -#else - -#ifdef __cxz_ranges_header__ -// assert, that this is only used within range_types/header.h - -#ifndef __cxz_range_type_spin_def__ -#define __cxz_range_type_spin_def__ - -namespace CNORXZ -{ - typedef GenSingleIndex SpinIndex; - - template <> - class GenSingleRangeFactory : public RangeFactoryBase - { - public: - - typedef GenSingleRange oType; - - GenSingleRangeFactory(); - std::shared_ptr create(); - - }; - - template <> - class GenSingleRange : public RangeInterface - { - public: - typedef RangeBase RB; - typedef typename RangeInterface >::IndexType IndexType; - typedef GenSingleRange RangeType; - typedef size_t MetaType; - typedef GenSingleRangeFactory FType; - - virtual size_t size() const final; - virtual size_t dim() const final; - - virtual vector typeNum() const final; - virtual size_t cmeta(char* target, size_t pos) const final; - virtual size_t cmetaSize() const final; - virtual std::string stringMeta(size_t pos) const final; - virtual vector data() const final; - - virtual SpaceType spaceType() const final; - virtual DataHeader dataHeader() const final; - - size_t get(size_t pos) const; - size_t getMeta(size_t metaPos) const; - - virtual IndexType begin() const final; - virtual IndexType end() const final; - //virtual std::shared_ptr index() const final; - - friend GenSingleRangeFactory; - - static constexpr bool defaultable = true; - static constexpr size_t mSpinNum = 4; - - static constexpr size_t ISSTATIC = 1; - static constexpr size_t SIZE = mSpinNum; - static constexpr bool HASMETACONT = false; - - static GenSingleRangeFactory factory() - { return GenSingleRangeFactory(); } - - protected: - - GenSingleRange() = default; - GenSingleRange(const GenSingleRange& in) = delete; - - //GenSingleRange(size_t spinNum); - }; - - typedef GenSingleRange SpinRange; - typedef GenSingleRangeFactory SpinRF; - - std::shared_ptr mkSPIN(const char* dp, size_t size); -} - - -#endif // #ifndef __cxz_range_type_spin_def__ - -#endif // #ifdef __cxz_ranges_header__ - -#endif // #ifdef include_range_type diff --git a/orig/include/ranges/ranges_header.cc.h b/orig/include/ranges/ranges_header.cc.h deleted file mode 100644 index 7254dce..0000000 --- a/orig/include/ranges/ranges_header.cc.h +++ /dev/null @@ -1,3 +0,0 @@ - -#include "ranges/dynamic_range.cc.h" -#include "ranges/index_wrapper.cc.h" diff --git a/orig/include/ranges/rbase_def.h b/orig/include/ranges/rbase_def.h deleted file mode 100644 index 36a5ff2..0000000 --- a/orig/include/ranges/rbase_def.h +++ /dev/null @@ -1,104 +0,0 @@ -// -*- C++ -*- - -#ifndef __cxz_ranges_base_def_h__ -#define __cxz_ranges_base_def_h__ - -#include "base/base.h" - -#include "allocator.h" -#define MUI static_cast(-1) - -namespace CNORXZ -{ - - template - using SIZET = size_t; - - /*********************** - * Provided Types * - ***********************/ - - // range_base.h - enum class SpaceType; - - // range_base.h - class RangeFactoryBase; - - // range_base.h - class RangeBase; - - // range_base.h - template - class RangeInterface; - - // index_base.h - template - class IndexInterface; - - // single_range.h - template - class GenSingleRange; - - // single_range.h - template - class GenSingleRangeFactory; - - // single_range.h - template - class GenSingleIndex; - - // subrange.h - template - class SubIndex; - - // subrange.h - template - class SubRangeFactory; - - // subrange.h - template - class SubRange; - - // multi_range.h - template - class MultiRangeFactory; - - // multi_range.h - template - class MultiRange; - - // multi_range.h - template - class MultiIndex; - - // anonymous_range.h - class AnonymousRangeFactory; - - // dynamic_range.h - class IndexWrapperBase; - - // dynamic_range.h - template - class IndexWrapper; - - // dynamic_range.h - class DynamicIndex; - - // dynamic_range.h - class DynamicRangeFactory; - - // dynamic_range.h - class DynamicRange; - - // value_range.h - template - class ValueRange; - - template - class ValueRangeFactory; - - template - class ValueIndex; -} - -#endif diff --git a/orig/include/ranges/reg_ind_num.h b/orig/include/ranges/reg_ind_num.h deleted file mode 100644 index 6fc4bd4..0000000 --- a/orig/include/ranges/reg_ind_num.h +++ /dev/null @@ -1,7 +0,0 @@ - -#ifndef __cxz_reg_ind_num_h__ -#define __cxz_reg_ind_num_h__ - - - -#define diff --git a/orig/include/ranges/rheader.h b/orig/include/ranges/rheader.h deleted file mode 100644 index c9ea0c4..0000000 --- a/orig/include/ranges/rheader.h +++ /dev/null @@ -1,10 +0,0 @@ - -//#ifndef __cxz_rheader_h__ -//#define __cxz_rheader_h__ - -#include "dynamic_range.h" -#include "rpheader.h" -#include "anonymous_range.h" -#include "value_range.h" - -//#endif diff --git a/orig/include/ranges/rpheader.h b/orig/include/ranges/rpheader.h deleted file mode 100644 index c6ecd37..0000000 --- a/orig/include/ranges/rpheader.h +++ /dev/null @@ -1,10 +0,0 @@ - -//#ifndef __cxz_rpheader_h__ -//#define __cxz_rpheader_h__ - -#include "single_range.h" -#include "multi_range.h" -#include "subrange.h" -//#include "anonymous_range.h" - -//#endif diff --git a/orig/include/ranges/type_map.h b/orig/include/ranges/type_map.h deleted file mode 100644 index 5e41ad1..0000000 --- a/orig/include/ranges/type_map.h +++ /dev/null @@ -1,231 +0,0 @@ - -#ifndef __cxz_type_map_h__ -#define __cxz_type_map_h__ - -#include -#include -#include -#include -#include - -#include "allocator.h" - -namespace CNORXZ -{ - - template - struct TypeMap - { - typedef void type; - static constexpr size_t size = 0; - }; - - template - struct NumTypeMap - { - static size_t num() { assert(0); return 0; }; - }; - - template - struct TypeHandle - { - static inline void stringCat(vector& out, const vector& in) - { - //for(auto& x: in) { std::cout << x << std::endl; } - const char* scp = reinterpret_cast(in.data()); - out.insert(out.end(), scp, scp + in.size() * sizeof(T)); - } - - static inline size_t metaSize(const vector& in) - { - return in.size() * sizeof(T); - } - - static inline void metaCat(vector& vec, const char* begin, size_t size) - { - const T* tp = reinterpret_cast( begin ); - vec.insert(vec.end(), tp, tp + size / sizeof(T)); - } - }; - - template <> - struct TypeHandle - { - static inline void stringCat(vector& out, const vector& in) - { - //for(auto& x: in) { std::cout << x << std::endl; } - std::string tmp = ""; - for(auto& x: in){ - tmp += x + '\n'; - } - const char* scp = reinterpret_cast(tmp.data()); - out.insert(out.end(), scp, scp + tmp.size()); - } - - static inline size_t metaSize(const vector& in) - { - size_t out = 0; - for(auto& x: in){ - out += x.size() + 1; - } - return out; - } - - static inline void metaCat(vector& vec, const char* begin, size_t size) - { - - std::string tmp(begin, size); - //std::cout << tmp << std::endl; - size_t pos = 0; - while(pos != tmp.size()){ - std::string es = "\n"; - size_t termpos = tmp.find_first_of(es, pos); - std::string tmpstr = tmp.substr(pos, termpos-pos); - vec.push_back(tmpstr); - pos = termpos + 1; - } - } - }; - - template - struct TypeHandle> - { - static inline void stringCat(vector& out, const vector>& in) - { - //for(auto& x: in) { std::cout << x << std::endl; } - for(auto& x: in){ - const size_t size = x.size(); - const char* ss = reinterpret_cast(&size); - const char* scp = reinterpret_cast(x.data()); - out.insert(out.end(), ss, ss + sizeof(size_t)); - out.insert(out.end(), scp, scp + size*sizeof(T)); - } - } - - static inline size_t metaSize(const vector>& in) - { - size_t out = 0; - for(auto& x: in){ - out += x.size()*sizeof(T); - out += sizeof(size_t); - } - return out; - } - - static inline void metaCat(vector>& vec, const char* begin, size_t size) - { - size_t pos = 0; - while(pos < size){ - const size_t xsize = *reinterpret_cast(begin+pos); - pos += sizeof(size_t); - const T* dbegin = reinterpret_cast(begin+pos); - const T* dend = dbegin+xsize; - vec.emplace_back(dbegin,dend); - //vector tmp(begin+pos, begin+npos); - //vec.push_back(tmp); - pos += xsize*sizeof(T); - } - assert(pos == size); - } - }; - - template - inline void stringCat(vector& out, const vector& in) - { - TypeHandle::stringCat(out,in); - } - - template - inline size_t metaSize(const vector& in) - { - return TypeHandle::metaSize(in); - } - - template - inline void metaCat(vector& vec, const char* begin, size_t size) - { - TypeHandle::metaCat(vec,begin,size); - } - - -#define XCOMMAX() , - -#define include_type(t,n) template <> struct TypeMap { typedef t type; static constexpr size_t size = sizeof(t); }; \ - template <> struct NumTypeMap { inline static size_t num(){ return n; } }; - -#include "ranges/type_register.h" - /* - include_type(size_t,1) - include_type(int,2) - include_type(char,3) - include_type(float,4) - include_type(double,5) - include_type(std::string,6) - include_type(vector,101) - include_type(vector,102) - include_type(vector,105) - include_type(vector,106) - include_type(std::array,201) - include_type(std::array,202) - include_type(std::array,205) - include_type(std::array,301) - include_type(std::array,302) - include_type(std::array,305) - include_type(std::array,401) - include_type(std::array,402) - include_type(std::array,405) - include_type(std::array,502) - include_type(std::array,602) - include_type(std::array,702) - include_type(std::array,802) - include_type(std::array,902) - */ -#undef include_type - - inline size_t sizeFromTypeNum(size_t tn) - { - if(tn == 1){ return sizeof(size_t); } - else if(tn == 2){ return sizeof(int); } - else if(tn == 3){ return sizeof(char); } - else if(tn == 4){ return sizeof(float); } - else if(tn == 5){ return sizeof(double); } - else if(tn == 6){ return sizeof(std::string); } - else if(tn > 6 and tn < 100){ assert(0); } - else if(tn >= 100 and tn < 200) { return sizeof(std::vector); } - else { const size_t nx = tn % 100; return sizeFromTypeNum(nx)*(tn-nx)/100; } - } -} - -#endif - -#undef XCOMMAX - - -#define register_all_types \ - register_type(1) \ - register_type(2) \ - register_type(3) \ - register_type(4) \ - register_type(5) \ - register_type(6) \ - register_type(101) \ - register_type(102) \ - register_type(105) \ - register_type(106) \ - register_type(201) \ - register_type(202) \ - register_type(301) \ - register_type(302) \ - register_type(402) \ - register_type(502) \ - register_type(602) \ - register_type(702) \ - register_type(802) \ - register_type(902) - - -#ifdef register_type - -register_all_types - -#endif diff --git a/orig/include/ranges/type_register.h b/orig/include/ranges/type_register.h deleted file mode 100644 index 5635ce5..0000000 --- a/orig/include/ranges/type_register.h +++ /dev/null @@ -1,26 +0,0 @@ - -include_type(vector,1000) -include_type(size_t,1) -include_type(int,2) -include_type(char,3) -include_type(float,4) -include_type(double,5) -include_type(std::string,6) -include_type(vector,101) -include_type(vector,102) -include_type(vector,105) -include_type(vector,106) -include_type(std::array,201) -include_type(std::array,202) -include_type(std::array,205) -include_type(std::array,301) -include_type(std::array,302) -include_type(std::array,305) -include_type(std::array,401) -include_type(std::array,402) -include_type(std::array,405) -include_type(std::array,502) -include_type(std::array,602) -include_type(std::array,702) -include_type(std::array,802) -include_type(std::array,902) diff --git a/orig/include/ranges/value_range.h b/orig/include/ranges/value_range.h deleted file mode 100644 index fd9b0ec..0000000 --- a/orig/include/ranges/value_range.h +++ /dev/null @@ -1,415 +0,0 @@ - -#ifndef __cxz_value_range_h__ -#define __cxz_value_range_h__ - -#include -#include -#include -#include - -#include "rbase_def.h" -//#include "base_def.h" -#include "ranges/rpheader.h" -#include "ranges/index_base.h" -#include "ranges/range_base.h" -#include "ranges/x_to_string.h" -#include "ranges/type_map.h" - -#include "xfor/for_type.h" - -namespace CNORXZ -{ - - namespace - { - using namespace CNORXZInternal; - } - - template - class ValueIndex : public IndexInterface,U> - { - public: - - typedef IndexInterface,U> IB; - typedef U MetaType; - typedef ValueRange RangeType; - typedef ValueIndex IType; - - ValueIndex(const std::shared_ptr& rptr); - - static constexpr IndexType sType() { return IndexType::SINGLE; } - static constexpr size_t totalDim() { return 1; } - static constexpr size_t sDim() { return 1; } - - static constexpr SpaceType STYPE = SpaceType::NONE; - - IndexType type() const; - - ValueIndex& operator=(size_t pos); - ValueIndex& operator++(); - ValueIndex& operator--(); - - int pp(std::intptr_t idxPtrNum); - int mm(std::intptr_t idxPtrNum); - - std::string stringMeta() const; - const U& meta() const; - const U* metaPtr() const; - ValueIndex& at(const U& metaPos); - size_t posAt(const U& metaPos) const; - - size_t dim(); // = 1 - bool last(); - bool first(); - - std::shared_ptr range(); - - template - void getPtr(); - - size_t getStepSize(size_t n); - - template - auto ifor(size_t step, Expr ex) const - -> For,Expr>; - - template - auto iforh(size_t step, Expr ex) const - -> For,Expr,ForType::HIDDEN>; - - private: - std::shared_ptr mExplicitRangePtr; - U mMeta; - }; - - template - class ValueRangeFactory : public RangeFactoryBase - { - public: - - typedef ValueRange oType; - - ValueRangeFactory(); - std::shared_ptr create(); - }; - - template - class ValueRange : public RangeInterface > - { - public: - typedef RangeBase RB; - typedef ValueIndex IndexType; - typedef ValueRange RangeType; - typedef U MetaType; - typedef ValueRangeFactory FType; - - virtual size_t size() const final; - virtual size_t dim() const final; - - virtual SpaceType spaceType() const final; - virtual DataHeader dataHeader() const final; - - virtual vector typeNum() const final; - virtual size_t cmeta(char* target, size_t pos) const final; - virtual size_t cmetaSize() const final; - virtual std::string stringMeta(size_t pos) const final; - virtual vector data() const final; - - U get(size_t pos) const; - - virtual IndexType begin() const final; - virtual IndexType end() const final; - - friend ValueRangeFactory; - - static constexpr bool defaultable = true; - static constexpr size_t ISSTATIC = 1; - static constexpr size_t SIZE = 1; - static constexpr bool HASMETACONT = false; - - static std::shared_ptr Default() - { - ValueRangeFactory vrf; - return std::dynamic_pointer_cast( vrf.create() ); - } - - protected: - mutable U const* mMeta; - ValueRange() = default; - }; - -} // namespace CNORXZ - -/* ========================= * - * --- TEMPLATE CODE --- * - * ========================= */ - -namespace CNORXZ -{ - /***************** - * ValueIndex * - *****************/ - - namespace - { - template - std::shared_ptr mkDefaultValueRange() - { - ValueRangeFactory vrf; - return vrf.create(); - } - } - - template - ValueIndex::ValueIndex(const std::shared_ptr& rptr) : - IndexInterface,U>(rptr, 0), - mExplicitRangePtr(std::dynamic_pointer_cast(IB::mRangePtr)) - {} - - template - IndexType ValueIndex::type() const - { - return IndexType::SINGLE; - } - - template - ValueIndex& ValueIndex::operator=(size_t pos) - { - IB::mPos = pos; - return *this; - } - - template - ValueIndex& ValueIndex::operator++() - { - ++IB::mPos; - return *this; - } - - template - ValueIndex& ValueIndex::operator--() - { - --IB::mPos; - return *this; - } - - template - int ValueIndex::pp(std::intptr_t idxPtrNum) - { - ++(*this); - return 1; - } - - template - int ValueIndex::mm(std::intptr_t idxPtrNum) - { - --(*this); - return 1; - } - - template - std::string ValueIndex::stringMeta() const - { - return xToString(mMeta); - } - - template - const U& ValueIndex::meta() const - { - return mMeta; - } - - template - const U* ValueIndex::metaPtr() const - { - return &mMeta; - } - - template - ValueIndex& ValueIndex::at(const U& metaPos) - { - mMeta = metaPos; - return *this; - } - - template - size_t ValueIndex::posAt(const U& metaPos) const - { - return 0; - } - - template - size_t ValueIndex::dim() // = 1 - { - return 1; - } - - template - bool ValueIndex::last() - { - return IB::mPos == IB::mMax - 1; - } - - template - bool ValueIndex::first() - { - return IB::mPos == 0; - } - - template - std::shared_ptr::RangeType> ValueIndex::range() - { - return mExplicitRangePtr; - } - - template - template - void ValueIndex::getPtr() {} - - template - size_t ValueIndex::getStepSize(size_t n) - { - return 1; - } - - template - template - auto ValueIndex::ifor(size_t step, Expr ex) const - -> For,Expr> - { - //static const size_t LAYER = typename Expr::LAYER; - return For,Expr>(this, step, ex); - } - - template - template - auto ValueIndex::iforh(size_t step, Expr ex) const - -> For,Expr,ForType::HIDDEN> - { - //static const size_t LAYER = typename Expr::LAYER; - return For,Expr,ForType::HIDDEN>(this, step, ex); - } - - - /************************** - * ValueRangeFactory * - **************************/ - - - template - ValueRangeFactory::ValueRangeFactory() - { - mProd = std::shared_ptr( new ValueRange() ); - } - - template - std::shared_ptr ValueRangeFactory::create() - { - setSelf(); - return mProd; - } - - - /******************* - * ValueRange * - *******************/ - - template - size_t ValueRange::size() const - { - return 1; - } - - template - size_t ValueRange::dim() const - { - return 1; - } - - template - SpaceType ValueRange::spaceType() const - { - return SpaceType::NONE; - } - - template - vector ValueRange::typeNum() const - { - return {NumTypeMap::num()}; - } - - template - size_t ValueRange::cmeta(char* target, size_t pos) const - { - *reinterpret_cast(target) = *mMeta; - return sizeof(U); - } - - template - size_t ValueRange::cmetaSize() const - { - return sizeof(U); - } - - template - std::string ValueRange::stringMeta(size_t pos) const - { - return ""; - } - - template - U ValueRange::get(size_t pos) const - { - return *mMeta; - } - - template - vector ValueRange::data() const - { - assert(0); - DataHeader h = dataHeader(); - vector out; - out.reserve(h.metaSize + sizeof(DataHeader)); - char* hcp = reinterpret_cast(&h); - out.insert(out.end(), hcp, hcp + sizeof(DataHeader)); - - //const char* scp = reinterpret_cast(mSpace.data()); - //out.insert(out.end(), scp, scp + h.metaSize); - return out; - } - - template - DataHeader ValueRange::dataHeader() const - { - DataHeader h; - h.spaceType = static_cast( SpaceType::NONE ); - h.metaSize = 0; - h.metaType = NumTypeMap::num(); - h.multiple = 0; - return h; - } - - template - typename ValueRange::IndexType ValueRange::begin() const - { - ValueIndex i( std::dynamic_pointer_cast > - ( std::shared_ptr( RB::mThis ) ) ); - i = 0; - mMeta = &i.meta(); - return i; - } - - template - typename ValueRange::IndexType ValueRange::end() const - { - ValueIndex i( std::dynamic_pointer_cast > - ( std::shared_ptr( RB::mThis ) ) ); - i = size(); - mMeta = &i.meta(); - return i; - } - - -} // namespace CNORXZ - -#endif diff --git a/orig/include/ranges/x_to_string.h b/orig/include/ranges/x_to_string.h deleted file mode 100644 index 547d657..0000000 --- a/orig/include/ranges/x_to_string.h +++ /dev/null @@ -1,127 +0,0 @@ - -#ifndef __cxz_x_to_string_h__ -#define __cxz_x_to_string_h__ - -#include -#include -#include -#include -#include - -#include "ranges/dynamic_meta.h" - -namespace CNORXZInternal -{ - 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); - - using CNORXZ::DynamicMetaT; - - template <> - inline std::string xToString(const DynamicMetaT& x); - - template - inline std::string xToString(const 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) - { - std::string out = std::to_string(x); - std::replace(out.begin(), out.end(), ',', '.'); - return out; - } - - template - struct TupleToString - { - template - static inline std::string mk(const std::tuple& tp) - { - return TupleToString::mk(tp) + "," + xToString(std::get(tp)); - } - }; - - template <> - struct TupleToString<0> - { - template - static inline std::string mk(const std::tuple& tp) - { - return xToString(std::get<0>(tp)); - } - }; - - template <> - inline std::string xToString(const char& x) - { - std::string out = ""; - return out += x; - } - - template <> - inline std::string xToString(const std::string& x) - { - return x; - } - - template <> - inline std::string xToString(const DynamicMetaT& x) - { - std::string out = "["; - for(size_t i = 0; i != x.size(); ++i){ - out += x[i].first; - out += ","; - } - //out.pop_back(); - out.back() = ']'; - return out; - } - - template - inline std::string xToString(const vector& x) - { - std::string out = "["; - for(auto& y: x){ - out += xToString(y) + ","; - } - //out.pop_back(); - out.back() = ']'; - return out; - } - - template - inline std::string xToString(const std::array& x) - { - std::string out = "["; - for(auto& y: x){ - out += xToString(y) + ","; - } - //out.pop_back(); - out.back() = ']'; - return out; - } - - template - inline std::string xToString(const std::tuple& tp) - { - return "{" + TupleToString::mk(tp) + "}"; - } - -} - -#endif diff --git a/orig/include/slice.cc.h b/orig/include/slice.cc.h deleted file mode 100644 index 84a9338..0000000 --- a/orig/include/slice.cc.h +++ /dev/null @@ -1,300 +0,0 @@ - -#include "slice.h" - -namespace CNORXZ -{ - - /******************* - * ConstSlice * - *******************/ - - template - void ConstSlice::format(const std::array& blocks) - { - MAB::mProtoI->format(blocks); - } - - template - ConstSlice::ConstSlice(const std::tuple...>& ranges, - const T* data) : - ArrayBase(ranges), - mData(data) - { - MAB::mInit = true; - } - - template - ConstSlice::ConstSlice(const std::shared_ptr&... ranges, const T* data) : - ArrayBase(ranges...), - mData(data) - { - MAB::mInit = true; - } - - template - ConstSlice::ConstSlice(const ArrayBase& ma, SIZET... sizes) : - ArrayBase - ( ma.range()->template get<0>().template scast(sizes...)->space() ), - mData( ma.data() ) - { - MAB::mInit = true; - } - - template - const T& ConstSlice::operator[](const IType& i) const - { - //assert(i.sliceMode()); // -> compare objects !!!!! - assert(i.container() == reinterpret_cast(this)); - return mData[ i.pos() ]; - } - - template - const T& ConstSlice::at(const typename IType::MetaType& meta) const - { - //auto x = begin().at(meta); - //VCHECK(x.pos()); - return mData[ begin().at(meta).pos() ]; - } - - template - const T* ConstSlice::data() const - { - return mData; - } - - template - bool ConstSlice::isSlice() const - { - return true; - } - - template - auto ConstSlice::begin() const -> ConstSlice::IType - { - IType i(*MAB::mProtoI,true); - i = 0; - //i = mStartPos; - return i.setData(data()); - } - - template - auto ConstSlice::end() const -> ConstSlice::IType - { - IType i(*MAB::mProtoI,true); - i = i.max(); // CHECK !!! - //i = std::get(mBlockSizes); - return i.setData(data()); - } - - template - std::shared_ptr > ConstSlice::anonymous(bool slice) const - { - assert(slice); - assert(not MAB::mProtoI->sliceMode()); // only originally ordered slices! - AnonymousRangeFactory arf(MAB::mRange->space()); - return std::make_shared > - ( std::dynamic_pointer_cast( arf.create() ), - data() ); - return nullptr; - } - - template - auto ConstSlice::define(const std::shared_ptr&... inds) - -> ConstSliceDef - { - return ConstSliceDef(*this, inds...); - } - - - /************** - * Slice * - **************/ - - template - void Slice::format(const std::array& blocks) - { - MAB::mProtoI->format(blocks); - } - - template - Slice::Slice(const std::shared_ptr&... ranges, T* data) : - MutableArrayBase(ranges...), - mData(data) {} - - template - Slice::Slice(const std::tuple...>& ranges, - T* data) : - MutableArrayBase(ranges), - mData(data) - { - MAB::mInit = true; - } - - template - Slice& Slice::operator=(T val) - { - OperationRoot opr(data(), begin()); - OperationValue opv(val); - opr = opv; - return *this; - } - - template - const T& Slice::operator[](const IType& i) const - { - //assert(i.sliceMode()); // -> compare objects !!!!! - assert(i.container() == reinterpret_cast(this)); - return mData[ i.pos() ]; - } - - template - T& Slice::operator[](const IType& i) - { - //assert(i.sliceMode()); - assert(i.container() == reinterpret_cast(this)); - return mData[ i.pos() ]; - } - - template - const T& Slice::at(const typename IType::MetaType& meta) const - { - //auto x = begin().at(meta); - //VCHECK(x.pos()); - return mData[ begin().at(meta).pos() ]; - } - - template - T& Slice::at(const typename IType::MetaType& meta) - { - //auto x = begin().at(meta); - //VCHECK(x.pos()); - return mData[ begin().at(meta).pos() ]; - } - - template - const T* Slice::data() const - { - return mData; - } - - template - T* Slice::data() - { - return mData; - } - - template - bool Slice::isSlice() const - { - return true; - } - - template - auto Slice::begin() const -> Slice::IType - { - IType i(*MAB::mProtoI,true); - i = 0; - //i = mStartPos; - return i.setData(data()); - } - - template - auto Slice::end() const -> Slice::IType - { - IType i(*MAB::mProtoI,true); - i = i.max(); // CHECK !!! - //i = std::get(mBlockSizes); - return i.setData(data()); - } - - template - std::shared_ptr > Slice::anonymous(bool slice) const - { - assert(0); // think about carefully!!!! - return nullptr; - } - /* - template - std::shared_ptr > Slice::anonymousMove() - { - assert(0); // think about carefully!!!! - return nullptr; - } - */ - template - auto Slice::define(const std::shared_ptr&... inds) - -> SliceDef - { - return SliceDef(*this, inds...); - } - - - template - SliceDef::SliceDef(Slice& sl, - const std::shared_ptr&... inds) : - mIndex(sl.begin()), - mSl(sl) - { - mIndex(inds...); - } - - template - template - SliceDef& SliceDef::operator=(const OperationRoot& op) - { - std::array blocks; - sfor_pn<0,sizeof...(SRanges)> - ( [&](auto i) { - std::get(blocks) = - op.rootSteps(reinterpret_cast - ( mIndex.template getPtr().get())).val(); - return 0; } ); - mSl.format(blocks); - mSl.mData = op.data(); - return *this; - } - - template - ConstSliceDef::ConstSliceDef(ConstSlice& sl, - const std::shared_ptr&... inds) : - mIndex(sl.begin()), - mSl(sl) - { - mIndex(inds...); - } - - template - template - ConstSliceDef& ConstSliceDef::operator=(const ConstOperationRoot& op) - { - std::array blocks; - sfor_pn<0,sizeof...(SRanges)> - ( [&](auto i) { - std::get(blocks) = - op.rootSteps(reinterpret_cast - ( mIndex.template getPtr().get())).val(); - return 0; } ); - mSl.format(blocks); - mSl.mData = op.data(); - return *this; - } - - template - template - ConstSliceDef& ConstSliceDef::operator=(const OperationRoot& op) - { - std::array blocks; - sfor_pn<0,sizeof...(SRanges)> - ( [&](auto i) { - std::get(blocks) = - op.rootSteps(reinterpret_cast - ( mIndex.template getPtr().get())).val(); - return 0; } ); - mSl.format(blocks); - mSl.mData = op.data(); - return *this; - } - - -} // end namespace CNORXZ - diff --git a/orig/include/slice.h b/orig/include/slice.h deleted file mode 100644 index dbc9a01..0000000 --- a/orig/include/slice.h +++ /dev/null @@ -1,198 +0,0 @@ - -#ifndef __cxz_slice_h__ -#define __cxz_slice_h__ - -#include "cxz_array_base.h" -#include "cxz_operation.h" - -namespace CNORXZ -{ - template - class ConstSlice : public ArrayBase - { - public: - - typedef ContainerRange CRange; - typedef ArrayBase MAB; - typedef ConstContainerIndex IType; - - using ArrayBase::operator(); - using ArrayBase::operator[]; - - DEFAULT_MEMBERS(ConstSlice); - - ConstSlice(const std::tuple...>& ranges, - const T* data = nullptr); - ConstSlice(const std::shared_ptr&... ranges, const T* data = nullptr); - ConstSlice(const ArrayBase& ma, SIZET... sizes); - - virtual const T& operator[](const IType& i) const final; - virtual const T& at(const typename IType::MetaType& meta) const override; - - virtual const T* data() const override; - - virtual bool isSlice() const override; - - virtual auto begin() const -> IType override; - virtual auto end() const -> IType override; - - virtual std::shared_ptr > anonymous(bool slice = false) const override; - - auto define(const std::shared_ptr&... inds) - -> ConstSliceDef; - - private: - friend ConstSliceDef; - - void format(const std::array& blocks); - - const T* mData; - }; - - - template - class Slice : public MutableArrayBase - { - public: - - typedef ContainerRange CRange; - typedef ArrayBase MAB; - typedef ConstContainerIndex IType; - - using ArrayBase::operator(); - using MutableArrayBase::operator(); - using ArrayBase::operator[]; - using MutableArrayBase::operator[]; - - DEFAULT_MEMBERS(Slice); - - Slice(const std::tuple...>& ranges, - T* data = nullptr); - Slice(const std::shared_ptr&... ranges, T* data = nullptr); - - Slice& operator=(T val); - - virtual const T& operator[](const IType& i) const final; - virtual T& operator[](const IType& i) final; - virtual const T& at(const typename IType::MetaType& meta) const override; - virtual T& at(const typename IType::MetaType& meta) override; - - virtual const T* data() const override; - virtual T* data() override; - - virtual bool isSlice() const override; - - virtual auto begin() const -> IType override; - virtual auto end() const -> IType override; - - virtual std::shared_ptr > anonymous(bool slice = false) const override; - //virtual std::shared_ptr > anonymousMove() override; - - auto define(const std::shared_ptr&... inds) - -> SliceDef; - - private: - friend SliceDef; - - void format(const std::array& blocks); - - T* mData; - }; - - - template - class SliceDef - { - public: - typedef ConstContainerIndex IType; - - template - static Slice mkSlice( const typename Slice::IndexType& ind, - const Op& op ) - { - Slice out(ind->range()->space(), &*ind); - std::array ff; - sfor_pn<0,sizeof...(SRanges)> - ( [&](auto i) { - std::get(ff) = - op.rootSteps(reinterpret_cast - ( ind.template getPtr().get())).val(); - return 0; } ); - out.format(ff); - return out; - } - - private: - IType mIndex; - Slice& mSl; - - SliceDef() = default; - public: - - SliceDef(Slice& sl, - const std::shared_ptr&... inds); - - template - SliceDef& operator=(const OperationRoot& op); - }; - - template - class ConstSliceDef - { - public: - typedef ConstContainerIndex IType; - - template - static ConstSlice mkSlice( const typename ConstSlice::IndexType& ind, - const Op& op ) - { - ConstSlice out(ind->range()->space(), &*ind); - std::array ff; - sfor_pn<0,sizeof...(SRanges)> - ( [&](auto i) { - std::get(ff) = - op.rootSteps(reinterpret_cast - ( ind.template getPtr().get())).val(); - return 0; } ); - out.format(ff); - return out; - } - - private: - IType mIndex; - ConstSlice& mSl; - - ConstSliceDef() = default; - public: - ConstSliceDef(ConstSlice& csl, - const std::shared_ptr&... inds); - - template - ConstSliceDef& operator=(const ConstOperationRoot& op); - - template - ConstSliceDef& operator=(const OperationRoot& op); - }; - - template - ConstSlice mkSlice( const typename ConstSlice::IndexType& ind, - const Op& op ) - { - return ConstSliceDef::mkSlice(ind, op); - } - - template - Slice mkSlice( const typename Slice::IndexType& ind, - const Op& op ) - { - return SliceDef::mkSlice(ind, op); - } - -} // end namespace CNORXZ - -/* ========================= * - * --- TEMPLATE CODE --- * - * ========================= */ - - -#endif diff --git a/orig/lib/high_level_operation.cc b/orig/lib/high_level_operation.cc deleted file mode 100644 index fd6a280..0000000 --- a/orig/lib/high_level_operation.cc +++ /dev/null @@ -1,40 +0,0 @@ - -#include "cnorxz.h" -#include "hl_cnorxz.h" - -namespace CNORXZ -{ - std::shared_ptr mkSubSpaceX(const std::shared_ptr& di, - size_t max) - { - auto& o = di->range()->orig(); - vector> ox(o.begin(),o.begin()+max); - DynamicRangeFactory drf(ox); - auto dr = createExplicit(drf); - auto odi = getIndex(dr); - vector> iv; - iv.reserve(max); - for(size_t i = 0; i != max; ++i){ - iv.push_back(di->getP(i)); - } - (*odi)(iv); - return odi; - } - - template class OperationRoot; - template class OperationRoot; - - template class HighLevelOpHolder; - template class HighLevelOpHolder; - - template class HighLevelOpBase; - template class HighLevelOpBase; - template class HighLevelOpRoot; - template class HighLevelOpRoot; - - template HighLevelOpHolder mkHLO(const OpCD& op); - template HighLevelOpHolder mkHLO(const OpD& op); - template HighLevelOpHolder mkHLOV(double val); - template HighLevelOpHolder mkHLOV(double val); - -} diff --git a/orig/lib/hl_ops/divides.cc b/orig/lib/hl_ops/divides.cc deleted file mode 100644 index 2047a51..0000000 --- a/orig/lib/hl_ops/divides.cc +++ /dev/null @@ -1,8 +0,0 @@ -#include "cnorxz.h" -#include "hl_cnorxz.h" - -namespace CNORXZ -{ - template class HighLevelOp,2>; - template class HighLevelOp,2>; -} diff --git a/orig/lib/hl_ops/exp.cc b/orig/lib/hl_ops/exp.cc deleted file mode 100644 index fa51192..0000000 --- a/orig/lib/hl_ops/exp.cc +++ /dev/null @@ -1,10 +0,0 @@ -#include "cnorxz.h" -#include "hl_cnorxz.h" - -namespace CNORXZ -{ - template class HighLevelOp,1>; - template class HighLevelOp,1>; - template HighLevelOpHolder hl_exp (const HighLevelOpHolder& in); - template HighLevelOpHolder hl_exp (const HighLevelOpHolder& in); -} diff --git a/orig/lib/hl_ops/minus.cc b/orig/lib/hl_ops/minus.cc deleted file mode 100644 index 5faeeaf..0000000 --- a/orig/lib/hl_ops/minus.cc +++ /dev/null @@ -1,8 +0,0 @@ -#include "cnorxz.h" -#include "hl_cnorxz.h" - -namespace CNORXZ -{ - template class HighLevelOp,2>; - template class HighLevelOp,2>; -} diff --git a/orig/lib/hl_ops/multiplies.cc b/orig/lib/hl_ops/multiplies.cc deleted file mode 100644 index 71182e2..0000000 --- a/orig/lib/hl_ops/multiplies.cc +++ /dev/null @@ -1,8 +0,0 @@ -#include "cnorxz.h" -#include "hl_cnorxz.h" - -namespace CNORXZ -{ - template class HighLevelOp,2>; - template class HighLevelOp,2>; -} diff --git a/orig/lib/hl_ops/negate.cc b/orig/lib/hl_ops/negate.cc deleted file mode 100644 index 79ca9b6..0000000 --- a/orig/lib/hl_ops/negate.cc +++ /dev/null @@ -1,8 +0,0 @@ -#include "cnorxz.h" -#include "hl_cnorxz.h" - -namespace CNORXZ -{ - template class HighLevelOp,1>; - template class HighLevelOp,1>; -} diff --git a/orig/lib/hl_ops/plus.cc b/orig/lib/hl_ops/plus.cc deleted file mode 100644 index 68fc583..0000000 --- a/orig/lib/hl_ops/plus.cc +++ /dev/null @@ -1,8 +0,0 @@ -#include "cnorxz.h" -#include "hl_cnorxz.h" - -namespace CNORXZ -{ - template class HighLevelOp,2>; - template class HighLevelOp,2>; -} diff --git a/orig/lib/map_range_factory_product_map.cc b/orig/lib/map_range_factory_product_map.cc deleted file mode 100644 index 0991b75..0000000 --- a/orig/lib/map_range_factory_product_map.cc +++ /dev/null @@ -1,7 +0,0 @@ - -#include "map_range_factory_product_map.h" - -namespace CNORXZ -{ - std::map,vector > MapRangeFactoryProductMap::mAleadyCreated; -} diff --git a/orig/lib/mk_hl_op.sh b/orig/lib/mk_hl_op.sh deleted file mode 100755 index 77c7ecd..0000000 --- a/orig/lib/mk_hl_op.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/bash - -mkdir -p hl_ops -for x in $(cat ../include/extensions/math.h) ; do - test "${x}" = "#ifdef" && continue - test "${x}" = "#endif" && continue - test "${x}" = "regFunc1" && continue - xx=${x#regFunc1\(} - fff=${xx%\)} - file=hl_ops/${fff}.cc - test -f ${file} && rm -f ${file} - echo "#include \"cnorxz.h\"" >> ${file} - echo "#include \"hl_cnorxz.h\"" >> ${file} - echo "" >> ${file} - echo "namespace CNORXZ" >> ${file} - echo "{" >> ${file} - echo " template class HighLevelOp,1>;" >> ${file} - echo " template class HighLevelOp,1>;" >> ${file} - echo " template HighLevelOpHolder hl_${fff} (const HighLevelOpHolder& in);" >> ${file} - echo " template HighLevelOpHolder hl_${fff} (const HighLevelOpHolder& in);" >> ${file} - echo "}" >> ${file} -done - -for fff in plus minus multiplies divides ; do - file=hl_ops/${fff}.cc - test -f ${file} && rm -f ${file} - echo "#include \"cnorxz.h\"" >> ${file} - echo "#include \"hl_cnorxz.h\"" >> ${file} - echo "" >> ${file} - echo "namespace CNORXZ" >> ${file} - echo "{" >> ${file} - echo " template class HighLevelOp,2>;" >> ${file} - echo " template class HighLevelOp,2>;" >> ${file} - echo "}" >> ${file} -done - -for fff in negate ; do - file=hl_ops/${fff}.cc - test -f ${file} && rm -f ${file} - echo "#include \"cnorxz.h\"" >> ${file} - echo "#include \"hl_cnorxz.h\"" >> ${file} - echo "" >> ${file} - echo "namespace CNORXZ" >> ${file} - echo "{" >> ${file} - echo " template class HighLevelOp,1>;" >> ${file} - echo " template class HighLevelOp,1>;" >> ${file} - echo "}" >> ${file} -done diff --git a/orig/lib/ranges/anonymous_range.cc b/orig/lib/ranges/anonymous_range.cc deleted file mode 100644 index acf7266..0000000 --- a/orig/lib/ranges/anonymous_range.cc +++ /dev/null @@ -1,297 +0,0 @@ - -#include "ranges/anonymous_range.h" -#include "ranges/ranges_header.cc.h" -#include "cxz_assert.h" - -namespace CNORXZ -{ - /****************************** - * AnonymousRangeFactory * - ******************************/ - - AnonymousRangeFactory::AnonymousRangeFactory() - { - mProd = std::shared_ptr( new AnonymousRange() ); - } - - - std::map,vector > AnonymousRangeFactory::mAleadyCreated; - - AnonymousRangeFactory::AnonymousRangeFactory(const vector>& origs) - { - mProd = std::shared_ptr( new AnonymousRange( origs ) ); - } - - std::shared_ptr AnonymousRangeFactory::checkIfCreated(const vector >& pvec) - { - std::shared_ptr out; - bool check = false; - for(auto& x: mAleadyCreated){ - if(x.second.size() == pvec.size()){ - check = true; - for(size_t i = 0; i != x.second.size(); ++i){ - if(x.second[i] != reinterpret_cast( pvec[i].get() ) ){ - check = false; - break; - } - } - if(check == true){ - out = x.first; - break; - } - } - } - if(not check){ - vector app(pvec.size()); - for(size_t i = 0; i != app.size(); ++i){ - app[i] = reinterpret_cast( pvec[i].get() ); - } - mAleadyCreated[mProd] = app; - out = mProd; - } - return out; - } - - - std::shared_ptr AnonymousRangeFactory::create() - { - mProd = checkIfCreated(std::dynamic_pointer_cast(mProd)->mOrig); - setSelf(); - mProductCreated = true; - return mProd; - } - - /*********************** - * AnonymousRange * - ***********************/ - - size_t AnonymousRange::get(size_t pos) const - { - return pos; - } - - size_t AnonymousRange::getMeta(size_t metaPos) const - { - return metaPos; - } - - size_t AnonymousRange::size() const - { - return mSize; - } - - size_t AnonymousRange::dim() const - { - return 1; - } - - SpaceType AnonymousRange::spaceType() const - { - return SpaceType::ANON; - } - - bool AnonymousRange::isEmpty() const - { - return mEmpty; - } - - vector AnonymousRange::typeNum() const - { - vector o; - for(auto& x: mOrig){ - auto tn = x->typeNum(); - o.insert(o.end(), tn.begin(), tn.end()); - } - return o; - } - - size_t AnonymousRange::cmeta(char* target, size_t pos) const - { - size_t out = 0; - size_t off = cmetaSize(); - for(size_t i = mOrig.size(); i != 0; --i) { - auto& x = mOrig[i-1]; - const size_t redpos = pos % x->size(); - const size_t s = x->cmetaSize(); - out += s; - off -= s; - pos -= redpos; - pos /= x->size(); - x->cmeta(target+off,redpos); - } - return out; - } - - size_t AnonymousRange::cmetaSize() const - { - size_t out = 0; - for(size_t i = mOrig.size(); i != 0; --i) { - auto& x = mOrig[i-1]; - out += x->cmetaSize(); - } - return out; - } - - std::string AnonymousRange::stringMeta(size_t pos) const - { - std::string out = "[ "; - //size_t xpos = pos; - for(size_t i = mOrig.size(); i != 0; --i) { - auto& x = mOrig[i-1]; - const size_t redpos = pos % x->size(); - out = ( (i == mOrig.size()) ? out : out + " , " ) + x->stringMeta(redpos); - pos -= redpos; - pos /= x->size(); - } - out += " ]"; - return out; - } - - vector AnonymousRange::data() const - { - DataHeader h = dataHeader(); - vector out; - char* hcp = reinterpret_cast(&h); - out.insert(out.end(), hcp, hcp + sizeof(DataHeader)); - for(auto& x: mOrig){ - auto part = x->data(); - out.insert(out.end(), part.begin(), part.end()); - } - return out; - } - - DataHeader AnonymousRange::dataHeader() const - { - DataHeader h; - h.spaceType = static_cast( SpaceType::ANON ); - h.metaSize = mOrig.size(); - h.multiple = 1; - return h; - } - - size_t AnonymousRange::anonymousDim() const - { - return mOrig.size(); - } - - typename AnonymousRange::IndexType AnonymousRange::begin() const - { - AnonymousIndex i - (std::dynamic_pointer_cast - ( std::shared_ptr(RB::mThis) ) ); - i = 0; - return i; - } - - typename AnonymousRange::IndexType AnonymousRange::end() const - { - AnonymousIndex i - (std::dynamic_pointer_cast - ( std::shared_ptr(RB::mThis) ) ); - i = size(); - return i; - } - - - std::shared_ptr AnonymousRange::sub(size_t num) const - { - return mOrig.at(num); - } - - std::shared_ptr AnonymousRange::sreplace(const std::shared_ptr in, size_t num) const - { - MA_ASSERT(mOrig[num]->size() == in->size(), - std::string("replaced range has different size than given range (") - +std::to_string(mOrig[num]->size())+" vs "+std::to_string(in->size())+")"); - auto tmp = mOrig; - tmp[num] = in; - AnonymousRangeFactory arf(tmp); - return std::dynamic_pointer_cast(arf.create()); - } - - std::shared_ptr AnonymousRange::sreplace(const vector>& in, size_t num) const - { - size_t nsize = 1; - for(auto& x: in){ - nsize *= x->size(); - } - MA_ASSERT(mOrig[num]->size() == nsize, - std::string("replaced range has different size than given range (") - +std::to_string(mOrig[num]->size())+" vs "+std::to_string(nsize)+")"); - auto norig = mOrig; - norig.resize(mOrig.size() + in.size() - 1); - for(size_t i = 0; i != num; ++i){ - norig[i] = mOrig[i]; - } - for(size_t i = 0; i != in.size(); ++i){ - norig[num+i] = in[i]; - } - for(size_t i = num + 1 ; i < mOrig.size(); ++i){ - norig[in.size()+i-1] = mOrig[i]; - } - //mOrig = std::move( norig ); - AnonymousRangeFactory arf(norig); - return std::dynamic_pointer_cast(arf.create()); - } - - std::shared_ptr AnonymousRange::sreplace(const std::shared_ptr& in, - const vector& num) const - { - if(num.size() != 0){ - size_t cnt = num[0]; - size_t rep_size = 1; - // assert continuous ordering or replaced ranges: - for(auto& x: num){ - assert(cnt++ == x); - rep_size *= mOrig[x]->size(); - } - MA_ASSERT(rep_size == in->size(), - std::string("replaced range has different size than given range (") - +std::to_string(rep_size)+" vs "+std::to_string(in->size())+")"); - vector> norig; - norig.reserve(mOrig.size()-num.size()+1); - norig.insert(norig.end(),mOrig.begin(),mOrig.begin()+num[0]); - norig.push_back(in); - norig.insert(norig.end(),mOrig.begin()+num.back()+1,mOrig.end()); - AnonymousRangeFactory arf(norig); - return std::dynamic_pointer_cast(arf.create()); - } - else { - return std::dynamic_pointer_cast( std::shared_ptr(RB::mThis) ); - } - } - - const vector >& AnonymousRange::orig() const - { - return mOrig; - } - - GenSingleRange::GenSingleRange(const vector>& origs) : - RangeInterface(), - mOrig(origs) - { - mSize = 1; - for(auto& x: mOrig){ - mSize *= x->size(); - } - if(mOrig.size()){ - mEmpty = false; - } - } - - - /***************** - * Functions * - *****************/ - - std::shared_ptr defaultRange(size_t size ) - { - AnonymousRangeFactory arf - ( std::dynamic_pointer_cast - (AnonymousRange::factory().create() ) ); - return std::dynamic_pointer_cast( arf.create() ); - } - - - -} // end namespace CNORXZ diff --git a/orig/lib/ranges/dynamic_meta.cc b/orig/lib/ranges/dynamic_meta.cc deleted file mode 100644 index 5422bdf..0000000 --- a/orig/lib/ranges/dynamic_meta.cc +++ /dev/null @@ -1,48 +0,0 @@ - -#include -#include -#include "ranges/dynamic_meta.h" -#include "ranges/ranges_header.cc.h" - -namespace CNORXZ -{ - - /********************* - * DynamicMetaT * - *********************/ - - bool DynamicMetaT::operator==(const DynamicMetaT& in) const - { - if(in.size() != mMeta.size()) { return false; } - for(size_t i = 0; i != mMeta.size(); ++i){ - if(in[i].second != mMeta[i].second) { return false; } - for(size_t j = 0; j != mMeta[i].second; ++j){ - if(in[i].first[j] != mMeta[i].first[j]) { return false; } - } - } - return true; - } - - bool DynamicMetaT::operator!=(const DynamicMetaT& in) const - { - return not operator==(in); - } - - size_t DynamicMetaT::size() const - { - return mMeta.size(); - } - - DynamicMetaElem& DynamicMetaT::operator[](size_t pos) - { - return mMeta[pos]; - } - - const DynamicMetaElem& DynamicMetaT::operator[](size_t pos) const - { - return mMeta[pos]; - } - - - -} // namespace CNORXZ diff --git a/orig/lib/ranges/dynamic_range.cc b/orig/lib/ranges/dynamic_range.cc deleted file mode 100644 index 2ec7bfe..0000000 --- a/orig/lib/ranges/dynamic_range.cc +++ /dev/null @@ -1,488 +0,0 @@ - -#include "ranges/dynamic_range.h" -#include "ranges/ranges_header.cc.h" -#include "cxz_assert.h" - -namespace CNORXZ -{ - namespace - { - using namespace CNORXZInternal; - } - - - - DynamicRangeFactory::DynamicRangeFactory(const vector>& origs) - { - mProd = std::shared_ptr( new DynamicRange( origs ) ); - } - - - - - DynamicRangeFactory::DynamicRangeFactory() - { - mProd = std::shared_ptr( new DynamicRange() ); - } - - // INSTANCIATE IF NEEDED!! - - std::map,vector > DynamicRangeFactory::mAleadyCreated; - DynamicIndex::IMapT DynamicIndex::sIMap; - - std::shared_ptr DynamicRangeFactory::checkIfCreated(const vector >& pvec) - { - std::shared_ptr out; - bool check = false; - for(auto& x: mAleadyCreated){ - if(x.second.size() == pvec.size()){ - check = true; - for(size_t i = 0; i != x.second.size(); ++i){ - if(x.second[i] != reinterpret_cast( pvec[i].get() ) ){ - check = false; - break; - } - } - if(check == true){ - out = x.first; - break; - } - } - } - if(not check){ - vector app(pvec.size()); - for(size_t i = 0; i != app.size(); ++i){ - app[i] = reinterpret_cast( pvec[i].get() ); - } - mAleadyCreated[mProd] = app; - out = mProd; - } - return out; - } - - - - std::shared_ptr DynamicRangeFactory::create() - { - mProd = checkIfCreated(std::dynamic_pointer_cast(mProd)->mOrig); - setSelf(); - mProductCreated = true; - return mProd; - } - - - /********************* - * DynamicIndex * - *********************/ - - - DynamicIndex::DynamicIndex(const std::shared_ptr& range) : - IndexInterface(range, 0), - mIVec(range->dim()) - { - if(mIVec.size() > 0){ - size_t xx = 1; - for(size_t i = mIVec.size()-1; i != 0; --i){ - mIVec[i].second = xx; - xx *= range->sub(i)->size(); - } - mIVec[0].second = xx; - } - } - - - IndexType DynamicIndex::type() const - { - return IndexType::SINGLE; - } - - - DynamicIndex& DynamicIndex::operator=(size_t pos) - { - IB::mPos = pos; - return *this; - } - - - DynamicIndex& DynamicIndex::operator++() - { - ++IB::mPos; - if(mIvecInit){ - size_t ipos = mIVec.size()-1; - auto& ii = mIVec[ipos].first; - auto& jj = mIVec[ipos-1].first; - while(ii->pos() == ii->max()-1 and ipos != 0) { - (*ii) = 0; - ++(*jj); - --ipos; - } - } - return *this; - } - - - DynamicIndex& DynamicIndex::operator--() - { - --IB::mPos; - if(mIvecInit){ - size_t ipos = mIVec.size()-1; - auto& ii = mIVec[ipos].first; - auto& jj = mIVec[ipos-1].first; - while(ii->pos() == 0 and ipos != 0) { - (*ii) = ii->max()-1; - --(*jj); - --ipos; - } - } - return *this; - } - - - DynamicIndex& DynamicIndex::sync() - { - MA_ASSERT(mIvecInit, "ivec not initialized"); - size_t sv = 1; - IB::mPos = 0; - for(size_t i = 0; i != mIVec.size(); ++i){ - auto& x = mIVec[mIVec.size()-i-1]; - IB::mPos += x.first->pos() * sv; - sv *= x.first->max(); - } - return *this; - } - - - DynamicIndex& DynamicIndex::operator()(const IVecT& ivec) - { - mIvecInit = true; - mIVec = ivec; - sync(); - return *this; - } - - - DynamicIndex& DynamicIndex::operator()(const vector>& ivec) - { - mIvecInit = true; - MA_ASSERT(mIVec.size() == ivec.size(), std::string("require ")+std::to_string(mIVec.size())+" indices"); - for(size_t i = 0; i != mIVec.size(); ++i){ - mIVec[i].first = ivec[i]; - } - sync(); - return *this; - } - - DynamicIndex& DynamicIndex::operator()(const vector& inames) - { - mIvecInit = true; - MA_ASSERT(mIVec.size() == inames.size(), std::string("require ")+std::to_string(mIVec.size())+" indices"); - for(size_t i = 0; i != mIVec.size(); ++i){ - const std::string& iname = inames[i]; - const std::string smeta = (iname.find_first_of("=") != std::string::npos) ? iname.substr(iname.find_first_of("=")+1) : ""; - if(sIMap.count(iname) != 0){ - auto thisr = this->range()->sub(i); - auto mapr = sIMap.at(iname)->range(); - if(thisr != mapr){ - MA_WARNING(std::string("range of index at position ")+std::to_string(i)+ - " is different from range of index with name "+iname); - MA_ASSERT(thisr->size() == mapr->size(), - "different size!"); - for(size_t jj = 0; jj != thisr->size(); ++jj){ - MA_ASSERT(thisr->stringMeta(jj) == mapr->stringMeta(jj), - "different meta"); - } - } - } - else { - sIMap[iname] = this->range()->sub(i)->aindex(); - } - if(smeta != ""){ - sIMap.at(iname)->at(smeta); - MA_ASSERT(sIMap.at(iname)->pos() != sIMap.at(iname)->max(), - smeta+" is not part of range of index with name "+iname); - } - mIVec[i].first = sIMap.at(iname); - } - sync(); - return *this; - } - - - int DynamicIndex::pp(std::intptr_t idxPtrNum) - { - ++(*this); - return 1; - } - - - int DynamicIndex::mm(std::intptr_t idxPtrNum) - { - --(*this); - return 1; - } - - - std::string DynamicIndex::stringMeta() const - { - return std::dynamic_pointer_cast( IB::mRangePtr )->stringMeta(IB::mPos); - } - - - typename DynamicIndex::MetaType DynamicIndex::meta() const - { - return std::dynamic_pointer_cast( IB::mRangePtr )->get(IB::mPos); - } - - - const typename DynamicIndex::MetaType* DynamicIndex::metaPtr() const - { - return nullptr; - } - - /* - bool DynamicIndex::isMeta(const MetaType& metaPos) const - { - return mExplicitRangePtr->isMeta(metaPos); - }*/ - - - DynamicIndex& DynamicIndex::at(const MetaType& metaPos) - { - (*this) = std::dynamic_pointer_cast( IB::mRangePtr )->getMeta( metaPos ); - return *this; - } - - - size_t DynamicIndex::posAt(const MetaType& metaPos) const - { - return std::dynamic_pointer_cast( IB::mRangePtr )->getMeta( metaPos ); - } - - - size_t DynamicIndex::dim() const // = 1 - { - return mIVec.size(); - } - - - bool DynamicIndex::last() const - { - return IB::mPos == IB::mMax - 1; - } - - - bool DynamicIndex::first() const - { - return IB::mPos == 0; - } - - - const IndexW& DynamicIndex::get(size_t n) const - { - MA_ASSERT(mIvecInit, "ivec not initialized"); - return *mIVec[n].first; - } - - const std::shared_ptr& DynamicIndex::getP(size_t n) const - { - MA_ASSERT(mIvecInit, "ivec not initialized"); - return mIVec[n].first; - } - - std::shared_ptr DynamicIndex::range() - { - return std::dynamic_pointer_cast( IB::mRangePtr ); - } - - - - - - size_t DynamicIndex::getStepSize(size_t n) const - { - return mIVec[n].second; - } - - - /*********************** - * DynamicRange * - ***********************/ - - - typename DynamicRange::MetaType DynamicRange::get(size_t pos) const - { - vector out(cmetaSize()); - cmeta(out.data(),pos); - return out; - } - - - size_t DynamicRange::getMeta(const MetaType& metaPos) const - { - return 0; // !!! - } - - - size_t DynamicRange::size() const - { - return mSize; - } - - - size_t DynamicRange::dim() const - { - return mOrig.size(); - } - - - SpaceType DynamicRange::spaceType() const - { - return SpaceType::DYN; - } - - - bool DynamicRange::isEmpty() const - { - return mEmpty; - } - - - vector DynamicRange::typeNum() const - { - vector o; - for(auto& x: mOrig){ - auto tn = x->typeNum(); - o.insert(o.end(), tn.begin(), tn.end()); - } - return o; - } - - - size_t DynamicRange::cmeta(char* target, size_t pos) const - { - size_t out = 0; - size_t off = cmetaSize(); - for(size_t i = mOrig.size(); i != 0; --i) { - auto& x = mOrig[i-1]; - const size_t redpos = pos % x->size(); - const size_t s = x->cmetaSize(); - out += s; - off -= s; - pos -= redpos; - pos /= x->size(); - x->cmeta(target+off,redpos); - } - assert(off == 0); - return out; - } - - - size_t DynamicRange::cmetaSize() const - { - size_t out = 0; - for(size_t i = mOrig.size(); i != 0; --i) { - auto& x = mOrig[i-1]; - out += x->cmetaSize(); - } - return out; - } - - - std::string DynamicRange::stringMeta(size_t pos) const - { - std::string out = ""; - //size_t xpos = pos; - for(size_t i = mOrig.size(); i != 0; --i) { - auto& x = mOrig[i-1]; - const size_t redpos = pos % x->size(); - out = x->stringMeta(redpos) + ( (i == mOrig.size()) ? out : ", " + out ); - pos -= redpos; - pos /= x->size(); - } - out = "[" + out + "]"; - return out; - } - - - vector DynamicRange::data() const - { - DataHeader h = dataHeader(); - vector out; - char* hcp = reinterpret_cast(&h); - out.insert(out.end(), hcp, hcp + sizeof(DataHeader)); - for(auto& x: mOrig){ - auto part = x->data(); - out.insert(out.end(), part.begin(), part.end()); - } - return out; - } - - - DataHeader DynamicRange::dataHeader() const - { - DataHeader h; - h.spaceType = static_cast( SpaceType::DYN ); - h.metaSize = mOrig.size(); - h.multiple = 1; - return h; - } - - - typename DynamicRange::IndexType DynamicRange::begin() const - { - DynamicIndex i - (std::dynamic_pointer_cast - ( std::shared_ptr(RB::mThis) ) ); - i = 0; - return i; - } - - - typename DynamicRange::IndexType DynamicRange::end() const - { - DynamicIndex i - (std::dynamic_pointer_cast - ( std::shared_ptr(RB::mThis) ) ); - i = size(); - return i; - } - - - std::shared_ptr DynamicRange::sub(size_t num) const - { - return mOrig.at(num); - } - - void DynamicRange::sreplace(const std::shared_ptr in, size_t num) - { - MA_ASSERT(mOrig[num]->size() == in->size(), - std::string("replaced range has different size than given range (") - +std::to_string(mOrig[num]->size())+" vs "+std::to_string(in->size())+")"); - mOrig[num] = in; - } - - - - - DynamicRange::DynamicRange(const vector>& origs) : - RangeInterface(), - mOrig(origs) - { - mSize = 1; - for(auto& x: mOrig){ - mSize *= x->size(); - } - if(mOrig.size()){ - mEmpty = false; - } - } - - - - const vector >& DynamicRange::orig() const - { - return mOrig; - } - -} // end namespace CNORXZ - diff --git a/orig/lib/ranges/multi_range_factory_product_map.cc b/orig/lib/ranges/multi_range_factory_product_map.cc deleted file mode 100644 index 1597ddf..0000000 --- a/orig/lib/ranges/multi_range_factory_product_map.cc +++ /dev/null @@ -1,8 +0,0 @@ - -#include "ranges/multi_range_factory_product_map.h" -#include "ranges/ranges_header.cc.h" - -namespace CNORXZ -{ - std::map,vector > MultiRangeFactoryProductMap::mAleadyCreated; -} diff --git a/orig/lib/ranges/range_types/space_range.cc b/orig/lib/ranges/range_types/space_range.cc deleted file mode 100644 index 39a3257..0000000 --- a/orig/lib/ranges/range_types/space_range.cc +++ /dev/null @@ -1,121 +0,0 @@ - -#include "ranges/rheader.h" -#include "ranges/x_to_string.h" -#include "ranges/ranges_header.cc.h" - -namespace CNORXZ -{ - std::shared_ptr mkPSPACE(const char* dp, size_t size) - { - size_t max = *reinterpret_cast(dp); - return std::make_shared(max); - } - - /******************** - * GenSingleRange * - ********************/ - - GenSingleRangeFactory::GenSingleRangeFactory(size_t size) - { - // Quasi Singleton - if(not mProd){ - mProd = std::shared_ptr( new GenSingleRange(size) ); - setSelf(); - } - } - - std::shared_ptr GenSingleRangeFactory::create() - { - return mProd; - } - - /******************** - * GenSingleRange * - ********************/ - - GenSingleRange::GenSingleRange(size_t size) : mSize(size) { } - - int GenSingleRange::get(size_t pos) const - { - return pos > mSize / 2 ? pos - mSize : pos; - } - - size_t GenSingleRange::getMeta(int metaPos) const - { - return metaPos < 0 ? metaPos + mSize : metaPos; - } - - size_t GenSingleRange::size() const - { - return mSize; - } - - size_t GenSingleRange::dim() const - { - return 1; - } - - SpaceType GenSingleRange::spaceType() const - { - return SpaceType::PSPACE; - } - - vector GenSingleRange::typeNum() const - { - return {NumTypeMap::num()}; - } - - size_t GenSingleRange::cmeta(char* target, size_t pos) const - { - *reinterpret_cast(target) = get(pos); - return sizeof(int); - } - - size_t GenSingleRange::cmetaSize() const - { - return sizeof(int); - } - - std::string GenSingleRange::stringMeta(size_t pos) const - { - return std::to_string(get(pos)); - } - - vector GenSingleRange::data() const - { - DataHeader h = dataHeader(); - vector out; - out.reserve(h.metaSize + sizeof(DataHeader)); - char* hcp = reinterpret_cast(&h); - out.insert(out.end(), hcp, hcp + sizeof(DataHeader)); - const char* scp = reinterpret_cast(&mSize); - out.insert(out.end(), scp, scp + h.metaSize); - return out; - } - - DataHeader GenSingleRange::dataHeader() const - { - DataHeader h; - h.spaceType = static_cast( SpaceType::PSPACE ); - h.metaSize = sizeof(size_t); - h.multiple = 0; - return h; - } - - typename GenSingleRange::IndexType GenSingleRange::begin() const - { - GenSingleIndex i( std::dynamic_pointer_cast > - ( std::shared_ptr( RB::mThis ) ) ); - i = 0; - return i; - } - - typename GenSingleRange::IndexType GenSingleRange::end() const - { - GenSingleIndex i( std::dynamic_pointer_cast > - ( std::shared_ptr( RB::mThis ) ) ); - i = size(); - return i; - } -} - diff --git a/orig/lib/ranges/range_types/spin_range.cc b/orig/lib/ranges/range_types/spin_range.cc deleted file mode 100644 index 40770fd..0000000 --- a/orig/lib/ranges/range_types/spin_range.cc +++ /dev/null @@ -1,128 +0,0 @@ - -#include "ranges/rheader.h" -#include "ranges/x_to_string.h" -#include "ranges/ranges_header.cc.h" - -namespace CNORXZ -{ - std::shared_ptr mkSPIN(const char* dp, size_t size) - { - return std::make_shared(); - } - - /******************** - * GenSingleRange * - ********************/ - - GenSingleRangeFactory::GenSingleRangeFactory() - { - // Quasi Singleton - if(not mProd){ - mProd = std::shared_ptr( new GenSingleRange() ); - setSelf(); - } - } - - std::shared_ptr GenSingleRangeFactory::create() - { - return mProd; - } - - /******************** - * GenSingleRange * - ********************/ - - size_t GenSingleRange::get(size_t pos) const - { - return pos; - } - - size_t GenSingleRange::getMeta(size_t metaPos) const - { - return metaPos; - } - - size_t GenSingleRange::size() const - { - return mSpinNum; - } - - size_t GenSingleRange::dim() const - { - return 1; - } - - SpaceType GenSingleRange::spaceType() const - { - return SpaceType::SPIN; - } - - vector GenSingleRange::typeNum() const - { - return {NumTypeMap::num()}; - } - - size_t GenSingleRange::cmeta(char* target, size_t pos) const - { - *reinterpret_cast(target) = pos; - return sizeof(size_t); - } - - size_t GenSingleRange::cmetaSize() const - { - return sizeof(size_t); - } - - std::string GenSingleRange::stringMeta(size_t pos) const - { - return std::to_string(get(pos)); - } - - vector GenSingleRange::data() const - { - DataHeader h = dataHeader(); - vector out; - out.reserve(h.metaSize + sizeof(DataHeader)); - char* hcp = reinterpret_cast(&h); - out.insert(out.end(), hcp, hcp + sizeof(DataHeader)); - return out; - } - - DataHeader GenSingleRange::dataHeader() const - { - DataHeader h; - h.spaceType = static_cast( SpaceType::SPIN ); - h.metaSize = 0; - h.multiple = 0; - return h; - } - - typename GenSingleRange::IndexType GenSingleRange::begin() const - { - GenSingleIndex i( std::dynamic_pointer_cast > - ( std::shared_ptr( RB::mThis ) ) ); - i = 0; - return i; - } - - typename GenSingleRange::IndexType GenSingleRange::end() const - { - GenSingleIndex i( std::dynamic_pointer_cast > - ( std::shared_ptr( RB::mThis ) ) ); - i = size(); - return i; - } - - // put this in the interface class !!! - /* - std::shared_ptr GenSingleRange::index() const - { - typedef IndexWrapper IW; - return std::make_shared - ( std::make_shared - ( std::dynamic_pointer_cast > - ( std::shared_ptr( RB::mThis ) ) ) ); - } - */ -} - diff --git a/orig/lib/ranges/ranges_deserialize_legacy.cc b/orig/lib/ranges/ranges_deserialize_legacy.cc deleted file mode 100644 index 432dbb5..0000000 --- a/orig/lib/ranges/ranges_deserialize_legacy.cc +++ /dev/null @@ -1,175 +0,0 @@ - -namespace CNORXZ -{ - - template - using STP = std::tuple...>; - - typedef vector > RVEC; - - template - inline bool compareSpaceTypes(const RVEC& rvec) - { - return RangeHelper::compareSpaceTypes(rvec); - } - - template - inline bool setFactory(const RVEC& rvec, std::shared_ptr& fptr) - { - if(compareSpaceTypes(rvec)) { - STP stp; - RangeHelper::setSpace(rvec, stp); - fptr = std::make_shared >(stp); - return true; - } - else { - return false; - } - } - - size_t indexId() - { - static size_t id = 0; - ++id; - return id; - } - - std::shared_ptr mkMULTI(char const** dp, size_t metaSize) - { - std::shared_ptr out = nullptr; - RVEC rvec(metaSize); - for(size_t i = 0; i != metaSize; ++i){ - auto ff = createRangeFactory(dp); - rvec[i] = ff->create(); - } - - if(metaSize == 0){ - assert(0); - } - else if(metaSize == 1) { -#define register_multi1(TT0) if(setFactory(rvec, out)) {} else -#include "ranges/multi_range_register.h" -#undef register_multi1 - assert(0); - } - else if(metaSize == 2) { -#define register_multi2(TT0,TT1) if(setFactory(rvec, out)) {} else -#include "ranges/multi_range_register.h" -#undef register_multi2 - assert(0); - } - else if(metaSize == 3) { -#define register_multi3(TT0,TT1,TT2) if(setFactory(rvec, out)) {} else -#include "ranges/multi_range_register.h" -#undef register_multi3 - assert(0); - } - else if(metaSize == 4) { -#define register_multi4(TT0,TT1,TT2,TT3) if(setFactory(rvec, out)) {} else -#include "ranges/multi_range_register.h" -#undef register_multi4 - assert(0); - } - else { - assert(0); - } - - return out; - } - - std::shared_ptr mkANONYMOUS(char const** dp, size_t metaSize) - { - std::shared_ptr out = nullptr; - auto arf = std::make_shared(); - for(size_t i = 0; i != metaSize; ++i){ - auto ff = createRangeFactory(dp); - arf->append( ff->create() ); - } - out = arf; - return out; - } - - - std::shared_ptr mkANY(int metaType, size_t metaSize, char const** dp) - { - std::shared_ptr out = nullptr; - if(metaType == -1){ - assert(0); - } -#define register_type(x) else if(x == metaType) { \ - vector::type> vd; \ - metaCat(vd, *dp, metaSize); \ - out = std::make_shared::type, \ - SpaceType::ANY> >(vd); } -#include "ranges/type_map.h" -#undef register_type - else { - assert(0); - } - return out; - } - - std::shared_ptr createSingleRangeFactory(const vector*& d, int metaType, size_t size) - { - std::shared_ptr out = nullptr; - if(metaType == -1){ - assert(0); - } -#define register_type(x) else if(x == metaType) { \ - vector::type> vd(size); \ - std::transform(d,d+size,vd.begin(), \ - [](const vector& c) \ - { assert(c.size() == sizeof(TypeMap::type)); \ - return *reinterpret_cast::type const*>(c.data()); }); \ - out = std::make_shared::type, \ - SpaceType::ANY> >(vd); } -#include "ranges/type_map.h" -#undef register_type - else { - assert(0); - } - return out; - } - - std::shared_ptr createRangeFactory(char const** dp) - { - DataHeader h = *reinterpret_cast(*dp); - *dp += sizeof(DataHeader); - - std::shared_ptr out = nullptr; - - if(h.multiple != 0){ - if(h.spaceType == static_cast( SpaceType::ANY )) { - // multi range - out = mkMULTI(dp, h.metaSize); - } - else if(h.spaceType == static_cast( SpaceType::ANON ) ) { - // anonymous range - out = mkANONYMOUS(dp, h.metaSize); - } - else { - assert(0); - } - } - else { - if(h.spaceType == static_cast( SpaceType::ANY ) ) { - // generic single range - out = mkANY(h.metaType, h.metaSize, dp); - } - else if(h.spaceType == static_cast( SpaceType::NONE ) ) { - // classic range - size_t size = *reinterpret_cast(*dp); - out = std::make_shared >(size); - } -#define include_range_type(x,n) else if(h.spaceType == static_cast( SpaceType::x ) ) { \ - out = mk##x(*dp, h.metaSize); } -#include "ranges/range_types/header.h" -#undef inlcude_range_type - else { - assert(0); - } - *dp += h.metaSize; - } - return out; - } -} diff --git a/orig/lib/ranges/type_map.cc b/orig/lib/ranges/type_map.cc deleted file mode 100644 index 9796b38..0000000 --- a/orig/lib/ranges/type_map.cc +++ /dev/null @@ -1,41 +0,0 @@ - -#include "ranges/type_map.h" -#include "ranges/ranges_header.cc.h" - -namespace CNORXZ -{ -#define XCOMMAX() , -#define include_type(t,n) template struct TypeMap; \ - template struct NumTypeMap; - -#include "ranges/type_register.h" - /* - include_type(size_t,1) - include_type(int,2) - include_type(char,3) - include_type(float,4) - include_type(double,5) - include_type(std::string,6) - include_type(vector,101) - include_type(vector,102) - include_type(vector,105) - include_type(vector,106) - include_type(std::array,201) - include_type(std::array,202) - include_type(std::array,205) - include_type(std::array,301) - include_type(std::array,302) - include_type(std::array,305) - include_type(std::array,401) - include_type(std::array,402) - include_type(std::array,405) - include_type(std::array,502) - include_type(std::array,602) - include_type(std::array,702) - include_type(std::array,802) - include_type(std::array,902) - */ -#undef include_type -#undef XCOMMAX - -} diff --git a/src/name_map.txt b/src/name_map.txt deleted file mode 100644 index f38a7a5..0000000 --- a/src/name_map.txt +++ /dev/null @@ -1,7 +0,0 @@ -:: Rename MultiArray library in CNORXZ (Containers with Native Operation Routines by XZ (chizeta)) -MultiArrayTools -> CNORXZ -MultiArray -> Array -multi_array_*.{cc,h} -> cxz_*.{cc,h} -*ma* -> *cxz* -libmultiarray -> libcnorxz -...!!!