This commit is contained in:
Christian Zimmermann 2022-09-12 01:09:51 +02:00
parent f6725f5356
commit 10db0908e0
17 changed files with 556 additions and 804 deletions

View file

@ -1,2 +1,3 @@
#include "dtype.cc.h"
#include "obj_handle.cc.h"

View file

@ -8,5 +8,7 @@
#include "macros.h"
#include "assert.h"
#include "types.h"
#include "obj_handle.h"
#include "dtype.h"
#endif

View file

@ -0,0 +1,62 @@
#ifndef __cxz_obj_handle_cc_h__
#define __cxz_obj_handle_cc_h__
#include "obj_handle.h"
namespace CNORXZ
{
template <typename T>
ObjHandle<T>::ObjHandle() : mC(std::make_unique<T>()) {}
template <typename T>
ObjHandle<T>::ObjHandle(const T& a) : mC(std::make_unique<T>(a)) {}
template <typename T>
ObjHandle<T>::ObjHandle(const ObjHandle& a) : mC(std::make_unique<T>(*a.mC)) {}
template <typename T>
ObjHandle<T>::ObjHandle(ObjHandle&& a) : mC(a.mC) {}
template <typename T>
ObjHandle& ObjHandle<T>::operator=(const ObjHandle& a)
{
mC = std::make_unique<T>(*a.mC);
return *this;
}
template <typename T>
ObjHandle& ObjHandle<T>::operator=(ObjHandle&& a)
{
mC = a.mC;
return *this;
}
template <typename T>
T& ObjHandle<T>::operator*()
{
return *mC;
}
template <typename T>
T* ObjHandle<T>::operator->()
{
return &*mC;
}
template <typename T>
const T& ObjHandle<T>::operator*() const
{
return *mC;
}
template <typename T>
const T* ObjHandle<T>::operator->() const
{
return &*mC;
}
}
#endif

View file

@ -0,0 +1,35 @@
#ifndef __cxz_obj_handle_h__
#define __cxz_obj_handle_h__
#include "types.h"
namespace CNORXZ
{
// Pointer wrapper for directly handling objects via abstract base class;
// Provides appropriate copy implementation
template <typename T>
class ObjHandle
{
private:
std::unique_ptr<T> mC;
public:
ObjHandle();
ObjHandle(const T& a);
ObjHandle(const ObjHandle& a);
ObjHandle(ObjHandle&& a);
ObjHandle& operator=(const ObjHandle& a);
ObjHandle& operator=(ObjHandle&& a);
T& operator*();
T* operator->();
const T& operator*() const;
const T* operator->() const;
};
}
#endif

View file

@ -31,6 +31,12 @@ namespace CNORXZ
template <typename T>
using Sptr = std::shared_ptr<T>;
template <typename T>
using Wptr = std::weak_ptr<T>;
template <typename T>
using Uptr = std::unique_ptr<T>;
template <typename... T>
using Tuple = std::tuple<T...>;
@ -49,6 +55,10 @@ namespace CNORXZ
// definition: base/dtype.h
class DType;
// definition: base/obj_handle.h
template <typename T>
class ObjHandle;
// definition: memory/allocator.h
template <typename T>
class Allocator;

View file

@ -1,87 +1,106 @@
//#ifdef include_range_type
//include_range_type(NONE,0)
//#else
#ifndef include_range_type
#ifdef __cxz_ranges_header__
// assert, that this is only used within range_types/header.h
#ifndef __cxz_range_type_classic_def__
#define __cxz_range_type_classic_def__
#include "base/base.h"
#include "ranges/index_base.h"
#include "ranges/range_base.h"
#include "xfor/for_type.h"
namespace CNORXZ
{
typedef GenSingleIndex<size_t,SpaceType::NONE,MUI> ClassicIndex;
template <>
class GenSingleRangeFactory<size_t,SpaceType::NONE,MUI> : public RangeFactoryBase
class CIndex : public IndexInterface<CIndex<MetaType>,SizeT>
{
public:
typedef GenSingleRange<size_t,SpaceType::NONE,MUI> oType;
typedef IndexInterface<CIndex<SizeT>,SizeT> IB;
typedef CRange RangeType;
GenSingleRangeFactory(size_t size = 0);
std::shared_ptr<RangeBase> create();
CIndex(const RangePtr& range);
CIndex& operator=(SizeT pos);
CIndex& operator++();
CIndex& operator--();
CIndex operator+(Int n) const;
CIndex operator-(Int n) const;
CIndex& operator+=(Int n);
CIndex& operator-=(Int n);
SizeT operator*() const;
SizeT operator->() const;
Int pp(PtrId idxPtrNum);
Int mm(PtrId idxPtrNum);
SizeT dim() const; // = 1
Sptr<RangeType> range() const;
SizeT getStepSize(SizeT n) const;
String stringMeta() const;
SizeT meta() const;
CIndex& at(const SizeT& metaPos);
template <class Expr>
auto ifor(SizeT step, Expr ex) const
-> For<CIndex<SizeT>,Expr>;
template <class Expr>
auto iforh(SizeT step, Expr ex) const
-> For<CIndex<SizeT>,Expr,ForType::HIDDEN>;
template <class Expr>
auto pifor(SizeT step, Expr ex) const
-> PFor<CIndex<SizeT>,Expr>;
private:
Sptr<RangeType> mRangePtr;
};
template <>
class GenSingleRange<size_t,SpaceType::NONE,MUI> : public RangeInterface<ClassicIndex>
class CRangeFactory : public RangeFactoryBase
{
public:
typedef CRange oType;
CRangeFactory(SizeT size);
CRangeFactory(SizeT size, RangePtr ref);
protected:
virtual void make() override;
private:
RangePtr mRef;
};
class CRange : public RangeInterface<CIndex>
{
public:
typedef RangeBase RB;
typedef typename RangeInterface<GenSingleIndex<size_t,SpaceType::NONE,MUI> >::IndexType IndexType;
typedef GenSingleRange<size_t,SpaceType::NONE,MUI> RangeType;
typedef size_t MetaType;
typedef GenSingleRangeFactory<size_t,SpaceType::NONE,MUI> FType;
typedef CIndex IndexType;
typedef CRangeFactory 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<size_t> 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<char> data() const final;
size_t get(size_t pos) const;
size_t getMeta(size_t metaPos) const;
friend CRangeFactory;
virtual SizeT size() const final;
virtual SizeT dim() const final;
virtual String stringMeta(SizeT pos) const final;
virtual IndexType begin() const final;
virtual IndexType end() const final;
//virtual std::shared_ptr<VIWB> index() const final;
friend GenSingleRangeFactory<size_t,SpaceType::NONE,MUI>;
static constexpr bool defaultable = true;
static constexpr size_t ISSTATIC = 0;
static constexpr size_t SIZE = MUI;
static constexpr bool HASMETACONT = false;
static GenSingleRangeFactory<size_t,SpaceType::NONE,MUI> factory(size_t size = 0)
{ return GenSingleRangeFactory<size_t,SpaceType::NONE,MUI>(size); }
SizeT get(SizeT pos) const;
SizeT getMeta(SizeT metaPos) const;
protected:
size_t mSize = 0;
CRange() = default;
CRange(const CRange& in) = delete;
CRange(SizeT size);
GenSingleRange() = default;
GenSingleRange(const GenSingleRange& in) = delete;
GenSingleRange(size_t size);
SizeT mSize = 0;
};
typedef GenSingleRange<size_t,SpaceType::NONE,MUI> ClassicRange;
typedef GenSingleRangeFactory<size_t,SpaceType::NONE,MUI> ClassicRF;
template <>
Sptr<CRange> rangeCast<CRange>(const RangePtr& r);
}
#endif // #ifndef __cxz_range_type_classic_def__
#endif // #ifdef __cxz_ranges_header__
#endif // #ifdef include_range_type
#endif

View file

@ -18,14 +18,14 @@ namespace CNORXZ
template <class I, typename MetaType>
IndexInterface<I,MetaType>::IndexInterface(const IndexInterface& in) :
mRangePtr(in.mRangePtr), mPos(in.mPos), mMax(in.mMax)
mPos(in.mPos)
{
mPtrNum = reinterpret_cast<PtrId>(this);
}
template <class I, typename MetaType>
IndexInterface<I,MetaType>::IndexInterface(IndexInterface&& in) :
mRangePtr(in.mRangePtr), mPos(in.mPos), mMax(in.mMax)
mPos(in.mPos)
{
mPtrNum = reinterpret_cast<PtrId>(this);
}
@ -35,7 +35,6 @@ namespace CNORXZ
{
mRangePtr = in.mRangePtr;
mPos = in.mPos;
mMax = in.mMax;
return *this;
}
@ -44,13 +43,12 @@ namespace CNORXZ
{
mRangePtr = in.mRangePtr;
mPos = in.mPos;
mMax = in.mMax;
return *this;
}
template <class I, typename MetaType>
IndexInterface<I,MetaType>::IndexInterface(const RangePtr& range, SizeT pos) :
mRangePtr(range), mPos(pos), mMax(mRangePtr->size())
IndexInterface<I,MetaType>::IndexInterface(SizeT pos) :
mPos(pos)
{
mPtrNum = reinterpret_cast<PtrId>(this);
}
@ -58,13 +56,13 @@ namespace CNORXZ
template <class I, typename MetaType>
bool IndexInterface<I,MetaType>::operator==(const IndexInterface& in) const
{
return in.mPos == mPos and in.mRangePtr.get() == mRangePtr.get();
return in.mPos == mPos and *in.range() == *range();
}
template <class I, typename MetaType>
bool IndexInterface<I,MetaType>::operator!=(const IndexInterface& in) const
{
return in.mPos != mPos or in.mRangePtr.get() != mRangePtr.get();
return in.mPos != mPos or *in.range() != *range();
}
template <class I, typename MetaType>

View file

@ -29,7 +29,7 @@ namespace CNORXZ
Int operator-(const IndexInterface& i) const { return mPos - i.mPos; }
SizeT pos() const;
SizeT max() const;
SizeT max() const { return THIS().max(); }
PtrId ptrId() const;
bool operator==(const IndexInterface& in) const;
@ -49,7 +49,7 @@ namespace CNORXZ
SizeT getStepSize(SizeT n) const { return THIS().getStepSize(n); }
String stringMeta() const { return THIS().stringMeta(); }
MetaType meta() const { return THIS().meta(); }
auto meta() const { return THIS().meta(); }
I& at(const MetaType& meta) { return THIS().at(meta); }
template <class Expr>
@ -70,11 +70,10 @@ namespace CNORXZ
IndexInterface& operator=(const IndexInterface& in);
IndexInterface(IndexInterface&& in);
IndexInterface& operator=(IndexInterface&& in);
IndexInterface(const RangePtr& range, SizeT pos);
IndexInterface(SizeT pos);
IndexPtr mRel = nullptr;
SizeT mPos = 0;
SizeT mMax = 0;
PtrId mPtrId = 0;
};

View file

@ -0,0 +1,23 @@
#ifndef __cxz_range_base_cc_h__
#define __cxz_range_base_cc_h__
#include "range_base.h"
namespace CNORXZ
{
template <class Index>
Index RangeInterface<Index>::begin() const
{
return Index(RangePtr(RB::mThis), 0);
}
template <class Index>
Index RangeInterface<Index>::end() const
{
return Index(RangePtr(RB::mThis), this->size());
}
}
#endif

View file

@ -8,35 +8,6 @@
namespace CNORXZ
{
SizeT indexId();
enum class SpaceType
{
NONE = 0, // meta data is that of a classic range, i.e. 0,1,2,...,N-1
ANY = 1, // meta data is arbitrary, i.e. explicitly stored; range could be multiple
#define include_range_type(x,n) x = n,
#include "range_types/header.h"
#undef include_range_type
ANON = -1, // anonymous content
DYN = -3 // dynamic content
};
struct DataHeader
{
public:
static constexpr SizeT VERSION = 1; // fixed by version of this repository !
private:
SizeT version = VERSION;
public:
int spaceType = static_cast<int>( SpaceType::NONE );
SizeT metaSize = 0; // size of meta data
int multiple = 0; // = 1 if multi range
int metaType = 0; // type of meta data
inline SizeT v() const { return version; }
};
typedef Sptr<RangeBase> RangePtr;
class RangeFactoryBase
{
public:
@ -57,6 +28,7 @@ namespace CNORXZ
private:
// also add single ranges here (PtrId -> own)
// rangeCast: PtrId -> original Range
static Map<TypeInfo,Map<Vector<PtrId>,RangePtr>> sCreated;
};
@ -77,21 +49,12 @@ namespace CNORXZ
bool operator!=(const RangeBase& in) const;
virtual TypeInfo type() const = 0;
PtrId id() const;
XIndexPtr beginX() const;
XIndexPtr endX() const;
virtual Vector<SizeT> typeNum() const = 0;
virtual SizeT cmeta(char* target, SizeT pos) const = 0;
virtual SizeT cmetaSize() const = 0;
virtual TypeInfo metaType() const = 0;
virtual String stringMeta(SizeT pos) const = 0;
virtual Vector<char> data() const = 0; // usefull when writing to files, etc...
virtual SpaceType spaceType() const = 0;
virtual DataHeader dataHeader() const = 0;
virtual RangePtr sub(SizeT num) const { return RangePtr(); }
PtrId id() const;
XIndexPtr begin() const;
XIndexPtr end() const;
friend RangeFactoryBase;
@ -101,30 +64,23 @@ namespace CNORXZ
std::weak_ptr<RangeBase> mThis;
};
template <class Index>
inline Sptr<IndexWrapperBase> mkIndexWrapper(const Index& i);
template <class Index>
class RangeInterface : public RangeBase
{
public:
//typedef typename Index::MetaType MetaType;
typedef Index IndexType;
typedef RangeBase RB;
static constexpr SpaceType STYPE = IndexType::STYPE;
virtual Index begin() const = 0;
virtual Index end() const = 0;
Sptr<Index> beginPtr() const { return std::make_shared<Index>(this->begin()); }
Sptr<Index> endPtr() const { return std::make_shared<Index>(this->end()); }
virtual Sptr<IndexWrapperBase> aindex() const override final
{ return mkIndexWrapper(this->begin()); }
Index begin() const;
Index end() const;
protected:
RangeInterface() = default;
};
template <class Range>
Sptr<Range> rangeCast(const RangePtr r);
RangePtr operator*(const RangePtr& a, const RangePtr& b); // -> Ptr to MultiRange
}

View file

@ -0,0 +1,255 @@
#ifndef __cxz_urange_cc_h__
#define __cxz_urange_cc_h__
#include <functional>
#include <algorithm>
#include "urange.h"
namespace CNORXZ
{
/*****************
* UIndex *
*****************/
namespace
{
template <typename MetaType>
Sptr<URange<MetaType>> rc(const RangePtr r)
{
if(typeid(URange<MetaType>) == r.type()){
return std::dynamic_pointer_cast<URange<MetaType>>(r)
}
else {
return rangeCast<URange<MetaType>>(r);
}
}
}
template <typename MetaType>
UIndex<MetaType>::UIndex(const RangePtr& range) :
IndexInterface<UIndex<MetaType>,MetaType>(0),
mRange(rc<MetaType>(range)),
mMetaPtr(&get(0))
{}
template <typename MetaType>
UIndex<MetaType>& UIndex<MetaType>::operator=(size_t pos)
{
IB::mPos = pos;
return *this;
}
template <typename MetaType>
UIndex<MetaType>& UIndex<MetaType>::operator++()
{
++IB::mPos;
return *this;
}
template <typename MetaType>
UIndex<MetaType>& UIndex<MetaType>::operator--()
{
--IB::mPos;
return *this;
}
template <typename MetaType>
int UIndex<MetaType>::pp(std::intptr_t idxPtrNum)
{
++(*this);
return 1;
}
template <typename MetaType>
int UIndex<MetaType>::mm(std::intptr_t idxPtrNum)
{
--(*this);
return 1;
}
template <typename MetaType>
String UIndex<MetaType>::stringMeta() const
{
return toString(this->meta());
}
template <typename MetaType>
MetaType& UIndex<MetaType>::meta() const
{
return mSpace[IB::mPos];
}
template <typename MetaType>
UIndex<MetaType>& UIndex<MetaType>::at(const MetaType& metaPos)
{
(*this) = mRangePtr->getMeta(metaPos);
return *this;
}
template <typename MetaType>
size_t UIndex<MetaType>::dim() // = 1
{
return 1;
}
template <typename MetaType>
Sptr<URange<MetaType>> UIndex<MetaType>::range()
{
return mRangePtr;
}
template <typename MetaType>
size_t UIndex<MetaType>::getStepSize(size_t n)
{
return 1;
}
template <typename MetaType>
template <class Expr>
auto UIndex<MetaType>::ifor(size_t step, Expr ex) const
-> For<URange<MetaType>,Expr>
{
return For<UIndex<MetaType>,Expr>(this, step, ex);
}
template <typename MetaType>
template <class Expr>
auto UIndex<MetaType>::iforh(size_t step, Expr ex) const
-> For<URange<MetaType>,Expr,ForType::HIDDEN>
{
return For<UIndex<MetaType>,Expr,ForType::HIDDEN>(this, step, ex);
}
template <typename MetaType>
template <class Expr>
auto UIndex<MetaType>::pifor(size_t step, Expr ex) const
-> PFor<URange<MetaType>,Expr>
{
return PFor<UIndex<MetaType>,Expr>(this, step, ex);
}
/********************
* SingleRange *
********************/
template <typename MetaType>
URangeFactory<MetaType>::URangeFactory(const Vector<MetaType>& space) :
mSpace(space) {}
template <typename MetaType>
URangeFactory<MetaType>::URangeFactory(Vector<MetaType>&& space) :
mSpace(space) {}
template <typename MetaType>
URangeFactory<MetaType>::URangeFactory(const Vector<MetaType>& space, const RangePtr& ref) :
mSpace(space), mRef(ref) {}
template <typename MetaType>
URangeFactory<MetaType>::URangeFactory(Vector<MetaType>&& space, const RangePtr& ref) :
mSpace(space), mRef(ref) {}
template <typename MetaType>
void URangeFactory<MetaType>::make()
{
if(mRef != nullptr) {
mProd = this->fromCreated[typeid(oType)][mRef->id()];
}
if(mProd == nullptr){
RangePtr key = mProd = std::shared_ptr<oType>
( new URange<MetaType>( std::move(mSpace) ) );
if(mRef != nullptr) { key = mRef->id(); }
this->addToCreated(typeid(oType), { key }, mProd);
}
}
/********************
* SingleRange *
********************/
template <typename MetaType>
URange<MetaType>::URange(const Vector<MetaType>& space) :
RangeInterface<URange<MetaType>>(),
mSpace(space)
{
std::sort(mSpace.begin(), mSpace.end(), std::less<MetaType>());
auto itdupl = std::adjacent_find(mSpace.begin(), mSpace.end());
CXZ_ASSERT(itdupl == mSpace.end(), "found duplicate: " << *itdupl);
}
template <typename MetaType>
URange<MetaType>::URange(Vector<MetaType>&& space) :
RangeInterface<URange<MetaType>>(),
mSpace(space)
{
std::sort(mSpace.begin(), mSpace.end(), std::less<MetaType>());
auto itdupl = std::adjacent_find(mSpace.begin(), mSpace.end());
CXZ_ASSERT(itdupl == mSpace.end(), "found duplicate: " << *itdupl);
}
template <typename MetaType>
const MetaType& URange<MetaType>::get(size_t pos) const
{
return mSpace[pos];
}
template <typename MetaType>
SizeT URange<MetaType>::getMeta(const MetaType& meta) const
{
auto b = mSpace.begin();
auto e = mSpace.end();
return std::lower_bound(b, e, meta, std::less<MetaType>()) - b;
}
template <typename MetaType>
SizeT URange<MetaType>::size() const
{
return mSpace.size();
}
template <typename MetaType>
SizeT URange<MetaType>::dim() const
{
return 1;
}
template <typename MetaType>
String URange<MetaType>::stringMeta(SizeT pos) const
{
return toString(this->get(pos));
}
template <typename MetaType>
typename URange<MetaType>::IndexType URange<MetaType>::begin() const
{
UIndex<MetaType> i( std::dynamic_pointer_cast<URange<MetaType> >
( std::shared_ptr<RangeBase>( RB::mThis ) ) );
i = 0;
return i;
}
template <typename MetaType>
typename URange<MetaType>::IndexType URange<MetaType>::end() const
{
UIndex<MetaType> i( std::dynamic_pointer_cast<URange<MetaType> >
( std::shared_ptr<RangeBase>( RB::mThis ) ) );
i = this->size();
return i;
}
/*******************
* Range Casts *
*******************/
template <typename MetaType>
Sptr<URange<MetaType>> rangeCast<URange<MetaType>>(const RangePtr& r)
{
CXZ_ERROR("to be implemented...");
return nullptr;
}
}
#endif

View file

@ -40,7 +40,7 @@ namespace CNORXZ
SizeT getStepSize(SizeT n) const;
String stringMeta() const;
MetaType meta() const;
const MetaType& meta() const;
UIndex& at(const MetaType& metaPos);
template <class Expr>
@ -64,12 +64,18 @@ namespace CNORXZ
class URangeFactory : public RangeFactoryBase
{
public:
URangeFactory() = delete;
URangeFactory(const Vector<U>& space);
URangeFactory(Vector<U>&& space);
URangeFactory(const Vector<MetaType>& space);
URangeFactory(Vector<MetaType>&& space);
URangeFactory(const Vector<MetaType>& space, const RangePtr& ref);
URangeFactory(Vector<MetaType>&& space, const RangePtr& ref);
protected:
void make();
URangeFactory() = default;
virtual void make() override;
private:
Vector<MetaType> mSpace;
RangePtr mRef = nullptr;
};
template <typename MetaType>
@ -80,342 +86,30 @@ namespace CNORXZ
typedef UIndex<MetaType> IndexType;
typedef URangeFactory<MetaType> FType;
friend URangeFactory<MetaType>;
virtual SizeT size() const final;
virtual SizeT dim() const final;
virtual std::string stringMeta(SizeT pos) const final;
const MetaType& get(SizeT pos) const;
SizeT getMeta(const MetaType& metaPos) const;
virtual String stringMeta(SizeT pos) const final;
virtual IndexType begin() const final;
virtual IndexType end() const final;
friend URangeFactory<MetaType>;
const MetaType& get(SizeT pos) const;
SizeT getMeta(const MetaType& metaPos) const;
protected:
URange() = delete;
URange(const URange& in) = delete;
URange(const vector<MetaType>& space);
URange(vector<MetaType>&& space);
URange(const Vector<MetaType>& space);
URange(Vector<MetaType>&& space);
Vector<MetaType> mSpace; // SORTED!!!
Vector<MetaType> mSpace;
};
template <typename MetaType>
Sptr<URange<MetaType>> rangeCast<URange<MetaType>>(const RangePtr& r);
}
/* ========================= *
* --- TEMPLATE CODE --- *
* ========================= */
namespace CNORXZ
{
/*****************
* UIndex *
*****************/
template <typename U, SpaceType TYPE, size_t S>
GenSingleIndex<U,TYPE,S>::GenSingleIndex(const std::shared_ptr<GenSingleRange<U,TYPE,S> >& range) :
IndexInterface<GenSingleIndex<U,TYPE,S>,U>(range, 0),
mExplicitRangePtr(std::dynamic_pointer_cast<RangeType>(IB::mRangePtr)),
mMetaPtr(MetaPtrHandle<GenSingleIndex<U,TYPE,S>::RangeType::HASMETACONT>::set
( dynamic_cast<RangeType*>(IB::mRangePtr.get() ) ) ) {}
template <typename U, SpaceType TYPE, size_t S>
IndexType GenSingleIndex<U,TYPE,S>::type() const
{
return IndexType::SINGLE;
}
template <typename U, SpaceType TYPE, size_t S>
GenSingleIndex<U,TYPE,S>& GenSingleIndex<U,TYPE,S>::operator=(size_t pos)
{
IB::mPos = pos;
return *this;
}
template <typename U, SpaceType TYPE, size_t S>
GenSingleIndex<U,TYPE,S>& GenSingleIndex<U,TYPE,S>::operator++()
{
++IB::mPos;
return *this;
}
template <typename U, SpaceType TYPE, size_t S>
GenSingleIndex<U,TYPE,S>& GenSingleIndex<U,TYPE,S>::operator--()
{
--IB::mPos;
return *this;
}
template <typename U, SpaceType TYPE, size_t S>
int GenSingleIndex<U,TYPE,S>::pp(std::intptr_t idxPtrNum)
{
++(*this);
return 1;
}
template <typename U, SpaceType TYPE, size_t S>
int GenSingleIndex<U,TYPE,S>::mm(std::intptr_t idxPtrNum)
{
--(*this);
return 1;
}
template <typename U, SpaceType TYPE, size_t S>
std::string GenSingleIndex<U,TYPE,S>::stringMeta() const
{
return std::dynamic_pointer_cast<GenSingleRange<U,TYPE,S> const>( IB::mRangePtr )->stringMeta(IB::mPos);
}
template <typename U, SpaceType TYPE, size_t S>
U GenSingleIndex<U,TYPE,S>::meta() const
{
return MetaPtrHandle<GenSingleIndex<U,TYPE,S>::RangeType::HASMETACONT>::getMeta
( mMetaPtr, IB::mPos, mExplicitRangePtr );
}
template <typename U, SpaceType TYPE, size_t S>
const U* GenSingleIndex<U,TYPE,S>::metaPtr() const
{
return mMetaPtr;
}
template <typename U, SpaceType TYPE, size_t S>
bool GenSingleIndex<U,TYPE,S>::isMeta(const U& metaPos) const
{
return mExplicitRangePtr->isMeta(metaPos);
}
template <typename U, SpaceType TYPE, size_t S>
GenSingleIndex<U,TYPE,S>& GenSingleIndex<U,TYPE,S>::at(const U& metaPos)
{
(*this) = std::dynamic_pointer_cast<GenSingleRange<U,TYPE,S> const>( IB::mRangePtr )->getMeta( metaPos );
return *this;
}
template <typename U, SpaceType TYPE, size_t S>
size_t GenSingleIndex<U,TYPE,S>::posAt(const U& metaPos) const
{
return std::dynamic_pointer_cast<GenSingleRange<U,TYPE,S> const>( IB::mRangePtr )->getMeta( metaPos );
}
template <typename U, SpaceType TYPE, size_t S>
size_t GenSingleIndex<U,TYPE,S>::dim() // = 1
{
return 1;
}
template <typename U, SpaceType TYPE, size_t S>
bool GenSingleIndex<U,TYPE,S>::last()
{
return IB::mPos == IB::mMax - 1;
}
template <typename U, SpaceType TYPE, size_t S>
bool GenSingleIndex<U,TYPE,S>::first()
{
return IB::mPos == 0;
}
template <typename U, SpaceType TYPE, size_t S>
std::shared_ptr<typename GenSingleIndex<U,TYPE,S>::RangeType> GenSingleIndex<U,TYPE,S>::range()
{
return mExplicitRangePtr;
}
template <typename U, SpaceType TYPE, size_t S>
template <size_t N>
void GenSingleIndex<U,TYPE,S>::getPtr() {}
template <typename U, SpaceType TYPE, size_t S>
size_t GenSingleIndex<U,TYPE,S>::getStepSize(size_t n)
{
return 1;
}
template <typename U, SpaceType TYPE, size_t S>
template <class Expr>
auto GenSingleIndex<U,TYPE,S>::ifor(size_t step, Expr ex) const
-> For<GenSingleIndex<U,TYPE,S>,Expr>
{
return For<GenSingleIndex<U,TYPE,S>,Expr>(this, step, ex);
}
template <typename U, SpaceType TYPE, size_t S>
template <class Expr>
auto GenSingleIndex<U,TYPE,S>::iforh(size_t step, Expr ex) const
-> For<GenSingleIndex<U,TYPE,S>,Expr,ForType::HIDDEN>
{
return For<GenSingleIndex<U,TYPE,S>,Expr,ForType::HIDDEN>(this, step, ex);
}
template <typename U, SpaceType TYPE, size_t S>
template <class Expr>
auto GenSingleIndex<U,TYPE,S>::pifor(size_t step, Expr ex) const
-> PFor<GenSingleIndex<U,TYPE,S>,Expr>
{
return PFor<GenSingleIndex<U,TYPE,S>,Expr>(this, step, ex);
}
/********************
* SingleRange *
********************/
template <typename U, SpaceType TYPE, size_t S>
GenSingleRangeFactory<U,TYPE,S>::GenSingleRangeFactory(const vector<U>& space)
{
mProd = std::shared_ptr<oType>( new GenSingleRange<U,TYPE,S>( space ) );
}
template <typename U, SpaceType TYPE, size_t S>
GenSingleRangeFactory<U,TYPE,S>::GenSingleRangeFactory(vector<U>&& space)
{
mProd = std::shared_ptr<oType>( new GenSingleRange<U,TYPE,S>( space ) );
}
template <typename U, SpaceType TYPE, size_t S>
std::shared_ptr<RangeBase> GenSingleRangeFactory<U,TYPE,S>::create()
{
setSelf();
return mProd;
}
/********************
* SingleRange *
********************/
template <typename U, SpaceType TYPE, size_t S>
GenSingleRange<U,TYPE,S>::GenSingleRange(const vector<U>& space) :
RangeInterface<GenSingleIndex<U,TYPE,S> >(),
mSpace(space), mMSpace(mSpace)
{
//for(size_t i = 0; i != mSpace.size(); ++i){
// mMSpace[mSpace[i]] = i;
//}
}
template <typename U, SpaceType TYPE, size_t S>
GenSingleRange<U,TYPE,S>::GenSingleRange(vector<U>&& space) :
RangeInterface<GenSingleIndex<U,TYPE,S> >(),
mSpace(space), mMSpace(mSpace) {}
template <typename U, SpaceType TYPE, size_t S>
const U& GenSingleRange<U,TYPE,S>::get(size_t pos) const
{
return mSpace[pos];
}
template <size_t SIZE>
inline size_t getStatSizeOrDyn(size_t size)
{
return SIZE;
}
template <>
inline size_t getStatSizeOrDyn<MUI>(size_t size)
{
return size;
}
template <typename U, SpaceType TYPE, size_t S>
size_t GenSingleRange<U,TYPE,S>::getMeta(const U& metaPos) const
{
return mMSpace.at(metaPos);
}
template <typename U, SpaceType TYPE, size_t S>
size_t GenSingleRange<U,TYPE,S>::size() const
{
return getStatSizeOrDyn<S>(mSpace.size());
}
template <typename U, SpaceType TYPE, size_t S>
size_t GenSingleRange<U,TYPE,S>::dim() const
{
return 1;
}
template <typename U, SpaceType TYPE, size_t S>
bool GenSingleRange<U,TYPE,S>::isMeta(const U& metaPos) const
{
return mMSpace.count(metaPos) != 0;
}
template <typename U, SpaceType TYPE, size_t S>
SpaceType GenSingleRange<U,TYPE,S>::spaceType() const
{
return TYPE;
}
template <typename U, SpaceType TYPE, size_t S>
vector<size_t> GenSingleRange<U,TYPE,S>::typeNum() const
{
return {NumTypeMap<U>::num()};
}
template <typename U, SpaceType TYPE, size_t S>
size_t GenSingleRange<U,TYPE,S>::cmeta(char* target, size_t pos) const
{
return ToCMeta<U>::apply(target, mSpace[pos]);
}
template <typename U, SpaceType TYPE, size_t S>
size_t GenSingleRange<U,TYPE,S>::cmetaSize() const
{
return ToCMeta<U>::size(mSpace[0]);
}
template <typename U, SpaceType TYPE, size_t S>
std::string GenSingleRange<U,TYPE,S>::stringMeta(size_t pos) const
{
return xToString(get(pos));
}
template <typename U, SpaceType TYPE, size_t S>
vector<char> GenSingleRange<U,TYPE,S>::data() const
{
DataHeader h = dataHeader();
vector<char> out;
out.reserve(h.metaSize + sizeof(DataHeader));
char* hcp = reinterpret_cast<char*>(&h);
out.insert(out.end(), hcp, hcp + sizeof(DataHeader));
stringCat(out, mSpace);
return out;
}
template <typename U, SpaceType TYPE, size_t S>
DataHeader GenSingleRange<U,TYPE,S>::dataHeader() const
{
DataHeader h;
h.spaceType = static_cast<int>( TYPE );
h.metaSize = metaSize(mSpace);
h.metaType = NumTypeMap<U>::num();
h.multiple = 0;
return h;
}
template <typename U, SpaceType TYPE, size_t S>
typename GenSingleRange<U,TYPE,S>::IndexType GenSingleRange<U,TYPE,S>::begin() const
{
GenSingleIndex<U,TYPE,S> i( std::dynamic_pointer_cast<GenSingleRange<U,TYPE,S> >
( std::shared_ptr<RangeBase>( RB::mThis ) ) );
i = 0;
return i;
}
template <typename U, SpaceType TYPE, size_t S>
typename GenSingleRange<U,TYPE,S>::IndexType GenSingleRange<U,TYPE,S>::end() const
{
GenSingleIndex<U,TYPE,S> i( std::dynamic_pointer_cast<GenSingleRange<U,TYPE,S> >
( std::shared_ptr<RangeBase>( RB::mThis ) ) );
i = size();
return i;
}
}
#include "range_types/header.h"
#endif

View file

@ -7,6 +7,9 @@
namespace CNORXZInternal
{
// Dynamic Ext: ObjHandl<ExtBase>
// In For Expr: try to resolve until some upper limit
struct None;
class ExtBase
@ -20,7 +23,6 @@ namespace CNORXZInternal
virtual size_t size() const = 0;
virtual const size_t& val() const = 0;
//virtual size_t rootSteps() const = 0;
virtual bool operator==(const ExtBase& in) const = 0;
virtual bool operator==(size_t in) const = 0;
@ -33,7 +35,6 @@ namespace CNORXZInternal
template <class ExtType>
const ExtType& expl() const;
virtual std::string stype() const = 0;
};
typedef std::shared_ptr<ExtBase> DExt;
@ -58,8 +59,6 @@ namespace CNORXZInternal
virtual std::shared_ptr<ExtBase> deepCopy() const override final { return std::make_shared<ExtT<ExtType>>(mExt); }
virtual size_t size() const override final { return sizeof(ExtType)/sizeof(size_t); }
//virtual size_t size() const override final { return ExtType::MExtSize(); }
//virtual size_t rootSteps() const override final;
const ExtType& ext() const { return mExt; }
virtual const size_t& val() const override final { return mExt.val(); }
virtual void zero() override final { mExt.zero(); }
@ -75,9 +74,7 @@ namespace CNORXZInternal
virtual DExt operator*(size_t in) const override final
{ return std::make_shared<ExtT<ExtType>>( mExt * in ); }
virtual std::string stype() const override final { return std::string("T[") + mExt.stype() + "]"; }
};
//class DExtT;
template <class ExtType>
DExt mkDExt(const ExtT<ExtType>& in)
@ -275,13 +272,7 @@ namespace CNORXZInternal
DExtTX& operator=(const DExtTX& in) { mNext = in.mNext; mDExt = in.mDExt->deepCopy(); return *this; }
DExtTX& operator=(DExtTX&& in) { mNext = in.mNext; mDExt = in.mDExt->deepCopy(); return *this; }
explicit DExtTX(const DExt& in) : mDExt(in) {}
/*
template <class Y>
DExtTX& operator=(const Y& y) { mDExt = std::make_shared<ExtT<Y>>(y); return *this; }
template <class Y>
DExtTX(const Y& y) : mDExt(std::make_shared<ExtT<Y>>(y)) {}
*/
bool operator==(const DExtTX& in) const
{ return *mDExt == *in.mDExt and mNext == in.mNext; }
@ -320,7 +311,6 @@ namespace CNORXZInternal
template <size_t N>
inline auto nn() const;
std::string stype() const { return std::string("D[") + mDExt->stype() + "," + mNext.stype() + "]"; }
};
typedef DExtTX<None> DExtT;

View file

@ -2,50 +2,49 @@
#ifndef __cxz_xfor_h__
#define __cxz_xfor_h__
#include <cstdlib>
#include <memory>
#include <tuple>
#include "xfor/for_type.h"
#include "xfor/for_utils.h"
#include "xfor/exttype.h"
#include "allocator.h"
#include <omp.h>
#define VCHECK(a) std::cout << __FILE__ << ": @" << __LINE__ \
<< " in " << __func__ << ": " << #a << " = " << a << std::endl;
#include "base/base.h"
#include "for_type.h"
#include "for_utils.h"
#include "exttype.h"
namespace CNORXZInternal
namespace CNORXZ
{
using namespace CNORXZ;
// 'HIDDEN FOR' CLASS for nested for loops in contractions a.s.o.
// (NO COUNTING OF MASTER POSITION !!!!!)
//typedef std::pair<size_t const*,size_t> DExt;
template <class Expr, class Pos>
class ExpressionInterface
{
public:
DEFAULT_MEMBERS(ExpressionInterface);
Expr& THIS() { return static_cast<Expr&>(*this); }
const Expr& THIS() const { return static_cast<const Expr&>(*this); }
Sptr<Expr> copy() const { THIS().copy(); }
class ExpressionBase
void operator(SizeT mlast, Pos last) { THIS()(mlast, last); }
void operator(SizeT mlast = 0) { THIS()(mlast); }
Pos rootSteps(PtrId ptrId = 0) const { return THIS().rootSteps(ptrId); }
Pos extension() const { return THIS().extenrion(); }
};
class XprBase : public ExpressionInterface<XprBase,Dext>
{
public:
ExpressionBase() = default;
ExpressionBase(const ExpressionBase& in) = default;
ExpressionBase(ExpressionBase&& in) = default;
ExpressionBase& operator=(const ExpressionBase& in) = default;
ExpressionBase& operator=(ExpressionBase&& in) = default;
DEFAULT_MEMBERS(XprBase);
//virtual size_t divResid() const { return 1; }
virtual std::intptr_t vI() const { return 0; }
virtual Sptr<XprBase> copy() const = 0;
virtual std::shared_ptr<ExpressionBase> deepCopy() const = 0;
virtual void operator()(size_t mlast, DExt last) = 0;
virtual void operator()(size_t mlast = 0) = 0;
virtual DExt dRootSteps(std::intptr_t iPtrNum = 0) const = 0;
virtual DExt dExtension() const = 0;
virtual void operator()(SizeT mlast, DExt last) = 0;
virtual void operator()(SizeT mlast) = 0;
virtual DExt rootSteps(PtrId iPtrNum = 0) const = 0;
virtual DExt extension() const = 0;
};
@ -77,80 +76,6 @@ namespace CNORXZInternal
}
};
template <size_t ISSTATIC>
struct ForBound
{
template <size_t BOUND, size_t DIV = 1>
static inline size_t bound(size_t bound)
{
return bound / DIV;
}
};
template <>
struct ForBound<1>
{
template <size_t BOUND, size_t DIV = 1>
static constexpr size_t bound(size_t bound)
{
return BOUND / DIV;
}
};
template <class IndexClass, class Expr>
class SingleExpression : public ExpressionBase
{
private:
SingleExpression() = default;
const IndexClass* mIndPtr;
size_t mSPos;
size_t mMax;
Expr mExpr;
typedef decltype(mExpr.rootSteps()) ExtType;
ExtType mExt;
mutable ExtType mRootSteps;
public:
typedef ExpressionBase EB;
static constexpr size_t LAYER = Expr::LAYER + 1;
static constexpr size_t SIZE = Expr::SIZE;
static constexpr size_t NHLAYER = Expr::NHLAYER + 1;
SingleExpression(const SingleExpression& in) = default;
SingleExpression& operator=(const SingleExpression& in) = default;
SingleExpression(SingleExpression&& in) = default;
SingleExpression& operator=(SingleExpression&& in) = default;
SingleExpression(const std::shared_ptr<IndexClass>& indPtr,
Expr expr);
SingleExpression(const IndexClass* indPtr,
Expr expr);
virtual std::shared_ptr<ExpressionBase> deepCopy() const override final
{
return std::make_shared<SingleExpression<IndexClass,Expr>>(*this);
}
template <size_t VS>
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;
DExt dRootSteps(std::intptr_t iPtrNum = 0) const override final;
DExt dExtension() const override final;
auto rootSteps(std::intptr_t iPtrNum = 0) const -> ExtType;
auto extension() const -> ExtType;
};
template <class IndexClass, class Expr>
class SubExpr : public ExpressionBase
{
@ -177,26 +102,15 @@ namespace CNORXZInternal
static constexpr size_t SIZE = Expr::SIZE + 1;
static constexpr size_t NHLAYER = Expr::NHLAYER + 1;
SubExpr(const SubExpr& in) = default;
SubExpr& operator=(const SubExpr& in) = default;
SubExpr(SubExpr&& in) = default;
SubExpr& operator=(SubExpr&& in) = default;
DEFAULT_MEMBERS_X(SubExpr);
SubExpr(const std::shared_ptr<IndexClass>& indPtr,
SubExpr(const Sptr<IndexClass>& indPtr,
std::intptr_t siptr,
const vector<size_t>* subset, Expr expr);
SubExpr(const IndexClass* indPtr, std::intptr_t siptr,
const vector<size_t>* subset, Expr expr);
virtual std::shared_ptr<ExpressionBase> deepCopy() const override final
{
return std::make_shared<SubExpr<IndexClass,Expr>>(*this);
}
template <size_t VS>
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;
@ -208,58 +122,6 @@ namespace CNORXZInternal
auto extension() const -> ExtType;
};
template <size_t LAYER, bool ISV>
struct MkVFor
{
template <size_t DIV, class IndexClass, class Expr>
using ptype = PFor<IndexClass,Expr,1>;
template <size_t DIV, class IndexClass, class Expr, ForType FT>
using type = For<IndexClass,Expr,FT,1>;
};
template <>
struct MkVFor<1,true>
{
template <size_t DIV, class IndexClass, class Expr>
using ptype = PFor<IndexClass,Expr,DIV>;
template <size_t DIV, class IndexClass, class Expr, ForType FT>
using type = For<IndexClass,Expr,FT,DIV>;
};
template <size_t LAYER>
struct MkVExpr
{
template <size_t VS, class Expr>
static auto mk(const Expr& e)
{
return e.template vec<VS>();
}
template <class Expr>
static inline size_t divResid(const Expr& e)
{
return e.divResid();
}
};
template <>
struct MkVExpr<1>
{
template <size_t VS, class Expr>
static auto mk(const Expr& e)
{
return e; // terminate
}
template <class Expr>
static inline size_t divResid(const Expr& e)
{
return 0;
}
};
template <ForType FT, size_t LAYER>
struct NHLayer
{
@ -316,48 +178,19 @@ namespace CNORXZInternal
static constexpr size_t MAX = RangeType::SIZE / DIV;
static constexpr size_t NHLAYER = (FT == ForType::HIDDEN) ? 0 : Expr::NHLAYER + 1;
For(const For& in) = default;
For& operator=(const For& in) = default;
For(For&& in) = default;
For& operator=(For&& in) = default;
DEFAULT_MEMBERS(For);
For(const std::shared_ptr<IndexClass>& indPtr,
For(const Sptr<IndexClass>& indPtr,
size_t step, Expr expr);
For(const IndexClass* indPtr,
size_t step, Expr expr);
virtual std::shared_ptr<ExpressionBase> deepCopy() const override final
{
return std::make_shared<For<IndexClass,Expr,FT,DIV>>(*this);
}
//virtual size_t divResid() const override final { return mMax % DIV + MkVExpr<LAYER>::divResid(mExpr); }
virtual std::intptr_t vI() const override final
{
if(mStep == 1 and NHLAYER == 1 and mMax % DIV == 0){
//if(mStep == 1 and mMax % DIV == 0){
//VCHECK(LAYER);
//VCHECK(NHLAYER);
return reinterpret_cast<std::intptr_t>(mIndPtr);
}
return mExpr.vI();
}
template <size_t VS>
auto vec() const
{
typedef typename MkVFor<NHLAYER,RangeType::SIZE % DIV == 0 or RangeType::SIZE == static_cast<size_t>(-1)>::
template type<VS,IndexClass,decltype(MkVExpr<NHLAYER>::template mk<VS>(mExpr)),FT> oType;
return oType(mIndPtr,mStep,MkVExpr<NHLAYER>::template mk<VS>(mExpr));
}
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;
PFor<IndexClass,Expr,DIV> parallel() const;
PFor<IndexClass,Expr> parallel() const;
DExt dRootSteps(std::intptr_t iPtrNum = 0) const override final;
DExt dExtension() const override final;
@ -367,93 +200,12 @@ namespace CNORXZInternal
};
template <class IndexClass, class Expr, size_t DIV>
class PFor : public ExpressionBase
{
private:
PFor() = default;
typedef typename IndexClass::RangeType RangeType;
const IndexClass* mIndPtr;
size_t mSPos;
size_t mMax;
size_t mStep;
Expr mExpr;
typedef decltype(mExpr.rootSteps()) ExtType;
ExtType mExt;
mutable ExtType mRootSteps;
public:
typedef ExpressionBase EB;
static constexpr size_t LAYER = Expr::LAYER + 1;
static constexpr size_t SIZE = Expr::SIZE;
static constexpr size_t MAX = RangeType::SIZE / DIV;
static constexpr size_t NHLAYER = Expr::NHLAYER + 1;
PFor(const PFor& in) = default;
PFor& operator=(const PFor& in) = default;
PFor(PFor&& in) = default;
PFor& operator=(PFor&& in) = default;
PFor(const std::shared_ptr<IndexClass>& indPtr,
size_t step, Expr expr);
PFor(const IndexClass* indPtr,
size_t step, Expr expr);
//virtual size_t divResid() const override final { return mMax % DIV + MkVExpr<LAYER>::divResid(mExpr); }
virtual std::intptr_t vI() const override final
{
if(mStep == 1 and NHLAYER == 1 and mMax % DIV == 0){
//if(mStep == 1 and mMax % DIV == 0){
//VCHECK(LAYER);
//VCHECK(LAYER);
return reinterpret_cast<std::intptr_t>(mIndPtr);
}
return mExpr.vI();
}
template <size_t VS>
auto vec() const
{
typedef typename MkVFor<NHLAYER,RangeType::SIZE % DIV == 0 or RangeType::SIZE == static_cast<size_t>(-1)>::
template ptype<VS,IndexClass,decltype(MkVExpr<NHLAYER>::template mk<VS>(mExpr))> oType;
return oType(mIndPtr,mStep,MkVExpr<NHLAYER>::template mk<VS>(mExpr));
}
virtual std::shared_ptr<ExpressionBase> deepCopy() const override final
{
return std::make_shared<PFor<IndexClass,Expr>>(*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;
DExt dRootSteps(std::intptr_t iPtrNum = 0) const override final;
DExt dExtension() const override final;
auto rootSteps(std::intptr_t iPtrNum = 0) const -> ExtType;
auto extension() const -> ExtType;
};
template <size_t N>
inline size_t exceptMax(size_t max) { return max; }
template <>
inline size_t exceptMax<1>(size_t max) { return 1; }
class DynamicExpression : public ExpressionBase
{
private:
size_t mThreadId = 0;
std::shared_ptr<ExpressionBase> mNext;
Sptr<ExpressionBase> mNext;
DynamicExpression() : mThreadId(omp_get_thread_num()) {}
public:
@ -486,7 +238,7 @@ namespace CNORXZInternal
return *this;
}
DynamicExpression(const std::shared_ptr<ExpressionBase>& next) :
DynamicExpression(const Sptr<ExpressionBase>& next) :
mNext(next)
{}
@ -498,14 +250,11 @@ namespace CNORXZInternal
template <class Expr>
DynamicExpression(Expr ex) : mNext( std::make_shared<Expr>(ex) ) {}
virtual std::shared_ptr<ExpressionBase> deepCopy() const override final
virtual Sptr<ExpressionBase> deepCopy() const override final
{
return std::make_shared<DynamicExpression>(*this);
}
template <size_t VS>
inline auto vec() const { return *this; }
inline void operator()(size_t mlast, DExt last) override final;
inline void operator()(size_t mlast, DExtT last) { (*this)(mlast,last.get()); }
inline void operator()(size_t mlast = 0) override final;
@ -518,52 +267,8 @@ namespace CNORXZInternal
};
template <class Expr>
class ExpressionHolder : public ExpressionBase
{
private:
ExpressionHolder() = default;
DynamicExpression mExpr;
typedef decltype(std::declval<Expr>().rootSteps()) ExtType;
ExtType mExt;
mutable ExtType mRootSteps;
public:
typedef ExpressionBase EB;
static constexpr size_t LAYER = Expr::LAYER + 1;
static constexpr size_t SIZE = Expr::SIZE;
static constexpr size_t NHLAYER = Expr::NHLAYER + 1;
ExpressionHolder(const ExpressionHolder& in) = default;
ExpressionHolder(ExpressionHolder&& in) = default;
ExpressionHolder& operator=(const ExpressionHolder& in) = default;
ExpressionHolder& operator=(ExpressionHolder&& in) = default;
ExpressionHolder(DynamicExpression expr);
virtual std::shared_ptr<ExpressionBase> deepCopy() const override final
{
return std::make_shared<ExpressionHolder<Expr>>(*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;
DExt dRootSteps(std::intptr_t iPtrNum = 0) const override final;
DExt dExtension() const override final;
auto rootSteps(std::intptr_t iPtrNum = 0) const -> ExtType;
auto extension() const -> ExtType;
};
} // namespace CNORXZInternal
/* ========================= *
* --- TEMPLATE CODE --- *
* ========================= */
@ -583,7 +288,7 @@ namespace CNORXZInternal
*****************/
template <class IndexClass, class Expr, ForType FT, size_t DIV>
For<IndexClass,Expr,FT,DIV>::For(const std::shared_ptr<IndexClass>& indPtr,
For<IndexClass,Expr,FT,DIV>::For(const Sptr<IndexClass>& indPtr,
size_t step, Expr expr) :
mIndPtr(indPtr.get()), mSPos(mIndPtr->pos()), mMax(mIndPtr->max()), mStep(step),
mExpr(expr), mExt(mExpr.rootSteps( reinterpret_cast<std::intptr_t>( mIndPtr )))
@ -680,7 +385,7 @@ namespace CNORXZInternal
******************/
template <class IndexClass, class Expr, size_t DIV>
PFor<IndexClass,Expr,DIV>::PFor(const std::shared_ptr<IndexClass>& indPtr,
PFor<IndexClass,Expr,DIV>::PFor(const Sptr<IndexClass>& indPtr,
size_t step, Expr expr) :
mIndPtr(indPtr.get()), mSPos(mIndPtr->pos()), mMax(mIndPtr->max()), mStep(step),
mExpr(expr), mExt(mExpr.rootSteps( reinterpret_cast<std::intptr_t>( mIndPtr )))
@ -786,7 +491,7 @@ namespace CNORXZInternal
************************/
template <class IndexClass, class Expr>
SingleExpression<IndexClass,Expr>::SingleExpression(const std::shared_ptr<IndexClass>& indPtr,
SingleExpression<IndexClass,Expr>::SingleExpression(const Sptr<IndexClass>& indPtr,
Expr expr) :
mIndPtr(indPtr.get()), mSPos(mIndPtr->pos()), mMax(mIndPtr->max()),
mExpr(expr), mExt(mExpr.rootSteps( reinterpret_cast<std::intptr_t>( mIndPtr )))
@ -873,7 +578,7 @@ namespace CNORXZInternal
****************/
template <class IndexClass, class Expr>
SubExpr<IndexClass,Expr>::SubExpr(const std::shared_ptr<IndexClass>& indPtr,
SubExpr<IndexClass,Expr>::SubExpr(const Sptr<IndexClass>& indPtr,
std::intptr_t siptr,
const vector<size_t>* subset, Expr expr) :
mIndPtr(indPtr.get()), mSIPtr(siptr), mSPos(mIndPtr->pos()), mMax(mIndPtr->max()),

View file

@ -0,0 +1 @@
pre-compiled stuff e.g. for python wrappers

1
src/lib/runtime/COMMENT Normal file
View file

@ -0,0 +1 @@
pre-compiled stuff e.g. for python wrappers

1
src/opt/python/COMMENT Normal file
View file

@ -0,0 +1 @@
coming soon: python wrappers