remove old files

This commit is contained in:
Christian Zimmermann 2022-11-23 23:26:27 +01:00
parent 1f27826aff
commit 7acc5c86ee
57 changed files with 0 additions and 8223 deletions

View file

@ -1,35 +0,0 @@
#include "arith.h"
namespace CNORXZ
{
template <class F>
template <class... Ops>
auto StaticFunctionBase<F>::mk(const Ops&... ops)
{
return Operation<typename F::value_type,F,Ops...>(ops...);
}
template <class F>
template <size_t N, class Tuple, typename... As>
inline auto StaticFunctionBase<F>::xapply(const Tuple& tp, As... as)
{
if constexpr(N > 0){
return xapply<N-1>(tp, std::get<N>(tp), as...);
}
else {
return F::apply(std::get<0>(tp), as...);
}
}
template <class F>
template <typename... As>
inline auto StaticFunctionBase<F>::apply(const std::tuple<As...>& arg)
{
return xapply<sizeof...(As)-1>(arg);
//return ArgPack<sizeof...(As)-1>::template mk<F,std::tuple<As...> >(arg);
}
}

View file

@ -1,213 +0,0 @@
#ifndef __cxz_arith_h__
#define __cxz_arith_h__
#include <functional>
namespace CNORXZ
{
//template <typename T, class F, typename... As>
template <class F>
struct StaticFunctionBase
{
static constexpr bool FISSTATIC = true;
typedef F function;
//typedef typename F::value_type value_type;
template <class... Ops>
static auto mk(const Ops&... ops);
template <size_t N, class Tuple, typename... As>
static inline auto xapply(const Tuple& tp, As... as);
template <typename... As>
static inline auto apply(const std::tuple<As...>& arg);
};
// OPERATIONS (STATIC)
template <typename T>
struct identity : public StaticFunctionBase<identity<T>>
{
//static constexpr bool FISSTATIC = true;
using StaticFunctionBase<identity<T>>::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 <typename T, typename U>
using plusv = decltype(std::declval<T>()+std::declval<U>());
template <typename T, typename U>
using minusv = decltype(std::declval<T>()-std::declval<U>());
template <typename T, typename U>
using multipliesv = decltype(std::declval<T>()*std::declval<U>());
template <typename T, typename U>
using dividesv = decltype(std::declval<T>()/std::declval<U>());
template <typename T, typename U>
struct plusx : public StaticFunctionBase<plusx<T,U>>
{
static constexpr bool FISSTATIC = true;
using StaticFunctionBase<plusx<T,U>>::apply;
typedef plusv<T,U> 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 <typename T, typename U>
struct minusx : public StaticFunctionBase<minusx<T,U>>
{
static constexpr bool FISSTATIC = true;
using StaticFunctionBase<minusx<T,U>>::apply;
typedef minusv<T,U> value_type;
static inline value_type apply(T a1, U a2)
{
return a1 - a2;
}
};
template <typename T, typename U>
struct multipliesx : public StaticFunctionBase<multipliesx<T,U>>
{
static constexpr bool FISSTATIC = true;
using StaticFunctionBase<multipliesx<T,U>>::apply;
typedef multipliesv<T,U> value_type;
static inline value_type apply(T a1, U a2)
{
return a1 * a2;
}
};
template <typename T, typename U>
struct dividesx : public StaticFunctionBase<dividesx<T,U>>
{
static constexpr bool FISSTATIC = true;
using StaticFunctionBase<dividesx<T,U>>::apply;
typedef dividesv<T,U> value_type;
static inline value_type apply(T a1, U a2)
{
return a1 / a2;
}
};
template <typename T>
struct negate : public StaticFunctionBase<negate<T>>
{
static constexpr bool FISSTATIC = true;
using StaticFunctionBase<negate<T>>::apply;
typedef T value_type;
static inline T apply(T a)
{
return -a;
}
};
template <typename T>
using plus = plusx<T,T>;
template <typename T>
using minus = minusx<T,T>;
template <typename T>
using multiplies = multipliesx<T,T>;
template <typename T>
using divides = dividesx<T,T>;
// OPERATIONS (STATIC)
template <typename R, typename... Args>
class function
{
public:
static constexpr bool FISSTATIC = false;
private:
std::function<R(Args...)> mF;
public:
function() = default;
function(const std::function<R(Args...)>& in) : mF(in) {}
inline R operator()(const Args&... args)
{
return mF(args...);
}
template <size_t N, class Tuple, typename... As>
static inline auto xapply(const std::function<R(Args...)>& ff, const Tuple& tp, As... as)
{
if constexpr(N > 0){
return xapply<N-1>(ff, tp, std::get<N>(tp), as...);
}
else {
return ff(std::get<0>(tp), as...);
}
}
inline R operator()(const std::tuple<Args...>& args)
{
return xapply<sizeof...(Args)-1>(mF, args);
}
};
#include <cmath>
#define regFunc1(fff) template <typename T>\
struct x_##fff : public StaticFunctionBase<x_##fff<T>> {\
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 <size_t N>
struct x_ipow
{
static constexpr bool FISSTATIC = true;
template <typename T>
static inline T apply(T a)
{
if constexpr(N > 0){
return a * x_ipow<N-1>::apply(a);
}
else {
return a;
}
}
};
} // end namespace CNORXZInternal
#include "arith.cc.h"
#endif

View file

@ -1,38 +0,0 @@
// -*- C++ -*-
#ifndef __cxz_base_def_h__
#define __cxz_base_def_h__
#include <cassert>
#define DEBUG_MODE_X
#ifdef DEBUG_MODE_X
#include <iostream>
#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

View file

@ -1,440 +0,0 @@
#include "container_index.h"
namespace CNORXZ
{
template <typename T, class... Indices>
ConstContainerIndex<T,Indices...>::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<decltype(*std::get<i>(mIPack))>::type
SubType;
std::get<i>(mIPack) = std::make_shared<SubType>( in.template get<i>() ) ;
return true;
});
}
template <typename T, class... Indices>
ConstContainerIndex<T,Indices...>& ConstContainerIndex<T,Indices...>::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<decltype(*std::get<i>(mIPack))>::type
SubType;
std::get<i>(mIPack) = std::make_shared<SubType>( in.template get<i>() ) ;
return true;
});
return *this;
}
template <typename T, class... Indices>
template <class MRange>
ConstContainerIndex<T,Indices...>::ConstContainerIndex(const std::shared_ptr<MRange>& range,
std::intptr_t objPtrNum) :
IndexInterface<ConstContainerIndex<T,Indices...>,std::tuple<typename Indices::MetaType...> >(range, 0),
mObjPtrNum(objPtrNum)
{
std::get<sizeof...(Indices)>(mBlockSizes) = 1;
sfor_mn<sizeof...(Indices),0>
( [&](auto i) {
auto r = range->template getPtr<i>();
std::get<i>(mIPack) = r->beginPtr();
*std::get<i>(mIPack) = 0;
std::get<i>(mBlockSizes) = sfor_p<i,sizeof...(Indices)>
( [&](auto j) { return std::get<j>(mIPack)->max(); } ,
[&](auto a, auto b) { return a * b; });
return 0;
});
IB::mPos = sfor_m<sizeof...(Indices),0>
( [&](auto i) { return std::get<i>(mIPack); },
[&](auto a, auto b) {return a->pos() + b*a->max();}, 0 );
mCPos = RangeHelper::makePos<sizeof...(Indices)-1>(mIPack, mBlockSizes);
}
template <typename T, class... Indices>
template <class MRange>
ConstContainerIndex<T,Indices...>::ConstContainerIndex(const std::shared_ptr<MRange>& range,
std::intptr_t objPtrNum,
const std::array<size_t,sizeof...(Indices)+1>& blockSizes) :
IndexInterface<ConstContainerIndex<T,Indices...>,std::tuple<typename Indices::MetaType...> >(range, 0),
mObjPtrNum(objPtrNum)
{
sfor_mn<sizeof...(Indices),0>
( [&](auto i) {
auto r = range->template getPtr<i>();
std::get<i>(mIPack) = r->beginPtr();
*std::get<i>(mIPack) = 0;
return 0;
});
IB::mPos = sfor_m<sizeof...(Indices),0>
( [&](auto i) { return std::get<i>(mIPack); },
[&](auto a, auto b) {return a->pos() + b*a->max();}, 0 );
mCPos = RangeHelper::makePos<sizeof...(Indices)-1>(mIPack, mBlockSizes);
mNonTrivialBlocks = true;
}
template <typename T, class... Indices>
template <typename X>
ConstContainerIndex<T,Indices...>&
ConstContainerIndex<T,Indices...>::operator=(const ConstContainerIndex<X,Indices...>& in)
{
mIPack = in.mIPack;
return (*this)();
}
template <typename T, class... Indices>
ConstContainerIndex<T,Indices...>& ConstContainerIndex<T,Indices...>::sync()
{
if(mExternControl){
IB::mPos = sfor_m<sizeof...(Indices),0>
( [&](auto i) { return std::get<i>(mIPack); },
[&](auto a, auto b) {return a->pos() + b*a->max();}, 0 );
mCPos = RangeHelper::makePos<sizeof...(Indices)-1>(mIPack, mBlockSizes);
}
return *this;
}
template <typename T, class... Indices>
template <size_t N>
auto& ConstContainerIndex<T,Indices...>::get() const
{
return *std::get<N>( mIPack );
}
template <typename T, class... Indices>
template <size_t N>
auto ConstContainerIndex<T,Indices...>::getPtr() const
{
return std::get<N>( mIPack );
}
template <typename T, class... Indices>
ConstContainerIndex<T,Indices...>& ConstContainerIndex<T,Indices...>::operator()(const std::shared_ptr<Indices>&... inds)
{
return (*this)(std::make_tuple(inds...));
}
template <typename T, class... Indices>
ConstContainerIndex<T,Indices...>& ConstContainerIndex<T,Indices...>::operator()(const std::tuple<std::shared_ptr<Indices>...>& inds)
{
sfor_pn<0,sizeof...(Indices)>
( [&](auto i) { std::get<i>(mIPack) = std::get<i>(inds); return 0; } );
mExternControl = true;
return sync();
}
template <typename T, class... Indices>
ConstContainerIndex<T,Indices...>& ConstContainerIndex<T,Indices...>::operator()()
{
return sync();
}
template <typename T, class... Indices>
IndexType ConstContainerIndex<T,Indices...>::type() const { return IndexType::CONT; }
template <typename T, class... Indices>
ConstContainerIndex<T,Indices...>& ConstContainerIndex<T,Indices...>::operator++()
{
if(mExternControl){
IB::mPos = sfor_m<sizeof...(Indices),0>
( [&](auto i) { return std::get<i>(mIPack); },
[&](auto a, auto b) {return a->pos() + b*a->max();}, 0 );
}
sfor_m<sizeof...(Indices),0>
( [&](auto i) {
auto& si = *std::get<i>( mIPack );
if(si.last() and i != 0) { si = 0; return true; }
else { ++si; return false; }
return false;
} );
mCPos = RangeHelper::makePos<sizeof...(Indices)-1>(mIPack, mBlockSizes);
++IB::mPos;
return *this;
}
template <typename T, class... Indices>
ConstContainerIndex<T,Indices...>& ConstContainerIndex<T,Indices...>::operator--()
{
if(mExternControl){
IB::mPos = sfor_m<sizeof...(Indices),0>
( [&](auto i) { return std::get<i>(mIPack); },
[&](auto a, auto b) {return a->pos() + b*a->max();}, 0 );
}
sfor_m<sizeof...(Indices),0>
( [&](auto i) {
auto& si = *std::get<i>( mIPack );
if(si.first() and i != 0) { si = si.max()-1; return true; }
else { --si; return false; }
return false;
} );
mCPos = RangeHelper::makePos<sizeof...(Indices)-1>(mIPack, mBlockSizes);
--IB::mPos;
return *this;
}
template <typename T, class... Indices>
ConstContainerIndex<T,Indices...>& ConstContainerIndex<T,Indices...>::operator=(size_t pos)
{
IB::mPos = pos;
RangeHelper::setIndexPack<sizeof...(Indices)-1>(mIPack, pos);
mCPos = RangeHelper::makePos<sizeof...(Indices)-1>(mIPack, mBlockSizes);
return *this;
}
template <typename T, class... Indices>
int ConstContainerIndex<T,Indices...>::pp(std::intptr_t idxPtrNum)
{
const int tmp = RangeHelper::ppx<sizeof...(Indices)-1>(mIPack, mBlockSizes, idxPtrNum);
IB::mPos += tmp;
return tmp;
}
template <typename T, class... Indices>
int ConstContainerIndex<T,Indices...>::mm(std::intptr_t idxPtrNum)
{
const int tmp = RangeHelper::mmx<sizeof...(Indices)-1>(mIPack, mBlockSizes, idxPtrNum);
IB::mPos -= tmp;
return tmp;
}
template <typename T, class... Indices>
std::string ConstContainerIndex<T,Indices...>::stringMeta() const
{
return std::dynamic_pointer_cast<RangeType>( IB::mRangePtr )->stringMeta(IB::mPos);
}
template <typename T, class... Indices>
typename ConstContainerIndex<T,Indices...>::MetaType ConstContainerIndex<T,Indices...>::meta() const
{
MetaType metaTuple;
sfor_pn<0,sizeof...(Indices)>
( [&](auto i) { std::get<i>(metaTuple) = std::get<i>(mIPack)->meta(); return 0; } );
return metaTuple;
}
template <typename T, class... Indices>
ConstContainerIndex<T,Indices...>& ConstContainerIndex<T,Indices...>::at(const MetaType& metaPos)
{
sfor_pn<0,sizeof...(Indices)>
( [&](auto i) { std::get<i>(mIPack)->at( std::get<i>(metaPos) ); return 0; } );
IB::mPos = RangeHelper::makePos<sizeof...(Indices)-1>(mIPack, mBlockSizes);
return *this;
}
template <typename T, class... Indices>
size_t ConstContainerIndex<T,Indices...>::dim() const
{
return sizeof...(Indices);
}
template <typename T, class... Indices>
bool ConstContainerIndex<T,Indices...>::first() const
{
return IB::pos() == 0;
}
template <typename T, class... Indices>
bool ConstContainerIndex<T,Indices...>::last() const
{
return IB::pos() == IB::mMax - 1;
}
template <typename T, class... Indices>
bool ConstContainerIndex<T,Indices...>::sliceMode() const
{
return mNonTrivialBlocks;
}
template <typename T, class... Indices>
std::shared_ptr<typename ConstContainerIndex<T,Indices...>::RangeType>
ConstContainerIndex<T,Indices...>::range()
{
return std::dynamic_pointer_cast<RangeType>( IB::mRangePtr );
}
template <typename T, class... Indices>
size_t ConstContainerIndex<T,Indices...>::getStepSize(size_t n)
{
if(n >= sizeof...(Indices)){
assert(0);
// throw !!
}
return mBlockSizes[n+1];
}
template <typename T, class... Indices>
template <class Exprs>
auto ConstContainerIndex<T,Indices...>::ifor(size_t step, Exprs exs) const
{
return RangeHelper::mkFor<0>(step, mIPack, mBlockSizes, exs);
}
template <typename T, class... Indices>
template <class Exprs>
auto ConstContainerIndex<T,Indices...>::iforh(size_t step, Exprs exs) const
{
return RangeHelper::mkForh<0>(step, mIPack, mBlockSizes, exs);
}
template <typename T, class... Indices>
template <class Exprs>
auto ConstContainerIndex<T,Indices...>::pifor(size_t step, Exprs exs) const
{
return RangeHelper::mkPFor<0>(step, mIPack, mBlockSizes, exs);
}
template <typename T, class... Indices>
std::intptr_t ConstContainerIndex<T,Indices...>::container() const
{
return mObjPtrNum;
}
template <typename T, class... Indices>
ConstContainerIndex<T,Indices...>& ConstContainerIndex<T,Indices...>::
format(const std::array<size_t,sizeof...(Indices)+1>& blocks)
{
mBlockSizes = blocks;
mNonTrivialBlocks = true;
return *this;
}
template <typename T, class... Indices>
ConstContainerIndex<T,Indices...>& ConstContainerIndex<T,Indices...>::setData(const T* data)
{
mData = data;
return *this;
}
template <typename T, class... Indices>
const T& ConstContainerIndex<T,Indices...>::operator*() const
{
return mData[mCPos];
}
template <typename T, class... Indices>
const T* ConstContainerIndex<T,Indices...>::operator->() const
{
return &mData[mCPos];
}
template <typename T, class... Indices>
ConstContainerIndex<T,Indices...> ConstContainerIndex<T,Indices...>::operator++(int)
{
auto tmp = *this;
++(*this);
return tmp;
}
template <typename T, class... Indices>
ConstContainerIndex<T,Indices...> ConstContainerIndex<T,Indices...>::operator--(int)
{
auto tmp = *this;
--(*this);
return tmp;
}
template <typename T, class... Indices>
ConstContainerIndex<T,Indices...>& ConstContainerIndex<T,Indices...>::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 <typename T, class... Indices>
ConstContainerIndex<T,Indices...>& ConstContainerIndex<T,Indices...>::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 <typename T, class... Indices>
ConstContainerIndex<T,Indices...> ConstContainerIndex<T,Indices...>::operator+(int num) const
{
auto tmp = *this;
return tmp += num;
}
template <typename T, class... Indices>
ConstContainerIndex<T,Indices...> ConstContainerIndex<T,Indices...>::operator-(int num) const
{
auto tmp = *this;
return tmp -= num;
}
template <typename T, class... Indices>
int ConstContainerIndex<T,Indices...>::operator-(const ConstContainerIndex<T,Indices...>& it) const
{
return static_cast<int>( IB::mPos ) - static_cast<int>( it.pos() );
}
template <typename T, class... Indices>
const T& ConstContainerIndex<T,Indices...>::operator[](int num) const
{
return mData[IB::mPos + num];
}
template <typename T, class... Indices>
bool ConstContainerIndex<T,Indices...>::operator<(const ConstContainerIndex<T,Indices...>& it) const
{
return IB::mPos < it.pos();
}
template <typename T, class... Indices>
bool ConstContainerIndex<T,Indices...>::operator>(const ConstContainerIndex<T,Indices...>& it) const
{
return IB::mPos > it.pos();
}
template <typename T, class... Indices>
bool ConstContainerIndex<T,Indices...>::operator<=(const ConstContainerIndex<T,Indices...>& it) const
{
return IB::mPos <= it.pos();
}
template <typename T, class... Indices>
bool ConstContainerIndex<T,Indices...>::operator>=(const ConstContainerIndex<T,Indices...>& it) const
{
return IB::mPos >= it.pos();
}
} // namespace CNORXZ

View file

@ -1,306 +0,0 @@
// -*- C++ -*-
#ifndef __cxz_container_index_h__
#define __cxz_container_index_h__
#include <cstdlib>
#include <tuple>
#include <memory>
#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 <typename T, class... Indices>
class ConstContainerIndex : public IndexInterface<ConstContainerIndex<T,Indices...>,
std::tuple<typename Indices::MetaType...> >
{
public:
typedef IndexInterface<ConstContainerIndex<T,Indices...>,
std::tuple<typename Indices::MetaType...> > IB;
typedef std::tuple<typename Indices::MetaType...> MetaType;
typedef std::tuple<std::shared_ptr<Indices>...> IndexPack;
typedef ContainerRange<typename Indices::RangeType...> 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<Indices...>>::type::PARALLEL;
template <typename X>
using CIX = ConstContainerIndex<X,Indices...>;
template <typename X>
friend class CIX;
private:
ConstContainerIndex() = default;
bool mNonTrivialBlocks = false;
bool mExternControl = false;
IndexPack mIPack;
std::array<size_t,sizeof...(Indices)+1> 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 <typename X>
ConstContainerIndex& operator=(const ConstContainerIndex<X,Indices...>& in);
template <class MRange>
ConstContainerIndex(const std::shared_ptr<MRange>& range,
std::intptr_t objPtrNum);
template <class MRange>
ConstContainerIndex(const std::shared_ptr<MRange>& range,
std::intptr_t objPtrNum,
const std::array<size_t,sizeof...(Indices)+1>& blockSizes);
template <size_t N>
size_t getBlockSize() const { return std::get<N>(mBlockSizes); }
const IndexPack& pack() const { return mIPack; }
ConstContainerIndex& sync(); // recalculate 'IB::mPos' when externalControl == true
ConstContainerIndex& operator()(const std::shared_ptr<Indices>&... inds); // control via external indices
ConstContainerIndex& operator()(const std::tuple<std::shared_ptr<Indices>...>& 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<RangeType> range();
template <size_t N>
auto& get() const;
template <size_t N>
auto getPtr() const;
size_t getStepSize(size_t n);
template <class Exprs>
auto ifor(size_t step, Exprs exs) const;
template <class Exprs>
auto iforh(size_t step, Exprs exs) const;
template <class Exprs>
auto pifor(size_t step, Exprs exs) const;
std::intptr_t container() const;
ConstContainerIndex& format(const std::array<size_t,sizeof...(Indices)+1>& 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 <typename T, class... Indices>
class ContainerIndex : public ConstContainerIndex<T,Indices...>
{
public:
typedef ConstContainerIndex<T,Indices...> 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 <typename X>
using CIX = ContainerIndex<X,Indices...>;
template <typename X>
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<T,Indices...>& in, T* data) : CCI(in)
{ mMData = data; }
ContainerIndex(const ConstContainerIndex<T,Indices...>& in, T* data, bool copy) :
CCI(in,copy)
{ mMData = data; }
ContainerIndex& copy(const ContainerIndex& in)
{ CCI::copy(in); mMData = in.mMData; }
template <typename X>
ContainerIndex& operator=(const ContainerIndex<X,Indices...>& in)
{ CCI::operator=(in); return *this; }
template <class MRange>
ContainerIndex(const std::shared_ptr<MRange>& range,
std::intptr_t objPtrNum) : CCI(range, objPtrNum) {}
template <class MRange>
ContainerIndex(const std::shared_ptr<MRange>& range,
std::intptr_t objPtrNum,
const std::array<size_t,sizeof...(Indices)+1>& blockSizes)
: CCI(range, objPtrNum, blockSizes) {}
template <size_t N>
size_t getBlockSize() const { return CCI::template getBlockSize<N>(); }
const IndexPack& pack() const { CCI::pack(); return *this; }
ContainerIndex& sync() { return CCI::sync(); return *this; }
ContainerIndex& operator()(const std::shared_ptr<Indices>&... inds)
{ CCI::operator()(inds...); return *this; }
ContainerIndex& operator()(const std::tuple<std::shared_ptr<Indices>...>& 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<RangeType> range() { return CCI::range(); }
template <size_t N>
auto& get() const { return CCI::template get<N>(); }
template <size_t N>
auto getPtr() const { return CCI::template getPtr<N>(); }
size_t getStepSize(size_t n) { return getStepSize(n); }
template <class Exprs>
auto ifor(size_t step, Exprs exs) const { return CCI::ifor(step, exs); }
template <class Exprs>
auto iforh(size_t step, Exprs exs) const { return CCI::iforh(step, exs); }
template <class Exprs>
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<size_t,sizeof...(Indices)+1>& 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

View file

@ -1,122 +0,0 @@
#ifndef __cxz_conversions_h__
#define __cxz_conversions_h__
#include "cxz_array.h"
#include "slice.h"
namespace CNORXZ
{
namespace ConversionSizes
{
template <size_t N>
struct OrigSize
{
template <typename C, typename T>
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<MUI>
{
template <typename C, typename T>
struct FromTo
{
static void check() {}
static constexpr size_t SIZE = MUI;
};
};
}
namespace
{
template <typename C, typename T, size_t N>
using SC = typename ConversionSizes::OrigSize<N>::template FromTo<C,T>;
template <typename C, typename T, class Range>
using SCR = SC<C,T,Range::SIZE>;
template <typename C, typename T, class Range>
using SCRR = GenSingleRange<typename Range::MetaType,SpaceType::NONE,SCR<C,T,Range>::SIZE>;
}
template <size_t N>
struct SubTuple
{
template <class RTP, class... Ranges>
static inline auto mk(const RTP& rtp, const Ranges&... rs)
-> decltype(SubTuple<N-1>::mk(rtp, std::get<N>(rtp), rs...))
{
return SubTuple<N-1>::mk(rtp, std::get<N>(rtp), rs...);
}
};
template <>
struct SubTuple<0>
{
template <class RTP, class... Ranges>
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 <class... Ranges>
using LastR = typename std::tuple_element<sizeof...(Ranges)-1,std::tuple<Ranges...>>::type;
template <typename C, typename T, class... Ranges>
auto rtcast(const std::tuple<std::shared_ptr<Ranges>...>& rtp)
-> decltype(std::tuple_cat(SubTuple<sizeof...(Ranges)-2>::mk(rtp),
std::make_tuple( std::dynamic_pointer_cast<SCRR<C,T,LastR<Ranges...>>>
( SCRR<C,T,LastR<Ranges...>>::factory().create() ) ) ))
{
return std::tuple_cat(SubTuple<sizeof...(Ranges)-2>::mk(rtp),
std::make_tuple( std::dynamic_pointer_cast<SCRR<C,T,LastR<Ranges...>>>
( SCRR<C,T,LastR<Ranges...>>::factory().create() ) ) );
}
template <typename T, class... Ranges>
inline Slice<T,Ranges...> rangeTpToSlice( const std::tuple<std::shared_ptr<Ranges>...>& rtp, T* data )
{
return Slice<T,Ranges...>(rtp, data);
}
template <typename T, class... Ranges>
inline ConstSlice<T,Ranges...> rangeTpToSlice( const std::tuple<std::shared_ptr<Ranges>...>& rtp, const T* data )
{
return ConstSlice<T,Ranges...>(rtp, data);
}
template <typename C, typename T, class... Ranges>
auto tcast(Array<T,Ranges...>& ma)
-> decltype(rangeTpToSlice
( rtcast<C,T>( ma.range()->space() ),
reinterpret_cast<C*>( ma.data() ) ))
{
// VCHECK(reinterpret_cast<std::intptr_t>(ma.data()) % 32);
//VCHECK(reinterpret_cast<std::intptr_t>(reinterpret_cast<C*>(ma.data())) % 32);
return rangeTpToSlice
( rtcast<C,T>( ma.range()->space() ),
reinterpret_cast<C*>( ma.data() ) );
}
template <typename C, typename T, class... Ranges>
auto tcast(const Array<T,Ranges...>& ma)
-> decltype(rangeTpToSlice
( rtcast<C,T>( ma.range()->space() ),
reinterpret_cast<const C*>( ma.data() ) ))
{
//VCHECK(reinterpret_cast<std::intptr_t>(ma.data()) % 32);
//VCHECK(reinterpret_cast<std::intptr_t>(reinterpret_cast<C*>(ma.data())) % 32);
return rangeTpToSlice
( rtcast<C,T>( ma.range()->space() ),
reinterpret_cast<const C*>( ma.data() ) );
}
}
#endif

View file

@ -1,269 +0,0 @@
#include "cxz_array.h"
#include "statics/static_for.h"
namespace CNORXZ
{
template <typename T>
Scalar<T> scalar(const T& in)
{
NullRF nrf;
return Scalar<T>( std::dynamic_pointer_cast<NullRange>( nrf.create() ), vector<T>( { in } ) );
}
/*******************
* Array *
*******************/
template <typename T, class... SRanges>
Array<T,SRanges...>::Array(const typename CRange::Space& space) :
MutableArrayBase<T,SRanges...>(space),
mCont(MAB::mRange->size())
{
MAB::mInit = true;
}
template <typename T, class... SRanges>
Array<T,SRanges...>::Array(const typename CRange::Space& space,
const vector<T>& vec) :
MutableArrayBase<T,SRanges...>(space),
mCont(vec)
{
MAB::mInit = true;
if(mCont.size() > MAB::mRange->size()){
mCont.erase(mCont.begin() + MAB::mRange->size(), mCont.end());
}
}
template <typename T, class... SRanges>
Array<T,SRanges...>::Array(const std::shared_ptr<SRanges>&... ranges) :
MutableArrayBase<T,SRanges...>(ranges...),
mCont(MAB::mRange->size())
{
MAB::mInit = true;
}
template <typename T, class... SRanges>
Array<T,SRanges...>::Array(const std::shared_ptr<SRanges>&... ranges, const T& val) :
MutableArrayBase<T,SRanges...>(ranges...),
mCont(MAB::mRange->size(), val)
{
MAB::mInit = true;
}
template <typename T, class... SRanges>
Array<T,SRanges...>::Array(const std::shared_ptr<SRanges>&... ranges, const vector<T>& vec) :
MutableArrayBase<T,SRanges...>(ranges...),
mCont(vec)
{
MAB::mInit = true;
if(mCont.size() > MAB::mRange->size()){
mCont.erase(mCont.begin() + MAB::mRange->size(), mCont.end());
}
}
template <typename T, class... SRanges>
Array<T,SRanges...>::Array(const std::shared_ptr<SRanges>&... ranges, vector<T>&& vec) :
MutableArrayBase<T,SRanges...>(ranges...),
mCont(std::forward<vector<T>>(vec))
{
MAB::mInit = true;
if(mCont.size() > MAB::mRange->size()){
mCont.erase(mCont.begin() + MAB::mRange->size(), mCont.end());
}
}
template <typename T, class... SRanges>
template <class... Ranges>
Array<T,SRanges...>::Array(const std::shared_ptr<SRanges>&... ranges, Array<T,Ranges...>&& in) :
MutableArrayBase<T,SRanges...>(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 <typename T, class... SRanges>
Array<T,SRanges...>::Array(Array<T,AnonymousRange>&& ama, SIZET<SRanges>... sizes) :
MutableArrayBase<T,SRanges...>
( ama.range()->template get<0>().template scast<SRanges...>(sizes...)->space() ),
mCont( std::move( ama.mCont ) )
{
MAB::mInit = true;
ama.mInit = false;
}
template <typename T, class... SRanges>
T& Array<T,SRanges...>::operator[](const IndexType& i)
{
return mCont[ i.pos() ];
}
template <typename T, class... SRanges>
const T& Array<T,SRanges...>::operator[](const IndexType& i) const
{
return mCont[ i.pos() ];
}
template <typename T, class... SRanges>
T& Array<T,SRanges...>::at(const typename IndexType::MetaType& meta)
{
return mCont[ MAB::cbegin().at(meta).pos() ];
}
template <typename T, class... SRanges>
const T& Array<T,SRanges...>::at(const typename IndexType::MetaType& meta) const
{
return mCont[ MAB::cbegin().at(meta).pos() ];
}
template <typename T, class... SRanges>
bool Array<T,SRanges...>::isConst() const
{
return false;
}
template <typename T, class... SRanges>
bool Array<T,SRanges...>::isSlice() const
{
return false;
}
template <typename T, class... SRanges>
template <class... SRanges2>
Array<T,SRanges2...> Array<T,SRanges...>::format(const std::shared_ptr<SRanges2>&... nrs)
{
//MAB::mInit = false;
return Array<T,SRanges2...>( nrs... , mCont );
}
template <typename T, class... SRanges>
template <class... SRanges2>
Array<T,SRanges2...> Array<T,SRanges...>::format(const std::tuple<std::shared_ptr<SRanges2>...>& nrs)
{
//MAB::mInit = false;
return Array<T,SRanges2...>( nrs , mCont );
}
template <typename T, class... SRanges>
template <class... SRanges2>
Slice<T,SRanges2...> Array<T,SRanges...>::slformat(const std::shared_ptr<SRanges2>&... nrs)
{
return Slice<T,SRanges2...>( nrs..., mCont.data() );
}
template <typename T, class... SRanges>
template <class... SRanges2>
ConstSlice<T,SRanges2...> Array<T,SRanges...>::slformat(const std::shared_ptr<SRanges2>&... nrs) const
{
return ConstSlice<T,SRanges2...>( nrs..., mCont.data() );
}
template <typename T, class... SRanges>
const T* Array<T,SRanges...>::data() const
{
return mCont.data();
}
template <typename T, class... SRanges>
T* Array<T,SRanges...>::data()
{
return mCont.data();
}
template <typename T, class... SRanges>
std::shared_ptr<ArrayBase<T,AnonymousRange> > Array<T,SRanges...>::anonymous(bool slice) const
{
AnonymousRangeFactory arf(MAB::mRange->space());
if(slice){
return std::make_shared<ConstSlice<T,AnonymousRange> >
( std::dynamic_pointer_cast<AnonymousRange>( arf.create() ),
data() );
}
else {
return std::make_shared<Array<T,AnonymousRange> >
( std::dynamic_pointer_cast<AnonymousRange>( arf.create() ),
mCont );
}
}
template <typename T, class... SRanges>
Array<T,SRanges...>& Array<T,SRanges...>::operator=(const T& in)
{
for(auto& x: mCont){
x = in;
}
return *this;
}
template <typename T, class... SRanges>
Array<T,SRanges...>& Array<T,SRanges...>::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<i>(MAB::mRange->space()).get() == std::get<i>(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 <typename T, class... SRanges>
Array<T,SRanges...>& Array<T,SRanges...>::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<i>(MAB::mRange->space()).get() == std::get<i>(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 <typename T, class... SRanges>
Array<T,SRanges...>& Array<T,SRanges...>::operator*=(const T& in)
{
for(auto& x: mCont){
x *= in;
}
return *this;
}
template <typename T, class... SRanges>
Array<T,SRanges...>& Array<T,SRanges...>::operator/=(const T& in)
{
for(auto& x: mCont){
x /= in;
}
return *this;
}
template <typename T, class... SRanges>
Array<T,SRanges...>::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 <typename T, class... SRanges>
auto Array<T,SRanges...>::cat() const
-> decltype(ArrayCatter<T>::cat(*this))
{
return ArrayCatter<T>::cat(*this);
}
}

View file

@ -1,151 +0,0 @@
// -*- C++ -*-
#ifndef __cxz_array_h__
#define __cxz_array_h__
#include <algorithm>
#include "cxz_array_base.h"
#include "ranges/anonymous_range.h"
namespace CNORXZ
{
template <typename T>
struct ArrayCatter;
template <typename T>
struct ArrayCatter
{
template <class... Ranges>
static auto cat(const Array<T,Ranges...>& ma)
-> Array<T,Ranges...>
{
return ma;
}
};
template <typename T, class... SRanges>
class Array : public MutableArrayBase<T,SRanges...>
{
public:
typedef ContainerRange<SRanges...> CRange;
typedef ArrayBase<T,SRanges...> MAB;
typedef ConstContainerIndex<T,typename SRanges::IndexType...> IndexType;
using ArrayBase<T,SRanges...>::operator[];
using MutableArrayBase<T,SRanges...>::operator[];
DEFAULT_MEMBERS(Array);
Array(const std::shared_ptr<SRanges>&... ranges);
Array(const std::shared_ptr<SRanges>&... ranges, const T& val);
Array(const std::shared_ptr<SRanges>&... ranges, const vector<T>& vec);
Array(const std::shared_ptr<SRanges>&... ranges, vector<T>&& vec);
template <class... Ranges>
Array(const std::shared_ptr<SRanges>&... ranges, Array<T,Ranges...>&& in); // same effect as format
Array(const typename CRange::Space& space);
Array(const typename CRange::Space& space, const vector<T>& vec);
Array(Array<T,AnonymousRange>&& ama, SIZET<SRanges>... sizes);
// Only if ALL ranges have default extensions:
//Array(const vector<T>& vec);
//Array(vector<T>&& vec);
// template <class Range2, class Range3>
// Array(const Array<Array<T,Range2>,Range3> in);
// implement contstructor using FunctionalArray as Input !!!
//template <class Range2, class Range3>
//Array& operator=(const Array<Array<T,Range2>,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 <class... SRanges2>
Array<T,SRanges2...> format(const std::shared_ptr<SRanges2>&... nrs); // reformat array using 'nr' which in
// total must have the same size as mRange
template <class... SRanges2>
Array<T,SRanges2...> format(const std::tuple<std::shared_ptr<SRanges2>...>& nrs);
template <class... SRanges2>
Slice<T,SRanges2...> slformat(const std::shared_ptr<SRanges2>&... nrs);
template <class... SRanges2>
ConstSlice<T,SRanges2...> slformat(const std::shared_ptr<SRanges2>&... nrs) const;
virtual const T* data() const override;
virtual T* data() override;
virtual vector<T>& vdata() { return mCont; }
virtual const vector<T>& vdata() const { return mCont; }
vector<T>&& vmove() { MAB::mInit = false; return std::move(mCont); }
virtual std::shared_ptr<ArrayBase<T,AnonymousRange> > anonymous(bool slice = false) const override;
//virtual std::shared_ptr<ArrayBase<T,AnonymousRange> > anonymousMove() override;
auto cat() const
-> decltype(ArrayCatter<T>::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 <typename U, class... SRanges2>
friend class Array;
private:
vector<T> mCont;
};
template <typename T>
using Scalar = Array<T,NullRange>;
template <typename T>
Scalar<T> scalar(const T& in);
template <typename T, class... ERanges>
struct ArrayCatter<Array<T,ERanges...> >
{
template <class... Ranges>
static auto cat(const Array<Array<T,ERanges...>,Ranges...>& ma)
-> Array<T,Ranges...,ERanges...>
{
auto sma = *ma.begin();
const size_t smas = sma.size();
const size_t mas = ma.size();
auto cr = ma.range()->cat(sma.range());
vector<T> 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<T,Ranges...,ERanges...>(cr->space(), std::move(ov));
}
};
}
/* ========================= *
* --- TEMPLATE CODE --- *
* ========================= */
#endif

View file

@ -1,274 +0,0 @@
#include "cxz_array_base.h"
namespace CNORXZ
{
/**********************
* ArrayBase *
**********************/
template <typename T, class... SRanges>
ArrayBase<T,SRanges...>::ArrayBase(const ArrayBase& in) :
mInit(in.mInit),
mRange(in.mRange)
{
if(mRange){
mProtoI = std::make_shared<IndexType>( mRange, reinterpret_cast<std::intptr_t>(this) );
}
}
template <typename T, class... SRanges>
ArrayBase<T,SRanges...>::ArrayBase(ArrayBase&& in) :
mInit(in.mInit),
mRange(in.mRange)
{
if(mRange){
mProtoI = std::make_shared<IndexType>( mRange, reinterpret_cast<std::intptr_t>(this) );
}
}
template <typename T, class... SRanges>
ArrayBase<T,SRanges...>& ArrayBase<T,SRanges...>::operator=(const ArrayBase& in)
{
mInit = in.mInit;
mRange = in.mRange;
if(mRange){
mProtoI = std::make_shared<IndexType>( mRange, reinterpret_cast<std::intptr_t>(this) );
}
return *this;
}
template <typename T, class... SRanges>
ArrayBase<T,SRanges...>& ArrayBase<T,SRanges...>::operator=(ArrayBase&& in)
{
mInit = in.mInit;
mRange = in.mRange;
if(mRange){
mProtoI = std::make_shared<IndexType>( mRange, reinterpret_cast<std::intptr_t>(this) );
}
return *this;
}
template <typename T, class... SRanges>
ArrayBase<T,SRanges...>::ArrayBase(const std::shared_ptr<SRanges>&... ranges)
{
ContainerRangeFactory<SRanges...> crf(ranges...);
mRange = std::dynamic_pointer_cast<ContainerRange<SRanges...> >( crf.create() );
mProtoI = std::make_shared<IndexType>( mRange, reinterpret_cast<std::intptr_t>(this) );
}
template <typename T, class... SRanges>
ArrayBase<T,SRanges...>::ArrayBase(const typename CRange::Space& space)
{
ContainerRangeFactory<SRanges...> crf(space);
mRange = std::dynamic_pointer_cast<ContainerRange<SRanges...> >( crf.create() );
mProtoI = std::make_shared<IndexType>( mRange, reinterpret_cast<std::intptr_t>(this) );
}
template <typename T, class... SRanges>
template <typename X>
const T& ArrayBase<T,SRanges...>::operator[](const ConstContainerIndex<X,typename SRanges::IndexType...>& i)
{
IndexType ii(*mProtoI);
ii = i;
return (*this)[ii];
}
template <typename T, class... SRanges>
const T& ArrayBase<T,SRanges...>::operator[](const std::tuple<IPTR<typename SRanges::IndexType>...>& is) const
{
IndexType ii(*mProtoI);
ii(is);
return (*this)[ii];
}
template <typename T, class... SRanges>
size_t ArrayBase<T,SRanges...>::size() const
{
return mRange->size();
}
template <typename T, class... SRanges>
typename ArrayBase<T,SRanges...>::CIndexType ArrayBase<T,SRanges...>::begin() const
{
return cbegin();
}
template <typename T, class... SRanges>
typename ArrayBase<T,SRanges...>::CIndexType ArrayBase<T,SRanges...>::end() const
{
return end();
}
template <typename T, class... SRanges>
typename ArrayBase<T,SRanges...>::CIndexType ArrayBase<T,SRanges...>::cbegin() const
{
CIndexType i(*mProtoI,true);
i = 0;
return i.setData(data());
}
template <typename T, class... SRanges>
typename ArrayBase<T,SRanges...>::CIndexType ArrayBase<T,SRanges...>::cend() const
{
CIndexType i(*mProtoI,true);
i = i.max();
return i.setData(data());
}
template <typename T, class... SRanges>
const std::shared_ptr<typename ArrayBase<T,SRanges...>::CRange>&
ArrayBase<T,SRanges...>::range() const
{
return mRange;
}
template <typename T, class... SRanges>
bool ArrayBase<T,SRanges...>::isConst() const
{
return true;
}
template <typename T, class... SRanges>
ConstOperationRoot<T,SRanges...>
ArrayBase<T,SRanges...>::operator()(const std::shared_ptr<typename SRanges::IndexType>&... inds) const
{
return ConstOperationRoot<T,SRanges...>(*this, inds...);
}
template <typename T, class... SRanges>
ConstOperationRoot<T,SRanges...>
ArrayBase<T,SRanges...>::op(const std::shared_ptr<CIndexType>& ind) const
{
return ConstOperationRoot<T,SRanges...>(data(), *ind);
}
template <typename T, class... SRanges>
template <class... MappedRanges>
ConstOperationRoot<T,MappedRanges...>
ArrayBase<T,SRanges...>::m(const std::shared_ptr<typename MappedRanges::IndexType>&... inds) const
{
static_assert(sizeof...(SRanges) == sizeof...(MappedRanges),
"number of mapped ranges must be equal to number of original ranges");
return ConstOperationRoot<T,MappedRanges...>(*this, inds...);
}
template <typename T, class... SRanges>
bool ArrayBase<T,SRanges...>::isInit() const
{
return mInit;
}
template <typename T, class... SRanges>
template <size_t N>
auto ArrayBase<T,SRanges...>::getRangePtr() const
-> decltype(mRange->template getPtr<N>())
{
return mRange->template getPtr<N>();
}
/******************************
* MutableArrayBase *
******************************/
template <typename T, class... SRanges>
MutableArrayBase<T,SRanges...>::MutableArrayBase(const std::shared_ptr<SRanges>&... ranges) :
ArrayBase<T,SRanges...>(ranges...) {}
template <typename T, class... SRanges>
MutableArrayBase<T,SRanges...>::MutableArrayBase(const typename CRange::Space& space) :
ArrayBase<T,SRanges...>(space) {}
template <typename T, class... SRanges>
template <typename X>
T& MutableArrayBase<T,SRanges...>::operator[](const ConstContainerIndex<X,typename SRanges::IndexType...>& i)
{
IndexType ii(*MAB::mProtoI);
ii = i;
return (*this)[ii];
}
template <typename T, class... SRanges>
T& MutableArrayBase<T,SRanges...>::operator[](const std::tuple<IPTR<typename SRanges::IndexType>...>& is)
{
IndexType ii(*MAB::mProtoI,this->data());
ii(is);
return (*this)[ii];
}
template <typename T, class... SRanges>
typename MutableArrayBase<T,SRanges...>::IndexType MutableArrayBase<T,SRanges...>::begin()
{
IndexType i(*MAB::mProtoI,this->data(),true);
i = 0;
return i.setData(data());
}
template <typename T, class... SRanges>
typename MutableArrayBase<T,SRanges...>::IndexType MutableArrayBase<T,SRanges...>::end()
{
IndexType i(*MAB::mProtoI,this->data(),true);
i = i.max();
return i.setData(data());
}
template <typename T, class... SRanges>
bool MutableArrayBase<T,SRanges...>::isConst() const
{
return false;
}
template <typename T, class... SRanges>
OperationRoot<T,SRanges...>
MutableArrayBase<T,SRanges...>::operator()(const std::shared_ptr<typename SRanges::IndexType>&... inds)
{
return OperationRoot<T,SRanges...>(*this, inds...);
}
template <typename T, class... SRanges>
OperationRoot<T,SRanges...>
MutableArrayBase<T,SRanges...>::op(const std::shared_ptr<CIndexType>& ind)
{
return OperationRoot<T,SRanges...>(data(), *ind);
}
template <typename T, class... SRanges>
ConstOperationRoot<T,SRanges...>
MutableArrayBase<T,SRanges...>::operator()(const std::shared_ptr<typename SRanges::IndexType>&... inds) const
{
return ConstOperationRoot<T,SRanges...>(*this, inds...);
}
template <typename T, class... SRanges>
ConstOperationRoot<T,SRanges...>
MutableArrayBase<T,SRanges...>::op(const std::shared_ptr<CIndexType>& ind) const
{
return ConstOperationRoot<T,SRanges...>(data(), *ind);
}
template <typename T, class... SRanges>
template <class... MappedRanges>
OperationRoot<T,MappedRanges...>
MutableArrayBase<T,SRanges...>::m(const std::shared_ptr<typename MappedRanges::IndexType>&... inds)
{
static_assert(sizeof...(SRanges) == sizeof...(MappedRanges),
"number of mapped ranges must be equal to number of original ranges");
return OperationRoot<T,MappedRanges...>(*this, inds...);
}
template <typename T, class... SRanges>
template <class... MappedRanges>
ConstOperationRoot<T,MappedRanges...>
MutableArrayBase<T,SRanges...>::m(const std::shared_ptr<typename MappedRanges::IndexType>&... inds) const
{
static_assert(sizeof...(SRanges) == sizeof...(MappedRanges),
"number of mapped ranges must be equal to number of original ranges");
return ConstOperationRoot<T,MappedRanges...>(*this, inds...);
}
} // end namespace CNORXZ

View file

@ -1,187 +0,0 @@
#ifndef __cxz_array_base_h__
#define __cxz_array_base_h__
#include <cstdlib>
#include <vector>
#include <memory>
#include <algorithm>
#include "base_def.h"
#include "mbase_def.h"
#include "ranges/rheader.h"
namespace CNORXZ
{
template <class IndexType>
using IPTR = std::shared_ptr<IndexType>;
template <class IndexType1, class IndexType2>
inline auto operator|(const IPTR<IndexType1>& i1, const IPTR<IndexType2>& i2)
-> decltype(std::make_tuple(i1,i2))
{
return std::make_tuple(i1,i2);
}
template <class IndexType1, class... IndexTypes2>
inline auto operator|(const IPTR<IndexType1>& i1,
const std::tuple<IPTR<IndexTypes2>...>& i2)
-> decltype(std::tuple_cat(std::make_tuple(i1),i2))
{
return std::tuple_cat(std::make_tuple(i1),i2);
}
template <class IndexType2, class... IndexTypes1>
inline auto operator|(const std::tuple<IPTR<IndexTypes1>...>& i1,
const IPTR<IndexType2>& i2)
-> decltype(std::tuple_cat(i1,std::make_tuple(i2)))
{
return std::tuple_cat(i1,std::make_tuple(i2));
}
template <class IndexType>
inline auto operator~(const IPTR<IndexType>& i)
-> decltype(std::make_tuple(i))
{
return std::make_tuple(i);
}
// Explicitely specify subranges in template argument !!!
template <typename T, class... SRanges>
class ArrayBase
{
public:
typedef T value_type;
typedef ContainerRange<SRanges...> CRange;
typedef ConstContainerIndex<T,typename SRanges::IndexType...> CIndexType;
typedef ContainerIndex<T,typename SRanges::IndexType...> IndexType;
protected:
bool mInit = false;
std::shared_ptr<CRange> mRange;
std::shared_ptr<CIndexType> mProtoI;
public:
//DEFAULT_MEMBERS(ArrayBase);
ArrayBase(const std::shared_ptr<SRanges>&... 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 <typename X>
const T& operator[](const ConstContainerIndex<X,typename SRanges::IndexType...>& i);
const T& operator[](const std::tuple<IPTR<typename SRanges::IndexType>...>& 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<CRange>& range() const;
virtual bool isConst() const;
virtual std::shared_ptr<ArrayBase<T,AnonymousRange> > anonymous(bool slice = false) const = 0;
virtual ConstOperationRoot<T,SRanges...>
op(const std::shared_ptr<CIndexType>& ind) const;
virtual ConstOperationRoot<T,SRanges...>
operator()(const std::shared_ptr<typename SRanges::IndexType>&... inds) const;
template <class... MappedRanges>
ConstOperationRoot<T,MappedRanges...>
m(const std::shared_ptr<typename MappedRanges::IndexType>&... inds) const;
virtual bool isInit() const;
template <size_t N>
auto getRangePtr() const
-> decltype(mRange->template getPtr<N>());
};
template <typename T, class... SRanges>
class MutableArrayBase : public ArrayBase<T,SRanges...>
{
public:
typedef ContainerRange<SRanges...> CRange;
typedef ArrayBase<T,SRanges...> MAB;
typedef ContainerIndex<T,typename SRanges::IndexType...> IndexType;
typedef ConstContainerIndex<T,typename SRanges::IndexType...> CIndexType;
using ArrayBase<T,SRanges...>::operator[];
using ArrayBase<T,SRanges...>::at;
using ArrayBase<T,SRanges...>::data;
using ArrayBase<T,SRanges...>::begin;
using ArrayBase<T,SRanges...>::end;
using ArrayBase<T,SRanges...>::cbegin;
using ArrayBase<T,SRanges...>::cend;
DEFAULT_MEMBERS(MutableArrayBase);
MutableArrayBase(const std::shared_ptr<SRanges>&... ranges);
MutableArrayBase(const typename CRange::Space& space);
template <typename X>
T& operator[](const ConstContainerIndex<X,typename SRanges::IndexType...>& i);
T& operator[](const std::tuple<IPTR<typename SRanges::IndexType>...>& 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<T,SRanges...>
op(const std::shared_ptr<CIndexType>& ind) const override;
virtual ConstOperationRoot<T,SRanges...>
operator()(const std::shared_ptr<typename SRanges::IndexType>&... inds) const override;
virtual OperationRoot<T,SRanges...>
op(const std::shared_ptr<CIndexType>& ind);
virtual OperationRoot<T,SRanges...> operator()(const std::shared_ptr<typename SRanges::IndexType>&... inds);
template <class... MappedRanges>
OperationRoot<T,MappedRanges...>
m(const std::shared_ptr<typename MappedRanges::IndexType>&... inds);
template <class... MappedRanges>
ConstOperationRoot<T,MappedRanges...>
m(const std::shared_ptr<typename MappedRanges::IndexType>&... inds) const;
};
} // end namespace CNORXZ
/* ========================= *
* --- TEMPLATE CODE --- *
* ========================= */
#endif

View file

@ -1,448 +0,0 @@
#include "high_level_operation.h"
namespace CNORXZ
{
template <typename T, class Op>
DynamicO<T> mkDynOp1(const Op& op)
{
return DynamicO<T>(op);
}
template <class ROP>
template <class... Indices>
template <class Op, class... Ops>
void HighLevelOpBase<ROP>::RetT<Indices...>::appendOuterM(const Op& op, const Ops&... ops)
{
// does not check anything regarding input !!!
if(outer.init()){
outer = mkDynOp1<size_t>(mkMOp<size_t>(outer,op,ops...));
}
else {
outer = mkDynOp1<size_t>(mkMOp<size_t>(op,ops...));
}
}
template <class ROP>
template <class... Indices>
void HighLevelOpBase<ROP>::RetT<Indices...>::appendOuterM()
{}
template <class ROP>
template <class... Indices>
void HighLevelOpBase<ROP>::RetT<Indices...>::appendOuter(const DynamicO<size_t>& in)
{
if(in.init()){
if(outer.init()){
outer = mkDynOp1<size_t>(mkMOp<size_t>(outer,in));
}
else {
outer = in;
}
}
}
template <class ROP>
template <class... Indices>
void HighLevelOpBase<ROP>::RetT<Indices...>::appendOuter(const RetT& in)
{
appendOuter(in.outer);
}
template <class ROP>
HighLevelOpRoot<ROP>::HighLevelOpRoot(const ROP& op) : mOp(op) {}
template <class ROP>
bool HighLevelOpRoot<ROP>::root() const
{
return true;
}
template <class ROP>
template <class... Inds>
auto HighLevelOpRoot<ROP>::xcreate(const std::shared_ptr<Inds>&... inds)
-> typename B::template RetT<Inds...>
{
assert(0);
return typename B::template RetT<Inds...>();
}
template <class ROP>
ROP* HighLevelOpRoot<ROP>::get()
{
return &mOp;
}
template <class ROP>
auto HighLevelOpRoot<ROP>::vget()
-> VOP*
{
return nullptr;
}
template <class ROP>
HighLevelOpValue<ROP>::HighLevelOpValue(const VOP& op) : mOp(op) {}
template <class ROP>
bool HighLevelOpValue<ROP>::root() const
{
return true;
}
template <class ROP>
template <class... Inds>
auto HighLevelOpValue<ROP>::xcreate(const std::shared_ptr<Inds>&... inds)
-> typename B::template RetT<Inds...>
{
assert(0);
return typename B::template RetT<Inds...>();
}
template <class ROP>
ROP* HighLevelOpValue<ROP>::get()
{
return nullptr;
}
template <class ROP>
auto HighLevelOpValue<ROP>::vget()
-> VOP*
{
return &mOp;
}
namespace
{
template <size_t N, class... Indices>
struct Create
{
template <class ROP, class OpF, class... OPs>
struct ccx
{
template <size_t M, class... DOPs>
static inline void
cccx(typename HighLevelOpBase<ROP>::template RetT<Indices...>& res,
const std::array<std::shared_ptr<HighLevelOpBase<ROP>>,M>& in,
const std::shared_ptr<Indices>&... inds,
const OPs&... ops,
const DOPs&... dops)
{
//static_assert(N > 0, "N > 0 failed");
auto& inn = std::get<N>(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<N-1,Indices...>::template ccx<ROP,OpF,OP,OPs...>::template cccx<M>
(res, in, inds..., op, ops..., dop, dops...);
}
else {
res.op = mkDynOutOp(mkFOp<OpF>(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<decltype(*op)>::type OP;
typedef typename std::remove_reference<decltype(*vop)>::type VOP;
if(op != nullptr){
Create<N-1,Indices...>::template ccx<ROP,OpF,OP,OPs...>::template cccx<M>
(res, in, inds..., *op, ops..., dops...);
}
else {
Create<N-1,Indices...>::template ccx<ROP,OpF,VOP,OPs...>::template cccx<M>
(res, in, inds..., *vop, ops..., dops...);
}
}
else {
if(op != nullptr){
res.op = mkDynOutOp(mkFOp<OpF>(*op,ops...), inds...);
}
else {
res.op = mkDynOutOp(mkFOp<OpF>(*vop,ops...), inds...);
}
res.appendOuterM(dops.op...);
}
}
}
};
};
}
template <class ROP, class OpF, size_t N>
HighLevelOp<ROP,OpF,N>::HighLevelOp(std::array<std::shared_ptr<HighLevelOpBase<ROP>>,N> in) : mIn(in) {}
template <class ROP, class OpF, size_t N>
bool HighLevelOp<ROP,OpF,N>::root() const
{
return false;
}
template <class ROP, class OpF, size_t N>
ROP* HighLevelOp<ROP,OpF,N>::get()
{
assert(0);
return nullptr;
}
template <class ROP, class OpF, size_t N>
auto HighLevelOp<ROP,OpF,N>::vget()
-> VOP*
{
assert(0);
return nullptr;
}
template <class ROP, class OpF, size_t N>
template <class... Inds>
auto HighLevelOp<ROP,OpF,N>::xcreate(const std::shared_ptr<Inds>&... inds)
-> typename B::template RetT<Inds...>
{
typename B::template RetT<Inds...> res;
Create<N-1,Inds...>::template ccx<ROP,OpF>::template cccx<N>
(res,mIn,inds...);
return res;
}
template <class ROP>
HighLevelOpHolder<ROP>::HighLevelOpHolder(const std::shared_ptr<HighLevelOpBase<ROP>>& op) : mOp(op) {}
template <class ROP>
bool HighLevelOpHolder<ROP>::root() const
{
return mOp->root();
}
template <class ROP>
template <class... Inds>
auto HighLevelOpHolder<ROP>::create(const std::shared_ptr<Inds>&... inds) const
-> decltype(mOp->create(inds...))
{
return mOp->create(inds...);
}
template <class ROP>
auto HighLevelOpHolder<ROP>::get()
-> decltype(mOp->get())
{
return mOp->get();
}
template <class ROP>
std::shared_ptr<HighLevelOpBase<ROP>> HighLevelOpHolder<ROP>::op() const
{
return mOp;
}
template <class ROP>
HighLevelOpHolder<ROP> HighLevelOpHolder<ROP>::operator*(const HighLevelOpHolder& in) const
{
return HighLevelOpHolder<ROP>
( std::make_shared<HighLevelOp<ROP,multipliesx<double,double>,2>>
( std::array<std::shared_ptr<HighLevelOpBase<ROP>>,2>({mOp, in.mOp}) ) );
}
template <class ROP>
HighLevelOpHolder<ROP> HighLevelOpHolder<ROP>::operator+(const HighLevelOpHolder& in) const
{
return HighLevelOpHolder<ROP>
( std::make_shared<HighLevelOp<ROP,plusx<double,double>,2>>
( std::array<std::shared_ptr<HighLevelOpBase<ROP>>,2>({mOp, in.mOp}) ) );
}
template <class ROP>
HighLevelOpHolder<ROP> HighLevelOpHolder<ROP>::operator-(const HighLevelOpHolder& in) const
{
return HighLevelOpHolder<ROP>
( std::make_shared<HighLevelOp<ROP,minusx<double,double>,2>>
( std::array<std::shared_ptr<HighLevelOpBase<ROP>>,2>({mOp, in.mOp}) ) );
}
template <class ROP>
HighLevelOpHolder<ROP> HighLevelOpHolder<ROP>::operator/(const HighLevelOpHolder& in) const
{
return HighLevelOpHolder<ROP>
( std::make_shared<HighLevelOp<ROP,dividesx<double,double>,2>>
( std::array<std::shared_ptr<HighLevelOpBase<ROP>>,2>({mOp, in.mOp}) ) );
}
template <class F, class ROP, class... ROPs>
HighLevelOpHolder<ROP> mkSFunc(const HighLevelOpHolder<ROP>& a, const HighLevelOpHolder<ROPs>&... as)
{
constexpr size_t N = sizeof...(ROPs)+1;
return HighLevelOpHolder<ROP>
( std::make_shared<HighLevelOp<ROP,F,N>>
( std::array<std::shared_ptr<HighLevelOpBase<ROP>>,N>({a.op(), as.op()...}) ) );
}
template <class ROP>
template <class... Indices>
HighLevelOpHolder<ROP>& HighLevelOpHolder<ROP>::xassign(const HighLevelOpHolder& in,
const std::shared_ptr<DynamicIndex>& di,
const std::shared_ptr<Indices>&... 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 <class ROP>
template <class... Indices>
HighLevelOpHolder<ROP>& HighLevelOpHolder<ROP>::xplus(const HighLevelOpHolder& in,
const std::shared_ptr<DynamicIndex>& di,
const std::shared_ptr<Indices>&... 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 <class Ind1, class Ind2, class... Inds>
std::string printInd(const std::shared_ptr<Ind1>& ind1, const std::shared_ptr<Ind2>& ind2,
const std::shared_ptr<Inds>&... inds)
{
return std::to_string(reinterpret_cast<std::intptr_t>(ind1.get())) + "(" +
std::to_string(ind1->max()) + "), " + printInd(ind2, inds...);
}
template <class Ind1>
std::string printInd(const std::shared_ptr<Ind1>& ind1)
{
return std::to_string(reinterpret_cast<std::intptr_t>(ind1.get())) + "(" + std::to_string(ind1->max()) + ")";
}
template <class ROP>
template <class MIndex, class... Indices>
HighLevelOpHolder<ROP>& HighLevelOpHolder<ROP>::assign(const HighLevelOpHolder& in,
const std::shared_ptr<MIndex>& mi,
const std::shared_ptr<Indices>&... inds)
{
auto xx = mkArrayPtr<double>(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<size_t> gexp;
if(dop.outer.init()){
gexp = mkDynOp1<size_t>(mkMOp<size_t>(dop.outer,dop.op));
}
else {
gexp = mkDynOp1<size_t>(mkMOp<size_t>(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<size_t,1>({1}), std::array<size_t,1>({0}));
return mkGetExpr(gexp, xloop); });
mi->pifor(1,loop)();
return *this;
}
template <class ROP>
template <class MIndex, class... Indices>
HighLevelOpHolder<ROP>& HighLevelOpHolder<ROP>::plus(const HighLevelOpHolder& in,
const std::shared_ptr<MIndex>& mi,
const std::shared_ptr<Indices>&... inds)
{
auto xx = mkArrayPtr<double>(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<size_t> gexp;
if(dop.outer.init()){
gexp = mkDynOp1<size_t>(mkMOp<size_t>(dop.outer,dop.op));
}
else {
gexp = mkDynOp1<size_t>(mkMOp<size_t>(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<size_t,1>({1}), std::array<size_t,1>({0}));
return mkGetExpr(gexp, xloop); });
mi->pifor(1,loop)();
return *this;
}
template <class ROP>
HighLevelOpHolder<ROP> mkHLO(const ROP& op)
{
return HighLevelOpHolder<ROP>(std::make_shared<HighLevelOpRoot<ROP>>( op ) );
}
template <class ROP>
HighLevelOpHolder<ROP> mkHLOV(double val)
{
return HighLevelOpHolder<ROP>(std::make_shared<HighLevelOpValue<ROP>>
( OperationValue<double>(val) ) );
}
#define SP " "
#define regFunc1(fff) template <class ROP> \
HighLevelOpHolder<ROP> hl_##fff (const HighLevelOpHolder<ROP>& in) \
{ return HighLevelOpHolder<ROP>( std::make_shared<HighLevelOp<ROP,x_##fff <double>,1>> \
( std::array<std::shared_ptr<HighLevelOpBase<ROP>>,1>( {in.op()} ) ) ); } \
#include "extensions/math.h"
#undef regFunc1
#undef SP
}

View file

@ -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<CI> CIP;
typedef OperationRoot<double,CR,DynamicRange> OpCD;
typedef OperationRoot<double,DynamicRange> OpD;
extern template class OperationRoot<double,CR,DynamicRange>;
extern template class OperationRoot<double,DynamicRange>;
template <typename T, class Op>
DynamicO<T> mkDynOp1(const Op& op);
std::shared_ptr<DynamicIndex> mkSubSpaceX(const std::shared_ptr<DynamicIndex>& di, size_t max);
template <class ROP>
class HighLevelOpBase
{
public:
typedef OperationValue<double> VOP;
template <class... Indices>
struct RetT
{
DynamicO<OpH<OperationRoot<double,typename Indices::RangeType...>>> op;
DynamicO<size_t> outer;
template <class Op, class... Ops>
void appendOuterM(const Op& op, const Ops&... ops);
void appendOuterM();
void appendOuter(const DynamicO<size_t>& in);
void appendOuter(const RetT& in);
};
virtual bool root() const = 0;
#define reg_ind1(I1) virtual RetT<I1> create \
(const std::shared_ptr<I1>& ind1) = 0
#define reg_ind2(I1,I2) virtual RetT<I1,I2> create \
(const std::shared_ptr<I1>& ind1,const std::shared_ptr<I2>& ind2) = 0
#define reg_ind3(I1,I2,I3) virtual RetT<I1,I2,I3> create \
(const std::shared_ptr<I1>& ind1,const std::shared_ptr<I2>& ind2,const std::shared_ptr<I3>& 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 ROP>
class HighLevelOpRoot : public HighLevelOpBase<ROP>
{
private:
typedef HighLevelOpBase<ROP> B;
typedef typename B::VOP VOP;
template <class... Inds>
typename B::template RetT<Inds...> xcreate(const std::shared_ptr<Inds>&... inds);
ROP mOp;
public:
HighLevelOpRoot(const ROP& op);
virtual bool root() const override final;
#define reg_ind1(I1) virtual typename B::template RetT<I1> create \
(const std::shared_ptr<I1>& ind1) \
override final { return xcreate(ind1); }
#define reg_ind2(I1,I2) virtual typename B::template RetT<I1,I2> create \
(const std::shared_ptr<I1>& ind1, const std::shared_ptr<I2>& ind2) \
override final { return xcreate(ind1,ind2); }
#define reg_ind3(I1,I2,I3) virtual typename B::template RetT<I1,I2,I3> create \
(const std::shared_ptr<I1>& ind1, const std::shared_ptr<I2>& ind2, const std::shared_ptr<I3>& 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<OpCD>;
extern template class HighLevelOpBase<OpD>;
extern template class HighLevelOpRoot<OpCD>;
extern template class HighLevelOpRoot<OpD>;
template <class ROP>
class HighLevelOpValue : public HighLevelOpBase<ROP>
{
private:
typedef HighLevelOpBase<ROP> B;
typedef typename B::VOP VOP;
template <class... Inds>
typename B::template RetT<Inds...> xcreate(const std::shared_ptr<Inds>&... 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 <class OpF, class... Ops>
auto mkFOp(const Ops&... ops)
{
return Operation<double,OpF,Ops...>(ops...);
}
template <class ROP, class OpF, size_t N>
class HighLevelOp : public HighLevelOpBase<ROP>
{
public:
typedef HighLevelOpBase<ROP> B;
typedef typename B::VOP VOP;
private:
std::array<std::shared_ptr<HighLevelOpBase<ROP>>,N> mIn;
template <class... Inds>
auto xcreate(const std::shared_ptr<Inds>&... inds)
-> typename B::template RetT<Inds...>;
public:
HighLevelOp(std::array<std::shared_ptr<HighLevelOpBase<ROP>>,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<OpCD,plusx<double,double>,2>;
extern template class HighLevelOp<OpCD,minusx<double,double>,2>;
extern template class HighLevelOp<OpCD,multipliesx<double,double>,2>;
extern template class HighLevelOp<OpCD,dividesx<double,double>,2>;
extern template class HighLevelOp<OpD,plusx<double,double>,2>;
extern template class HighLevelOp<OpD,minusx<double,double>,2>;
extern template class HighLevelOp<OpD,multipliesx<double,double>,2>;
extern template class HighLevelOp<OpD,dividesx<double,double>,2>;
#define regFunc1(fff) \
extern template class HighLevelOp<OpCD,x_##fff<double>,1>; \
extern template class HighLevelOp<OpD,x_##fff<double>,1>;
#include "extensions/math.h"
#undef regFunc1
template <class ROP>
class HighLevelOpHolder
{
private:
std::shared_ptr<HighLevelOpBase<ROP>> 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<HighLevelOpBase<ROP>>& op);
bool root() const;
template <class... Inds>
auto create(const std::shared_ptr<Inds>&... inds) const
-> decltype(mOp->create(inds...));
auto get() -> decltype(mOp->get());
std::shared_ptr<HighLevelOpBase<ROP>> 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 <class... Indices>
HighLevelOpHolder& xassign(const HighLevelOpHolder& in,
const std::shared_ptr<DynamicIndex>& di,
const std::shared_ptr<Indices>&... is);
template <class... Indices>
HighLevelOpHolder& xplus(const HighLevelOpHolder& in,
const std::shared_ptr<DynamicIndex>& di,
const std::shared_ptr<Indices>&... is);
template <class MIndex, class... Indices>
HighLevelOpHolder& assign(const HighLevelOpHolder& in,
const std::shared_ptr<MIndex>& mi,
const std::shared_ptr<Indices>&... inds);
template <class MIndex, class... Indices>
HighLevelOpHolder& plus(const HighLevelOpHolder& in,
const std::shared_ptr<MIndex>& mi,
const std::shared_ptr<Indices>&... inds);
};
extern template class HighLevelOpHolder<OpCD>;
extern template class HighLevelOpHolder<OpD>;
template <class F, class ROP, class... ROPs>
HighLevelOpHolder<ROP> mkSFunc(const HighLevelOpHolder<ROP>& a, const HighLevelOpHolder<ROPs>&... as);
template <class ROP>
HighLevelOpHolder<ROP> mkHLO(const ROP& op);
template <class ROP>
HighLevelOpHolder<ROP> mkHLOV(double val);
extern template HighLevelOpHolder<OpCD> mkHLO(const OpCD& op);
extern template HighLevelOpHolder<OpD> mkHLO(const OpD& op);
extern template HighLevelOpHolder<OpCD> mkHLOV(double val);
extern template HighLevelOpHolder<OpD> mkHLOV(double val);
#define regFunc1(fff) template <class ROP> \
HighLevelOpHolder<ROP> hl_##fff (const HighLevelOpHolder<ROP>& in);
#include "extensions/math.h"
#undef regFunc1
#define regFunc1(fff) template <class ROP> \
HighLevelOpHolder<ROP> hl_##fff (const HighLevelOpHolder<ROP>& in); \
extern template HighLevelOpHolder<OpCD> hl_##fff (const HighLevelOpHolder<OpCD>& in); \
extern template HighLevelOpHolder<OpD> hl_##fff (const HighLevelOpHolder<OpD>& in);
#include "extensions/math.h"
#undef regFunc1
}
#endif

View file

@ -1,3 +0,0 @@
#include "high_level_operation.h"
#include "high_level_operation.cc.h"

View file

@ -1,704 +0,0 @@
#include "map_range.h"
#include <type_traits>
namespace CNORXZ
{
namespace
{
using namespace CNORXZInternal;
}
/**************
* OpExpr *
**************/
template <class Op, class Index, class Expr, SpaceType STYPE>
OpExpr<Op,Index,Expr,STYPE>::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<std::intptr_t>( mIndPtr )))
mExt( mOp.rootSteps( reinterpret_cast<std::intptr_t>( mIndPtr ) ).extend
( ex.rootSteps( reinterpret_cast<std::intptr_t>( mIndPtr ) ) ) )
{
assert(mIndPtr != nullptr);
}
template <class Op, class Index, class Expr, SpaceType STYPE>
std::shared_ptr<ExpressionBase> OpExpr<Op,Index,Expr,STYPE>::deepCopy() const
{
return std::make_shared<OpExpr<Op,Index,Expr,STYPE>>(*this);
}
template <class Op, class Index, class Expr, SpaceType STYPE>
inline void OpExpr<Op,Index,Expr,STYPE>::operator()(size_t mlast, DExt last)
{
operator()(mlast, std::dynamic_pointer_cast<ExtT<ExtType>>(last)->ext());
}
template <class Op, class Index, class Expr, SpaceType STYPE>
inline void OpExpr<Op,Index,Expr,STYPE>::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<ForType::DEFAULT>::valuex(mlast, mStep, pos);
mExpr(mnpos, getX<NEXT>( npos ) );
}
}
template <class Op, class Index, class Expr, SpaceType STYPE>
inline void OpExpr<Op,Index,Expr,STYPE>::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<ForType::DEFAULT>::valuex(mlast, mStep, pos);
mExpr(mnpos, getX<NEXT>( npos ));
}
}
template <class Op, class Index, class Expr, SpaceType STYPE>
auto OpExpr<Op,Index,Expr,STYPE>::rootSteps(std::intptr_t iPtrNum) const
-> ExtType
{
return mOp.rootSteps(iPtrNum).extend( mExpr.rootSteps(iPtrNum) );
//return mExpr.rootSteps(iPtrNum).extend( mOp.rootSteps(iPtrNum) );
}
template <class Op, class Index, class Expr, SpaceType STYPE>
DExt OpExpr<Op,Index,Expr,STYPE>::dRootSteps(std::intptr_t iPtrNum) const
{
return std::make_shared<ExtT<ExtType>>(rootSteps(iPtrNum));
}
template <class Op, class Index, class Expr, SpaceType STYPE>
DExt OpExpr<Op,Index,Expr,STYPE>::dExtension() const
{
return std::make_shared<ExtT<ExtType>>(mExt);
}
/******************
* MapIndex *
******************/
template <class OIType, class Op, SpaceType XSTYPE, class... Indices>
template <class MRange>
GenMapIndex<OIType,Op,XSTYPE,Indices...>::GenMapIndex(const std::shared_ptr<MRange>& range) :
IndexInterface<GenMapIndex<OIType,Op,XSTYPE,Indices...>,typename Op::value_type>(range, 0)
{
std::get<sizeof...(Indices)>(mBlockSizes) = 1;
sfor_mn<sizeof...(Indices),0>
( [&](auto i) {
auto r = range->template getPtr<i>();
std::get<i>(mIPack) = r->beginPtr();
*std::get<i>(mIPack) = 0;
std::get<i>(mBlockSizes) = sfor_p<i,sizeof...(Indices)>
( [&](auto j) { return std::get<j>(mIPack)->max(); } ,
[&](auto a, auto b) { return a * b; });
return 0;
});
IB::mPos = sfor_m<sizeof...(Indices),0>
( [&](auto i) { return std::get<i>(mIPack); },
[&](auto a, auto b) {return a->pos() + b*a->max();}, 0 );
mOutIndex = std::make_shared<OIType>
( std::dynamic_pointer_cast<RangeType>( IB::mRangePtr )->outRange()->begin() );
}
template <class OIType, class Op, SpaceType XSTYPE, class... Indices>
template <size_t DIR>
GenMapIndex<OIType,Op,XSTYPE,Indices...>& GenMapIndex<OIType,Op,XSTYPE,Indices...>::up()
{
static_assert(DIR < sizeof...(Indices), "DIR exceeds number of sub-indices");
IB::mPos += sfor_p<DIR,sizeof...(Indices)>
( [&](auto i) { return std::get<i>(mIPack)->max(); },
[&](auto a, auto b) { return a * b; } );
sfor_m<DIR+1,0>
( [&](auto i) {
auto& si = *std::get<i>( mIPack );
if(si.last() and i != 0) { si = 0; return true; }
else { ++si; return false; }
return false;
} );
return *this;
}
template <class OIType, class Op, SpaceType XSTYPE, class... Indices>
template <size_t DIR>
GenMapIndex<OIType,Op,XSTYPE,Indices...>& GenMapIndex<OIType,Op,XSTYPE,Indices...>::down()
{
static_assert(DIR < sizeof...(Indices), "DIR exceeds number of sub-indices");
IB::mPos -= sfor_p<DIR,sizeof...(Indices)>
( [&](auto i) { return std::get<i>(mIPack)->max(); },
[&](auto a, auto b) { return a * b; } );
sfor_m<DIR+1,0>
( [&](auto i) {
auto& si = *std::get<i>( mIPack );
if(si.first() and i != 0) { si = si.max()-1; return true; }
else { --si; return false; }
return false;
} );
return *this;
}
template <class OIType, class Op, SpaceType XSTYPE, class... Indices>
template <size_t N>
auto GenMapIndex<OIType,Op,XSTYPE,Indices...>::get() const -> decltype( *std::get<N>( mIPack ) )&
{
return *std::get<N>(mIPack);
}
template <class OIType, class Op, SpaceType XSTYPE, class... Indices>
template <size_t N>
auto GenMapIndex<OIType,Op,XSTYPE,Indices...>::getPtr() const -> decltype( std::get<N>( mIPack ) )&
{
return std::get<N>(mIPack);
}
template <class OIType, class Op, SpaceType XSTYPE, class... Indices>
auto GenMapIndex<OIType,Op,XSTYPE,Indices...>::outIndex() const -> std::shared_ptr<OIType>
{
return mOutIndex;
}
template <class OIType, class Op, SpaceType XSTYPE, class... Indices>
GenMapIndex<OIType,Op,XSTYPE,Indices...>& GenMapIndex<OIType,Op,XSTYPE,Indices...>::operator()(const std::shared_ptr<Indices>&... indices)
{
return (*this)(std::make_tuple(indices...));
}
template <class OIType, class Op, SpaceType XSTYPE, class... Indices>
GenMapIndex<OIType,Op,XSTYPE,Indices...>& GenMapIndex<OIType,Op,XSTYPE,Indices...>::operator()(const std::tuple<std::shared_ptr<Indices>...>& indices)
{
sfor_pn<0,sizeof...(Indices)>
( [&](auto i) { std::get<i>(mIPack) = std::get<i>(indices); return 0; } );
RangeHelper::setIndexPack<sizeof...(Indices)-1>(mIPack, IB::mPos);
return *this;
}
template <class OIType, class Op, SpaceType XSTYPE, class... Indices>
IndexType GenMapIndex<OIType,Op,XSTYPE,Indices...>::type() const
{
return IndexType::MULTI;
}
template <class OIType, class Op, SpaceType XSTYPE, class... Indices>
GenMapIndex<OIType,Op,XSTYPE,Indices...>& GenMapIndex<OIType,Op,XSTYPE,Indices...>::operator=(size_t pos)
{
(*mOutIndex) = pos;
IB::mPos = mOutIndex->pos();
return *this;
}
template <class OIType, class Op, SpaceType XSTYPE, class... Indices>
GenMapIndex<OIType,Op,XSTYPE,Indices...>& GenMapIndex<OIType,Op,XSTYPE,Indices...>::operator++()
{
++(*mOutIndex);
IB::mPos = mOutIndex->pos();
return *this;
}
template <class OIType, class Op, SpaceType XSTYPE, class... Indices>
GenMapIndex<OIType,Op,XSTYPE,Indices...>& GenMapIndex<OIType,Op,XSTYPE,Indices...>::operator--()
{
--(*mOutIndex);
IB::mPos = mOutIndex->pos();
return *this;
}
template <class OIType, class Op, SpaceType XSTYPE, class... Indices>
int GenMapIndex<OIType,Op,XSTYPE,Indices...>::pp(std::intptr_t idxPtrNum)
{
mOutIndex->pp(idxPtrNum);
IB::mPos = mOutIndex->pos();
return 1;
}
template <class OIType, class Op, SpaceType XSTYPE, class... Indices>
int GenMapIndex<OIType,Op,XSTYPE,Indices...>::mm(std::intptr_t idxPtrNum)
{
mOutIndex->mm(idxPtrNum);
IB::mPos = mOutIndex->pos();
return 1;
}
template <class OIType, class Op, SpaceType XSTYPE, class... Indices>
std::string GenMapIndex<OIType,Op,XSTYPE,Indices...>::stringMeta() const
{
return std::dynamic_pointer_cast<RangeType>( IB::mRangePtr )->stringMeta(IB::mPos);
}
template <class OIType, class Op, SpaceType XSTYPE, class... Indices>
typename GenMapIndex<OIType,Op,XSTYPE,Indices...>::MetaType GenMapIndex<OIType,Op,XSTYPE,Indices...>::meta() const
{
return mOutIndex->meta();
}
template <class OIType, class Op, SpaceType XSTYPE, class... Indices>
GenMapIndex<OIType,Op,XSTYPE,Indices...>& GenMapIndex<OIType,Op,XSTYPE,Indices...>::at(const MetaType& metaPos)
{
mOutIndex->at(metaPos);
IB::mPos = mOutIndex->pos();
return *this;
}
template <class OIType, class Op, SpaceType XSTYPE, class... Indices>
size_t GenMapIndex<OIType,Op,XSTYPE,Indices...>::posAt(const MetaType& metaPos) const
{
return range()->outRange()->getMeta(metaPos);
}
template <class OIType, class Op, SpaceType XSTYPE, class... Indices>
size_t GenMapIndex<OIType,Op,XSTYPE,Indices...>::dim() const
{
return sizeof...(Indices);
}
template <class OIType, class Op, SpaceType XSTYPE, class... Indices>
bool GenMapIndex<OIType,Op,XSTYPE,Indices...>::first() const
{
return IB::mPos == 0;
}
template <class OIType, class Op, SpaceType XSTYPE, class... Indices>
bool GenMapIndex<OIType,Op,XSTYPE,Indices...>::last() const
{
return IB::mPos == IB::mMax - 1;
}
template <class OIType, class Op, SpaceType XSTYPE, class... Indices>
std::shared_ptr<typename GenMapIndex<OIType,Op,XSTYPE,Indices...>::RangeType>
GenMapIndex<OIType,Op,XSTYPE,Indices...>::range() const
{
return std::dynamic_pointer_cast<RangeType>( IB::mRangePtr );
}
template <class OIType, class Op, SpaceType XSTYPE, class... Indices>
template <size_t N>
auto GenMapIndex<OIType,Op,XSTYPE,Indices...>::getPtr() -> decltype( std::get<N>( mIPack ) )&
{
return std::get<N>(mIPack);
}
template <class OIType, class Op, SpaceType XSTYPE, class... Indices>
size_t GenMapIndex<OIType,Op,XSTYPE,Indices...>::getStepSize(size_t n) const
{
if(n >= sizeof...(Indices)){
assert(0);
// throw !!
}
return mBlockSizes[n+1];
}
template <class OIType, class Op, SpaceType XSTYPE, class... Indices>
template <class Exprs>
auto GenMapIndex<OIType,Op,XSTYPE,Indices...>::ifor(size_t step, Exprs exs) const
{
return RangeHelper::mkFor<0>
(0, mIPack, mBlockSizes,
OpExpr<Op,GenMapIndex<OIType,Op,XSTYPE,Indices...>,Exprs,XSTYPE>
( range()->map(), this, step, exs ));
}
template <class OIType, class Op, SpaceType XSTYPE, class... Indices>
template <class Exprs>
auto GenMapIndex<OIType,Op,XSTYPE,Indices...>::pifor(size_t step, Exprs exs) const
{
return ifor(step, exs);
}
template <class OIType, class Op, SpaceType XSTYPE, class... Indices>
template <class Exprs>
auto GenMapIndex<OIType,Op,XSTYPE,Indices...>::iforh(size_t step, Exprs exs) const
{
return ifor(step, exs);
}
/*************************
* MapRangeFactory *
*************************/
template <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
template <class MA>
GenMapRangeFactory<ORType,Op,XSTYPE,Ranges...>::GenMapRangeFactory(const std::shared_ptr<ORType>& outr,
const std::tuple<Op,MA>& mapf,
const std::shared_ptr<Ranges>&... rs)
{
mProd = std::shared_ptr< GenMapRange<ORType,Op,XSTYPE,Ranges...> >
( new GenMapRange<ORType,Op,XSTYPE,Ranges...>( outr, mapf, rs... ) );
}
template <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
template <class MA>
GenMapRangeFactory<ORType,Op,XSTYPE,Ranges...>::GenMapRangeFactory(const std::shared_ptr<ORType>& outr,
const std::tuple<Op,MA>& mapf,
const typename GenMapRange<ORType,Op,XSTYPE,Ranges...>::Space& st)
{
mProd = std::shared_ptr< GenMapRange<ORType,Op,XSTYPE,Ranges...> >
( new GenMapRange<ORType,Op,XSTYPE,Ranges...>( outr, mapf, st ) );
}
template <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
template <class MA>
GenMapRangeFactory<ORType,Op,XSTYPE,Ranges...>::GenMapRangeFactory(const std::tuple<Op,MA>& mapf,
const std::shared_ptr<Ranges>&... rs)
{
mProd = std::shared_ptr< GenMapRange<ORType,Op,XSTYPE,Ranges...> >
( new GenMapRange<ORType,Op,XSTYPE,Ranges...>( mapf, rs... ) );
}
template <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
template <class MA>
GenMapRangeFactory<ORType,Op,XSTYPE,Ranges...>::GenMapRangeFactory(const std::tuple<Op,MA>& mapf,
const typename GenMapRange<ORType,Op,XSTYPE,Ranges...>::Space& st)
{
mProd = std::shared_ptr< GenMapRange<ORType,Op,XSTYPE,Ranges...> >
( new GenMapRange<ORType,Op,XSTYPE,Ranges...>( mapf, st ) );
}
template <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
std::shared_ptr<RangeBase> GenMapRangeFactory<ORType,Op,XSTYPE,Ranges...>::create()
{
mProd = checkIfCreated( std::dynamic_pointer_cast<oType>( mProd )->mSpace );
setSelf();
return mProd;
}
template <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
std::shared_ptr<RangeBase> GenMapRangeFactory<ORType,Op,XSTYPE,Ranges...>::checkIfCreated(const std::tuple<std::shared_ptr<Ranges>...>& ptp)
{
std::shared_ptr<RangeBase> 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::intptr_t>( std::get<i>(ptp).get() ) == x.second[i]; },
[&](auto a, auto b) { return a and b; } );
if(check){
out = x.first;
break;
}
}
}
if(not check){
vector<std::intptr_t> pv(sizeof...(Ranges));
sfor_pn<0,sizeof...(Ranges)>
( [&](auto i) { pv[i] = reinterpret_cast<std::intptr_t>( std::get<i>(ptp).get() ); return 0; } );
pv.push_back( reinterpret_cast<std::intptr_t>
( &std::dynamic_pointer_cast<oType>( mProd )->mMapf ) );
MapRangeFactoryProductMap::mAleadyCreated[mProd] = pv;
out = mProd;
}
return out;
}
/******************
* MapRange *
******************/
template <SpaceType XSTYPE>
struct OutRangeMaker
{};
template <>
struct OutRangeMaker<SpaceType::ANY>
{
template <class MapF, class ORType>
static void mk(std::shared_ptr<ORType>& outRange, Array<size_t,ORType>& mapMult, const MapF& mapf)
{
std::map<typename MapF::value_type,size_t> mult;
for(auto ii = mapf.begin(); ii.max() != ii.pos(); ++ii) {
mult[mapf[ii]]++;
}
vector<typename MapF::value_type> outmeta(mult.size());
vector<size_t> 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<ORType>( orf.create() );
mapMult = Array<size_t,ORType>( outRange, outmult );
}
};
template <>
struct OutRangeMaker<SpaceType::NONE>
{
template <class MapF, class ORType>
static void mk(std::shared_ptr<ORType>& outRange, Array<size_t,ORType>& mapMult, const MapF& mapf)
{
static_assert( std::is_same<size_t,typename MapF::value_type>::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<size_t> mult(max,0);
for(auto ii = mapf.begin(); ii.max() != ii.pos(); ++ii) {
mult[mapf[ii]]++;
}
vector<size_t> outmult(mult.size());
size_t cnt = 0;
for(auto& x: mult){
outmult[cnt++] = x;
}
typename ORType::FType orf(max);
outRange = std::dynamic_pointer_cast<ORType>( orf.create() );
mapMult = Array<size_t,ORType>( outRange, outmult );
}
};
template <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
template <class MA>
void GenMapRange<ORType,Op,XSTYPE,Ranges...>::mkOutRange(const MA& mapf)
{
//FunctionalArray<typename MapF::value_type,MapF,Ranges...> fma(mSpace, mMapf);
OutRangeMaker<XSTYPE>::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 <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
template <class MA>
GenMapRange<ORType,Op,XSTYPE,Ranges...>::GenMapRange(const std::shared_ptr<ORType>& outr, const std::tuple<Op,MA>& mapf,
const std::shared_ptr<Ranges>&... 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 <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
template <class MA>
GenMapRange<ORType,Op,XSTYPE,Ranges...>::GenMapRange(const std::shared_ptr<ORType>& outr, const std::tuple<Op,MA>& 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 <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
template <class MA>
GenMapRange<ORType,Op,XSTYPE,Ranges...>::GenMapRange(const std::tuple<Op,MA>& mapf,
const std::shared_ptr<Ranges>&... rs) :
mSpace(std::make_tuple(rs...)),
mMapf(std::get<0>(mapf))
{
mkOutRange(std::get<1>(mapf));
}
template <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
template <class MA>
GenMapRange<ORType,Op,XSTYPE,Ranges...>::GenMapRange(const std::tuple<Op,MA>& mapf, const Space& space) :
mSpace( space ),
mMapf(std::get<0>(mapf))
{
mkOutRange(std::get<1>(mapf));
}
template <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
template <size_t N>
auto GenMapRange<ORType,Op,XSTYPE,Ranges...>::get() const -> decltype( *std::get<N>( mSpace ) )&
{
return *std::get<N>(mSpace);
}
template <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
template <size_t N>
auto GenMapRange<ORType,Op,XSTYPE,Ranges...>::getPtr() const -> decltype( std::get<N>( mSpace ) )&
{
return std::get<N>(mSpace);
}
template <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
auto GenMapRange<ORType,Op,XSTYPE,Ranges...>::outRange() const -> std::shared_ptr<ORType>
{
return mOutRange;
}
template <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
const Op& GenMapRange<ORType,Op,XSTYPE,Ranges...>::map() const
{
return mMapf;
}
template <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
size_t GenMapRange<ORType,Op,XSTYPE,Ranges...>::dim() const
{
return sdim;
}
template <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
size_t GenMapRange<ORType,Op,XSTYPE,Ranges...>::size() const
{
return mOutRange->size();
}
template <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
SpaceType GenMapRange<ORType,Op,XSTYPE,Ranges...>::spaceType() const
{
return SpaceType::ANY;
}
template <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
const typename GenMapRange<ORType,Op,XSTYPE,Ranges...>::Space& GenMapRange<ORType,Op,XSTYPE,Ranges...>::space() const
{
return mSpace;
}
template <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
vector<size_t> GenMapRange<ORType,Op,XSTYPE,Ranges...>::typeNum() const
{
vector<size_t> o;
RangeHelper::getTypeNum<sizeof...(Ranges)-1>(o,mSpace);
return o;
}
template <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
size_t GenMapRange<ORType,Op,XSTYPE,Ranges...>::cmeta(char* target, size_t pos) const
{
//MetaType* xtarget = reinterpret_cast<MetaType*>(target);
assert(0);
return 0;
}
template <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
size_t GenMapRange<ORType,Op,XSTYPE,Ranges...>::cmetaSize() const
{
return RangeHelper::getCMetaSize<0>(mSpace);
}
template <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
std::string GenMapRange<ORType,Op,XSTYPE,Ranges...>::stringMeta(size_t pos) const
{
auto i = begin();
i = pos;
return "[ " + RangeHelper::getStringMeta<0>(i) + " ]";
}
template <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
vector<char> GenMapRange<ORType,Op,XSTYPE,Ranges...>::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));
sfor_pn<0,sizeof...(Ranges)>
( [&](auto i) {
vector<char> part = std::get<i>(mSpace)->data();
out.insert(out.end(), part.begin(), part.end());
return 0;
} );
return out;
}
template <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
DataHeader GenMapRange<ORType,Op,XSTYPE,Ranges...>::dataHeader() const
{
DataHeader h;
h.spaceType = static_cast<int>( SpaceType::ANY );
h.metaSize = sizeof...(Ranges);
h.multiple = 1;
return h;
}
template <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
typename GenMapRange<ORType,Op,XSTYPE,Ranges...>::IndexType GenMapRange<ORType,Op,XSTYPE,Ranges...>::begin() const
{
GenMapIndex<typename ORType::IndexType,Op,XSTYPE,typename Ranges::IndexType...>
i( std::dynamic_pointer_cast<GenMapRange<ORType,Op,XSTYPE,Ranges...> >
( std::shared_ptr<RangeBase>( RB::mThis ) ) );
i = 0;
return i;
}
template <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
typename GenMapRange<ORType,Op,XSTYPE,Ranges...>::IndexType GenMapRange<ORType,Op,XSTYPE,Ranges...>::end() const
{
GenMapIndex<typename ORType::IndexType,Op,XSTYPE,typename Ranges::IndexType...>
i( std::dynamic_pointer_cast<GenMapRange<ORType,Op,XSTYPE,Ranges...> >
( std::shared_ptr<RangeBase>( RB::mThis )) );
i = size();
return i;
}
template <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
auto GenMapRange<ORType,Op,XSTYPE,Ranges...>::mapMultiplicity() const
-> const Array<size_t,ORType>&
{
return mMapMult;
}
template <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
auto GenMapRange<ORType,Op,XSTYPE,Ranges...>::explMapMultiplicity() const
-> ConstSlice<size_t,GenMapRange>
{
/*
auto tmp = mMapMult;
return tmp.format( std::dynamic_pointer_cast<GenMapRange<ORType,Op,XSTYPE,Ranges...> >
( std::shared_ptr<RangeBase>( RB::mThis )) );
*/
return mMapMult.slformat(std::dynamic_pointer_cast<GenMapRange<ORType,Op,XSTYPE,Ranges...> >
( std::shared_ptr<RangeBase>( RB::mThis )));
}
template <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
vector<size_t> GenMapRange<ORType,Op,XSTYPE,Ranges...>::mapPos() const
{
return mMapPos;
}
/*
template <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
template <class... ERanges>
auto GenMapRange<ORType,Op,XSTYPE,Ranges...>::cat(const std::shared_ptr<MapRange<ERanges...> >& erange)
-> std::shared_ptr<GenMapRange<Ranges...,ERanges...> >
{
auto crange = std::tuple_cat(mSpace, erange->space());
MapRangeFactory<Ranges...,ERanges...> rf(crange);
return std::dynamic_pointer_cast<MapRange<Ranges...,ERanges...> >(rf.create());
}
*/
}

View file

@ -1,354 +0,0 @@
// -*- C++ -*-
#ifndef __cxz_map_range_h__
#define __cxz_map_range_h__
#include <cstdlib>
#include <tuple>
#include <memory>
#include <map>
#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 <class Func, class... Indices>
auto mkMapOp(const std::shared_ptr<Func>& func,
const std::shared_ptr<Indices>&... is)
-> decltype(std::make_tuple(FunctionalArray<typename Func::value_type,Func,
typename Indices::RangeType...>().exec(is...),
FunctionalArray<typename Func::value_type,Func,
typename Indices::RangeType...>()))
{
typedef FunctionalArray<typename Func::value_type,Func,typename Indices::RangeType...> 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 <class Op, class Index, class Expr, SpaceType STYPE = SpaceType::ANY>
//template <class MapF, class IndexPack, class Expr, SpaceType STYPE = SpaceType::ANY>
class OpExpr : public ExpressionBase
{
public:
//typedef typename Index::OIType OIType;
//typedef SingleIndex<typename Op::value_type,STYPE> 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<intptr_t>()).extend( mExpr.rootSteps(std::declval<intptr_t>()) )) 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<ExpressionBase> deepCopy() const override final;
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;
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 OIType, class Op, SpaceType XSTYPE, class... Indices>
class GenMapIndex : public IndexInterface<GenMapIndex<OIType,Op,XSTYPE,Indices...>,
typename Op::value_type>
//std::tuple<typename Indices::MetaType...> >
{
public:
typedef IndexInterface<GenMapIndex<OIType,Op,XSTYPE,Indices...>,
typename Op::value_type> IB;
//std::tuple<typename Indices::MetaType...> > IB;
typedef std::tuple<std::shared_ptr<Indices>...> IndexPack;
//typedef std::tuple<typename Indices::MetaType...> MetaType;
typedef typename Op::value_type MetaType;
typedef GenMapRange<typename OIType::RangeType,Op,XSTYPE,typename Indices::RangeType...> RangeType;
typedef GenMapIndex IType;
//typedef SingleIndex<typename Op::value_type,XSTYPE> 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<typename OIType::MetaType,typename Op::value_type>::value, "inconsitent value types" ); }
static constexpr SpaceType STYPE = XSTYPE;
static constexpr bool PARALLEL = false;
private:
IndexPack mIPack;
std::array<size_t,sizeof...(Indices)+1> mBlockSizes;
std::shared_ptr<OIType> 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 <class MRange>
GenMapIndex(const std::shared_ptr<MRange>& range);
template <size_t DIR>
GenMapIndex& up();
template <size_t DIR>
GenMapIndex& down();
template <size_t N>
auto get() const -> decltype( *std::get<N>( mIPack ) )&;
template <size_t N>
auto getPtr() const -> decltype( std::get<N>( mIPack ) )&;
template <size_t N>
size_t getBlockSize() const { return std::get<N>(mBlockSizes); }
std::shared_ptr<OIType> outIndex() const;
// 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>&... indices);
GenMapIndex& operator()(const std::tuple<std::shared_ptr<Indices>...>& 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<RangeType> range() const;
template <size_t N>
auto getPtr() -> decltype( std::get<N>( mIPack ) )&;
size_t getStepSize(size_t n) const;
template <class Exprs>
auto ifor(size_t step, Exprs exs) const; // first step arg not used!
template <class Exprs>
auto pifor(size_t step, Exprs exs) const; // NO MULTITHREADING
template <class Exprs>
auto iforh(size_t step, Exprs exs) const;
};
/*************************
* MapRangeFactory *
*************************/
// NOT THREAD SAVE
template <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
class GenMapRangeFactory : public RangeFactoryBase
{
public:
//typedef SingleRange<typename Op::value_type,XSTYPE> ORType;
typedef GenMapRange<ORType,Op,XSTYPE,Ranges...> oType;
GenMapRangeFactory() = delete;
template <class MA>
GenMapRangeFactory(const std::shared_ptr<ORType>& outr, const std::tuple<Op,MA>& mapf,
const std::shared_ptr<Ranges>&... rs);
template <class MA>
GenMapRangeFactory(const std::shared_ptr<ORType>& outr, const std::tuple<Op,MA>& mapf,
const typename GenMapRange<ORType,Op,XSTYPE,Ranges...>::Space& st);
template <class MA>
GenMapRangeFactory(const std::tuple<Op,MA>& mapf, const std::shared_ptr<Ranges>&... rs);
template <class MA>
GenMapRangeFactory(const std::tuple<Op,MA>& mapf,
const typename GenMapRange<ORType,Op,XSTYPE,Ranges...>::Space& space);
virtual std::shared_ptr<RangeBase> create() override;
private:
std::shared_ptr<RangeBase> checkIfCreated(const std::tuple<std::shared_ptr<Ranges>...>& ptp);
};
/******************
* MapRange *
******************/
template <class ORType, class Op, SpaceType XSTYPE, class... Ranges>
class GenMapRange : public RangeInterface<GenMapIndex<typename ORType::IndexType,Op,XSTYPE,typename Ranges::IndexType...> >
{
public:
typedef RangeBase RB;
typedef std::tuple<std::shared_ptr<Ranges>...> Space;
typedef GenMapIndex<typename ORType::IndexType,Op,XSTYPE,typename Ranges::IndexType...> IndexType;
typedef typename Op::value_type MetaType;
protected:
GenMapRange() = delete;
GenMapRange(const GenMapRange& in) = delete;
GenMapRange& operator=(const GenMapRange& in) = delete;
template <class MA>
GenMapRange(const std::shared_ptr<ORType>& outr, const std::tuple<Op,MA>& mapf,
const std::shared_ptr<Ranges>&... rs);
template <class MA>
GenMapRange(const std::shared_ptr<ORType>& outr, const std::tuple<Op,MA>& mapf,
const Space& space);
template <class MA>
GenMapRange(const std::tuple<Op,MA>& mapf, const Space& space);
template <class MA>
GenMapRange(const std::tuple<Op,MA>& mapf, const std::shared_ptr<Ranges>&... rs);
Space mSpace;
Op mMapf;
//Op mMapf;
std::shared_ptr<ORType> mOutRange;
Array<size_t,ORType> mMapMult;
vector<size_t> mMapPos;
private:
template <class MA>
void mkOutRange(const MA& mapf);
public:
static constexpr size_t sdim = sizeof...(Ranges);
template <size_t N>
auto get() const -> decltype( *std::get<N>( mSpace ) )&;
template <size_t N>
auto getPtr() const -> decltype( std::get<N>( mSpace ) )&;
std::shared_ptr<ORType> 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<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;
const Space& space() const;
virtual IndexType begin() const final;
virtual IndexType end() const final;
const Array<size_t,ORType>& mapMultiplicity() const;
ConstSlice<size_t,GenMapRange> explMapMultiplicity() const;
vector<size_t> mapPos() const;
/*
template <class... ERanges>
auto cat(const std::shared_ptr<GenMapRange<ERanges...> >& erange)
-> std::shared_ptr<GenMapRange<Ranges...,ERanges...> >;
*/
friend GenMapRangeFactory<ORType,Op,XSTYPE,Ranges...>;
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 <class OIType, class Op, class... Indices>
using MapIndex = GenMapIndex<OIType,Op,SpaceType::ANY,Indices...>;
template <class ORType, class Op, class... Ranges>
using MapRangeFactory = GenMapRangeFactory<ORType,Op,SpaceType::ANY,Ranges...>;
template <class ORType, class Op, class... Ranges>
using MapRange = GenMapRange<ORType,Op,SpaceType::ANY,Ranges...>;
template <class OIType, class Op, class... Indices>
auto mapResult/*<MapIndex<Op,Indices...> >*/(const std::shared_ptr<MapIndex<OIType,Op,Indices...> >& ind)
-> decltype(ind->outIndex())
{
return ind->outIndex();
}
}
#endif

View file

@ -1,26 +0,0 @@
#ifndef __cxz_map_range_factory_product_map_h__
#define __cxz_map_range_factory_product_map_h__
#include <memory>
#include <vector>
#include <map>
#include "ranges/rbase_def.h"
#include "mbase_def.h"
namespace CNORXZ
{
class MapRangeFactoryProductMap
{
public:
template <class ORType, class MapF, SpaceType XSTYPE, class... Ranges>
friend class GenMapRangeFactory;
private:
static std::map<std::shared_ptr<RangeBase>,vector<std::intptr_t> > mAleadyCreated;
};
}
#endif

View file

@ -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 <class... Ranges>
using ContainerRangeFactory = MultiRangeFactory<Ranges...>;
template <class... Ranges>
using ContainerRange = MultiRange<Ranges...>;
// container_index.h
template <typename T, class... Indices>
class ConstContainerIndex;
// cxz_array.h
template <typename T, class... SRanges>
class ArrayBase;
// cxz_array.h
template <typename T, class... SRanges>
class MutableArrayBase;
// cxz_array.h
template <typename T, class... SRanges>
class Array;
// cxz_operation.h
template <typename T, class OperationClass>
class OperationBase;
// cxz_operation.h
template <typename T, class OperationClass>
class OperationTemplate;
// cxz_operation.h
template <typename T, class... Ranges>
class OperationRoot;
// cxz_operation.h
template <typename T, class... Ranges>
class ParallelOperationRoot;
// cxz_operation.h
template <typename T>
class OperationValue;
// cxz_operation.h
template <typename T, class... Ranges>
class ConstOperationRoot;
// cxz_operation.h
template <typename T, class Op>
class OperationPointer;
// cxz_operation.h
template <typename T, class OpFunction, class... Ops>
class Operation;
// cxz_operation.h
template <typename T, class Op, class IndexType>
class Contraction;
// cxz_operation.h
template <typename T, class Op, class... Indices>
class SliceContraction;
// slice.h
template <typename T, class... SRanges>
class Slice;
template <typename T, class... SRanges>
class ConstSlice;
// slice.h
template <typename T, class... SRanges>
class SliceDef;
// slice.h
template <typename T, class... SRanges>
class ConstSliceDef;
// map_range.h
template <class OITpye, class MapF, SpaceType XSTYPE, class... Indices>
class GenMapIndex;
// map_range.h
template <class ORType, class MapF, SpaceType XSTYPE, class... Ranges>
class GenMapRangeFactory;
// map_range.h
template <class ORType, class MapF, SpaceType XSTYPE, class... Ranges>
class GenMapRange;
}
#endif

View file

@ -1,261 +0,0 @@
// -*- C++ -*-
#ifndef __cxz_anonymous_range_h__
#define __cxz_anonymous_range_h__
#include <cstdlib>
#include <map>
#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<size_t,SpaceType::ANON,MUI> AnonymousIndex;
//template <class R>
//using SIZET = size_t;
typedef GenSingleRange<size_t,SpaceType::ANON,MUI> AnonymousRange;
// NOT THREAD SAVE!!
class AnonymousRangeFactory : public RangeFactoryBase
{
public:
typedef AnonymousRange oType;
AnonymousRangeFactory();
template <class... RangeTypes>
AnonymousRangeFactory(const std::tuple<std::shared_ptr<RangeTypes>...>& origs);
template <class... RangeTypes>
AnonymousRangeFactory(std::shared_ptr<RangeTypes>... origs);
AnonymousRangeFactory(const vector<std::shared_ptr<RangeBase>>& origs);
template <class Range>
void append(std::shared_ptr<Range> r);
std::shared_ptr<RangeBase> create();
private:
std::shared_ptr<RangeBase> checkIfCreated(const vector<std::shared_ptr<RangeBase> >& pvec);
static std::map<std::shared_ptr<RangeBase>,vector<std::intptr_t> > mAleadyCreated;
bool mProductCreated = false;
};
template <>
class GenSingleRange<size_t,SpaceType::ANON,MUI> : public RangeInterface<AnonymousIndex>
{
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<AnonymousIndex>::IndexType IndexType;
typedef GenSingleRange<size_t,SpaceType::ANON,MUI> 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<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;
std::shared_ptr<RangeBase> sub(size_t num) const;
template <class Range>
std::shared_ptr<Range> fullsub(size_t num) const;
template <class... Ranges>
std::shared_ptr<MultiRange<Ranges...> > scast(SIZET<Ranges>... sizes) const; // save cast
const vector<std::shared_ptr<RangeBase> >& orig() const;
std::shared_ptr<AnonymousRange> sreplace(const std::shared_ptr<RangeBase> in, size_t num) const;
std::shared_ptr<AnonymousRange> sreplace(const vector<std::shared_ptr<RangeBase>>& in, size_t num) const;
std::shared_ptr<AnonymousRange> sreplace(const std::shared_ptr<RangeBase>& in,
const vector<size_t>& num) const;
bool isEmpty() const;
friend AnonymousRangeFactory;
static AnonymousRangeFactory factory()
{ return AnonymousRangeFactory(); }
protected:
GenSingleRange() = default;
GenSingleRange(const AnonymousRange& in) = default;
template <class... RangeTypes>
GenSingleRange(const std::tuple<std::shared_ptr<RangeTypes>...>& origs);
template <class... RangeTypes>
GenSingleRange(std::shared_ptr<RangeTypes>... origs);
GenSingleRange(const vector<std::shared_ptr<RangeBase>>& origs);
size_t mSize = 1;
bool mEmpty = true;
vector<std::shared_ptr<RangeBase> > mOrig;
};
}
/* ========================= *
* --- TEMPLATE CODE --- *
* ========================= */
namespace CNORXZ
{
/***********************
* AnonymousRange *
***********************/
template <class... RangeTypes>
AnonymousRangeFactory::AnonymousRangeFactory(const std::tuple<std::shared_ptr<RangeTypes>...>& origs)
{
mProd = std::shared_ptr<oType>( new AnonymousRange( origs ) );
}
template <class... RangeTypes>
AnonymousRangeFactory::AnonymousRangeFactory(std::shared_ptr<RangeTypes>... origs)
{
mProd = std::shared_ptr<oType>( new AnonymousRange( origs... ) );
}
template <class Range>
void AnonymousRangeFactory::append(std::shared_ptr<Range> r)
{
if(mProductCreated){
mProd = std::shared_ptr<oType>( new AnonymousRange( *std::dynamic_pointer_cast<oType>(mProd) ) );
mProductCreated = false;
}
std::dynamic_pointer_cast<oType>(mProd)->mOrig.push_back(r);
std::dynamic_pointer_cast<oType>(mProd)->mSize *= r->size();
std::dynamic_pointer_cast<oType>(mProd)->mEmpty = false;
}
/*****************
* Functions *
*****************/
std::shared_ptr<AnonymousRange> defaultRange(size_t size = 0);
}
namespace CNORXZ
{
namespace RangeHelper
{
template <>
inline void resolveSetRange<AnonymousRange>(std::shared_ptr<AnonymousRange>& rp,
const vector<std::shared_ptr<RangeBase> >& 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<AnonymousRange>( arf.create() );
}
template <>
inline void setRangeToVec<AnonymousRange>(vector<std::shared_ptr<RangeBase> >& v,
std::shared_ptr<AnonymousRange> 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 <class... RangeTypes>
GenSingleRange<size_t,SpaceType::ANON,MUI>::GenSingleRange(const std::tuple<std::shared_ptr<RangeTypes>...>& origs) :
RangeInterface<AnonymousIndex>()
{
mOrig.resize(sizeof...(RangeTypes));
sfor_pn<0,sizeof...(RangeTypes)>
( [&](auto i) { mOrig[i] = std::get<i>(origs); return 0; } );
mSize = sfor_p<0,sizeof...(RangeTypes)>
( [&](auto i) { return std::get<i>(origs)->size(); },
[&](auto a, auto b) { return a * b; } );
if(sizeof...(RangeTypes)){
mEmpty = false;
}
}
template <class... RangeTypes>
GenSingleRange<size_t,SpaceType::ANON,MUI>::GenSingleRange(std::shared_ptr<RangeTypes>... origs) :
RangeInterface<AnonymousIndex>()
{
auto rst = std::make_tuple(origs...);
mOrig.resize(sizeof...(RangeTypes));
sfor_pn<0,sizeof...(RangeTypes)>
( [&](auto i) { mOrig[i] = std::get<i>(rst); return 0; } );
mSize = sfor_p<0,sizeof...(RangeTypes)>
( [&](auto i) { return std::get<i>(rst)->size(); },
[&](auto a, auto b) { return a * b; } );
if(sizeof...(RangeTypes)){
mEmpty = false;
}
}
template <class Range>
std::shared_ptr<Range> GenSingleRange<size_t,SpaceType::ANON,MUI>::fullsub(size_t num) const
{
return std::dynamic_pointer_cast<Range>( mOrig.at(num) );
}
template <class... Ranges>
std::shared_ptr<MultiRange<Ranges...> > GenSingleRange<size_t,SpaceType::ANON,MUI>::scast(SIZET<Ranges>... sizes) const
{
std::tuple<std::shared_ptr<Ranges>...> rtp;
RangeHelper::resolveRangeType<0>(mOrig, rtp, 0, sizes...);
MultiRangeFactory<Ranges...> mrf(rtp);
return std::dynamic_pointer_cast<MultiRange<Ranges...> >( mrf.create() );
}
}
#endif

View file

@ -1,238 +0,0 @@
#include "ranges/dynamic_range.h"
namespace CNORXZ
{
namespace
{
using namespace CNORXZInternal;
}
/****************************
* DynamicRangeFactory *
****************************/
template <class... RangeTypes>
DynamicRangeFactory::DynamicRangeFactory(const std::tuple<std::shared_ptr<RangeTypes>...>& origs)
{
mProd = std::shared_ptr<oType>( new DynamicRange( origs ) );
}
template <class... RangeTypes>
DynamicRangeFactory::DynamicRangeFactory(std::shared_ptr<RangeTypes>... origs)
{
mProd = std::shared_ptr<oType>( new DynamicRange( origs... ) );
}
template <class Range>
void DynamicRangeFactory::append(std::shared_ptr<Range> r)
{
if(mProductCreated){
mProd = std::shared_ptr<oType>( new DynamicRange( *std::dynamic_pointer_cast<oType>(mProd) ) );
mProductCreated = false;
}
std::dynamic_pointer_cast<oType>(mProd)->mOrig.push_back(r);
std::dynamic_pointer_cast<oType>(mProd)->mSize *= r->size();
std::dynamic_pointer_cast<oType>(mProd)->mEmpty = false;
}
/*********************
* DynamicIndex *
*********************/
template <class... Indices>
DynamicIndex& DynamicIndex::operator()(const std::shared_ptr<Indices>&... is)
{
mIvecInit = true;
vector<std::shared_ptr<IndexW>> tmp =
{ std::make_shared<IndexWrapper<Indices>>(is)... };
assert(mIVec.size() == tmp.size());
for(size_t i = 0; i != mIVec.size(); ++i){
mIVec[i].first = tmp[i];
}
sync();
return *this;
}
template <size_t N>
void DynamicIndex::getPtr() {}
struct ForMaker
{
template <class IVecT>
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 <class Expr>
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 <class Expr>
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 <class Expr>
DynamicExpression DynamicIndex::pifor(size_t step, Expr ex) const
{
return ifor(step, ex); // no multithreading here at the moment...
}
/***********************
* DynamicRange *
***********************/
template <class... RangeTypes>
DynamicRange::DynamicRange(const std::tuple<std::shared_ptr<RangeTypes>...>& origs) :
RangeInterface<DynamicIndex>()
{
mOrig.resize(sizeof...(RangeTypes));
sfor_pn<0,sizeof...(RangeTypes)>
( [&](auto i) { mOrig[i] = std::get<i>(origs); return 0; } );
mSize = sfor_p<0,sizeof...(RangeTypes)>
( [&](auto i) { return std::get<i>(origs)->size(); },
[&](auto a, auto b) { return a * b; } );
if(sizeof...(RangeTypes)){
mEmpty = false;
}
}
template <class... RangeTypes>
DynamicRange::DynamicRange(std::shared_ptr<RangeTypes>... origs) :
RangeInterface<DynamicIndex>()
{
auto rst = std::make_tuple(origs...);
mOrig.resize(sizeof...(RangeTypes));
sfor_pn<0,sizeof...(RangeTypes)>
( [&](auto i) { mOrig[i] = std::get<i>(rst); return 0; } );
mSize = sfor_p<0,sizeof...(RangeTypes)>
( [&](auto i) { return std::get<i>(rst)->size(); },
[&](auto a, auto b) { return a * b; } );
if(sizeof...(RangeTypes)){
mEmpty = false;
}
}
template <class Range>
std::shared_ptr<Range> DynamicRange::fullsub(size_t num) const
{
return std::dynamic_pointer_cast<Range>( mOrig.at(num) );
}
template <class... Ranges>
std::shared_ptr<MultiRange<Ranges...> > DynamicRange::scast(SIZET<Ranges>... sizes) const
{
std::tuple<std::shared_ptr<Ranges>...> rtp;
RangeHelper::resolveRangeType<0>(mOrig, rtp, 0, sizes...);
MultiRangeFactory<Ranges...> mrf(rtp);
return std::dynamic_pointer_cast<MultiRange<Ranges...> >( mrf.create() );
}
} // end namespace CNORXZ
namespace CNORXZ
{
namespace RangeHelper
{
template <>
inline void resolveSetRange<DynamicRange>(std::shared_ptr<DynamicRange>& rp,
const vector<std::shared_ptr<RangeBase> >& 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<DynamicRange>( arf.create() );
}
template <>
inline void setRangeToVec<DynamicRange>(vector<std::shared_ptr<RangeBase> >& v,
std::shared_ptr<DynamicRange> 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<DynamicIndex>(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;
}
}
}

View file

@ -1,250 +0,0 @@
#ifndef __cxz_dynamic_range_h__
#define __cxz_dynamic_range_h__
#include <cassert>
#include <map>
#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<DynamicIndex,vector<char>>
{
private:
typedef vector<std::pair<std::shared_ptr<IndexW>,size_t>> IVecT;
typedef std::map<std::string,std::shared_ptr<IndexW>> IMapT;
static IMapT sIMap;
IVecT mIVec;
bool mIvecInit = false;
public:
typedef IndexInterface<DynamicIndex,vector<char>> IB;
typedef vector<char> MetaType;
typedef DynamicRange RangeType;
typedef DynamicIndex IType;
DynamicIndex(const std::shared_ptr<RangeType>& range);
static void clearIMap() { sIMap.clear(); }
template <class Index>
static std::shared_ptr<Index> getIndexFromMap(const std::string& name)
{
auto tmp = std::dynamic_pointer_cast<IndexWrapper<Index>>(sIMap.at(name));
assert(tmp);
return tmp->getIndex();
}
static const std::shared_ptr<IndexW>& 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<std::shared_ptr<IndexW>>& ivec);
DynamicIndex& operator()(const vector<std::string>& inames);
template <class... Indices>
DynamicIndex& operator()(const std::shared_ptr<Indices>&... 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<IndexW>& getP(size_t n) const;
std::shared_ptr<RangeType> range();
template <size_t N>
void getPtr();
size_t getStepSize(size_t n) const;
template <class Expr>
DynamicExpression ifor(size_t step, Expr ex) const;
template <class Expr>
DynamicExpression iforh(size_t step, Expr ex) const;
template <class Expr>
DynamicExpression pifor(size_t step, Expr ex) const;
};
// NOT THREAD SAVE!!
class DynamicRangeFactory : public RangeFactoryBase
{
public:
typedef DynamicRange oType;
DynamicRangeFactory();
template <class... RangeTypes>
DynamicRangeFactory(const std::tuple<std::shared_ptr<RangeTypes>...>& origs);
template <class... RangeTypes>
DynamicRangeFactory(std::shared_ptr<RangeTypes>... origs);
DynamicRangeFactory(const vector<std::shared_ptr<RangeBase>>& origs);
template <class Range>
void append(std::shared_ptr<Range> r);
std::shared_ptr<RangeBase> create();
private:
std::shared_ptr<RangeBase> checkIfCreated(const vector<std::shared_ptr<RangeBase> >& pvec);
static std::map<std::shared_ptr<RangeBase>,vector<std::intptr_t> > mAleadyCreated;
bool mProductCreated = false;
};
class DynamicRange : public RangeInterface<DynamicIndex>
{
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<char> MetaType;
typedef DynamicRangeFactory FType;
private:
DynamicRange() = default;
DynamicRange(const DynamicRange& in) = default;
template <class... RangeTypes>
DynamicRange(const std::tuple<std::shared_ptr<RangeTypes>...>& origs);
template <class... RangeTypes>
DynamicRange(std::shared_ptr<RangeTypes>... origs);
DynamicRange(const vector<std::shared_ptr<RangeBase>>& origs);
size_t mSize = 1;
bool mEmpty = true;
vector<std::shared_ptr<RangeBase> > 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<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;
std::shared_ptr<RangeBase> sub(size_t num) const;
template <class Range>
std::shared_ptr<Range> fullsub(size_t num) const;
template <class... Ranges>
std::shared_ptr<MultiRange<Ranges...> > scast(SIZET<Ranges>... sizes) const; // save cast
const vector<std::shared_ptr<RangeBase> >& orig() const;
void sreplace(const std::shared_ptr<RangeBase> in, size_t num);
bool isEmpty() const;
friend DynamicRangeFactory;
static DynamicRangeFactory factory()
{ return DynamicRangeFactory(); }
};
} // namespace CNORXZ
namespace CNORXZ
{
namespace RangeHelper
{
template <>
inline void resolveSetRange<DynamicRange>(std::shared_ptr<DynamicRange>& rp,
const vector<std::shared_ptr<RangeBase> >& orig,
size_t origpos, size_t size);
template <>
inline void setRangeToVec<DynamicRange>(vector<std::shared_ptr<RangeBase> >& v,
std::shared_ptr<DynamicRange> r);
template <>
inline size_t getStepSize<DynamicIndex>(const DynamicIndex& ii, std::intptr_t j);
}
}
//#include "dynamic_range.cc.h"
#endif

View file

@ -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

View file

@ -1,176 +0,0 @@
#include "index_wrapper.h"
#include "range_helper.h"
namespace CNORXZ
{
template <class Index>
IndexWrapper<Index>::IndexWrapper(const std::shared_ptr<Index>& i) : mI(i)
{
ClassicRF crf(mI->max());
mCI = std::make_shared<ClassicIndex>
( std::dynamic_pointer_cast<ClassicRange>( crf.create() ) );
(*mCI) = mI->pos();
}
template <class Index>
IndexType IndexWrapper<Index>::type() const
{
return mI->type();
}
template <class Index>
IndexWrapper<Index>& IndexWrapper<Index>::operator=(size_t pos)
{
(*mI) = pos;
return *this;
}
template <class Index>
IndexWrapper<Index>& IndexWrapper<Index>::operator++()
{
++(*mI);
return *this;
}
template <class Index>
IndexWrapper<Index>& IndexWrapper<Index>::operator--()
{
--(*mI);
return *this;
}
template <class Index>
size_t IndexWrapper<Index>::pos() const
{
return mI->pos();
}
template <class Index>
size_t IndexWrapper<Index>::max() const
{
return mI->max();
}
template <class Index>
int IndexWrapper<Index>::pp(std::intptr_t idxPtrNum)
{
return mI->pp(idxPtrNum);
}
template <class Index>
int IndexWrapper<Index>::mm(std::intptr_t idxPtrNum)
{
return mI->mm(idxPtrNum);
}
template <class Index>
std::string IndexWrapper<Index>::stringMeta() const
{
return mI->stringMeta();
}
template <class Index>
IndexWrapper<Index>& IndexWrapper<Index>::at(const typename Index::MetaType& metaPos)
{
mI->at(metaPos);
return *this;
}
template <class Index>
size_t IndexWrapper<Index>::posAt(const typename Index::MetaType& metaPos)
{
return mI->posAt(metaPos);
}
template <class Index>
size_t IndexWrapper<Index>::dim() const
{
return mI->dim();
}
template <class Index>
bool IndexWrapper<Index>::last() const
{
return mI->last();
}
template <class Index>
bool IndexWrapper<Index>::first() const
{
return mI->first();
}
template <class Index>
std::shared_ptr<RangeBase> IndexWrapper<Index>::range() const
{
return mI->range();
}
template <class Index>
size_t IndexWrapper<Index>::getStepSize(size_t n) const
{
return mI->getStepSize(n);
}
template <class Index>
size_t IndexWrapper<Index>::getStepSizeComp(std::intptr_t j) const
{
size_t out = RangeHelper::getStepSize(*mI, j);
if(out == 0){
out = RangeHelper::getStepSize(*mCI, j);
}
return out;
}
template <class Index>
std::intptr_t IndexWrapper<Index>::get() const
{
return reinterpret_cast<std::intptr_t>(mI.get());
}
template <class Index>
std::intptr_t IndexWrapper<Index>::ptrNum() const
{
return mI->ptrNum();
}
template <class Index>
DynamicExpression IndexWrapper<Index>::ifor(size_t step, DynamicExpression ex) const
{
return mI->ifor(step, ex);
}
template <class Index>
DynamicExpression IndexWrapper<Index>::iforh(size_t step, DynamicExpression ex) const
{
return mI->iforh(step, ex);
}
template <class Index>
std::shared_ptr<IndexWrapperBase> IndexWrapper<Index>::duplicate() const
{
return std::make_shared<IndexWrapper>( std::make_shared<Index>( *mI ) );
}
template <class Index>
std::shared_ptr<Index> IndexWrapper<Index>::getIndex() const
{
return mI;
}
template <class Index>
std::shared_ptr<ClassicIndex> IndexWrapper<Index>::reduced() const
{
(*mCI) = mI->pos();
return mCI;
}
template <class Index>
inline std::shared_ptr<IndexWrapperBase> mkIndexWrapper(const Index& i)
{
return std::make_shared<IndexWrapper<Index>>(std::make_shared<Index>(i));
}
}

View file

@ -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<RangeBase> 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<IndexWrapperBase> 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<IndexWrapperBase> duplicateI() const
{ return std::dynamic_pointer_cast<IndexWrapperBase>( this->duplicate() ); }
*/
virtual std::shared_ptr<ClassicIndex> reduced() const = 0;
};
typedef IndexWrapperBase IndexW;
template <class Index>
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<Index> mI;
std::shared_ptr<ClassicIndex> 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<Index>& 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<RangeBase> 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<IndexWrapperBase> duplicate() const override final;
std::shared_ptr<Index> getIndex() const;
virtual std::shared_ptr<ClassicIndex> reduced() const override final;
};
/*
template <class Index>
std::shared_ptr<IndexWrapperBase> mkIndexWrapper(const Index& i);
*/
}
#endif

View file

@ -1,25 +0,0 @@
#ifndef __cxz_multi_range_factory_product_map_h__
#define __cxz_multi_range_factory_product_map_h__
#include <memory>
#include <vector>
#include <map>
#include "ranges/rbase_def.h"
namespace CNORXZ
{
class MultiRangeFactoryProductMap
{
public:
template <class... Ranges>
friend class MultiRangeFactory;
private:
static std::map<std::shared_ptr<RangeBase>,vector<std::intptr_t> > mAleadyCreated;
};
}
#endif

View file

@ -1,9 +0,0 @@
#ifdef register_multi3
typedef SingleRange<char,SpaceType::ANY> SCRange;
register_multi3(PSpaceRange,PSpaceRange,PSpaceRange)
register_multi3(SCRange,SCRange,SCRange)
#endif

View file

@ -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__

View file

@ -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<int,SpaceType::PSPACE,MUI> XSpaceIndex;
template <>
class GenSingleRangeFactory<int,SpaceType::PSPACE,MUI> : public RangeFactoryBase
{
public:
typedef GenSingleRange<int,SpaceType::PSPACE,MUI> oType;
GenSingleRangeFactory(size_t size = 0);
std::shared_ptr<RangeBase> create();
};
template <>
class GenSingleRange<int,SpaceType::PSPACE,MUI> : public RangeInterface<XSpaceIndex>
{
public:
typedef RangeBase RB;
typedef typename RangeInterface<GenSingleIndex<int,SpaceType::PSPACE,MUI> >::IndexType IndexType;
typedef GenSingleRange<int,SpaceType::PSPACE,MUI> RangeType;
typedef int MetaType;
typedef GenSingleRangeFactory<int,SpaceType::PSPACE,MUI> FType;
virtual size_t size() const final;
virtual size_t dim() 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;
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<int,SpaceType::PSPACE,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<int,SpaceType::PSPACE,MUI> factory(size_t size = 0)
{ return GenSingleRangeFactory<int,SpaceType::PSPACE,MUI>(size); }
protected:
size_t mSize = 0;
GenSingleRange() = default;
GenSingleRange(const GenSingleRange& in) = delete;
GenSingleRange(size_t size);
};
typedef GenSingleRange<int,SpaceType::PSPACE,MUI> PSpaceRange;
typedef GenSingleRangeFactory<int,SpaceType::PSPACE,MUI> PSpaceRF;
std::shared_ptr<PSpaceRF> mkPSPACE(const char* dp, size_t size);
template <class SpaceRange>
struct PromoteMSpaceRange
{
template <class... SpaceRanges>
static auto mk(const MultiRange<SpaceRanges...>&)
-> MultiRange<SpaceRange,SpaceRanges...>;
template <class... SpaceRanges>
static auto mkf(const MultiRangeFactory<SpaceRanges...>&)
-> MultiRangeFactory<SpaceRange,SpaceRanges...>;
};
template <size_t N>
struct CreateNDimSpaceRange
{
template <class SpaceRange>
static auto mk()
-> decltype(PromoteMSpaceRange<SpaceRange>::
template mk(CreateNDimSpaceRange<N-1>::
template mk<SpaceRange>()));
template <class SpaceRange>
static auto mkf()
-> decltype(PromoteMSpaceRange<SpaceRange>::
template mkf(CreateNDimSpaceRange<N-1>::
template mkf<SpaceRange>()));
};
template <>
struct CreateNDimSpaceRange<1>
{
template <class SpaceRange>
static auto mk()
-> MultiRange<SpaceRange>;
template <class SpaceRange>
static auto mkf()
-> MultiRangeFactory<SpaceRange>;
};
template <class SpaceRange, size_t N>
using MSpaceRange = decltype(CreateNDimSpaceRange<N>::template mk<SpaceRange>());
template <class SpaceRange, size_t N>
using MSpaceRF = decltype(CreateNDimSpaceRange<N>::template mkf<SpaceRange>());
}
#endif // #ifndef __cxz_range_type_space_def__
#endif // #ifdef __cxz_ranges_header__
#endif // #ifdef include_range_type

View file

@ -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<size_t,SpaceType::SPIN,4> SpinIndex;
template <>
class GenSingleRangeFactory<size_t,SpaceType::SPIN,4> : public RangeFactoryBase
{
public:
typedef GenSingleRange<size_t,SpaceType::SPIN,4> oType;
GenSingleRangeFactory();
std::shared_ptr<RangeBase> create();
};
template <>
class GenSingleRange<size_t,SpaceType::SPIN,4> : public RangeInterface<SpinIndex>
{
public:
typedef RangeBase RB;
typedef typename RangeInterface<GenSingleIndex<size_t,SpaceType::SPIN,4> >::IndexType IndexType;
typedef GenSingleRange<size_t,SpaceType::SPIN,4> RangeType;
typedef size_t MetaType;
typedef GenSingleRangeFactory<size_t,SpaceType::SPIN,4> FType;
virtual size_t size() const final;
virtual size_t dim() 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;
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<VIWB> index() const final;
friend GenSingleRangeFactory<size_t,SpaceType::SPIN,4>;
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<size_t,SpaceType::SPIN,4> factory()
{ return GenSingleRangeFactory<size_t,SpaceType::SPIN,4>(); }
protected:
GenSingleRange() = default;
GenSingleRange(const GenSingleRange& in) = delete;
//GenSingleRange(size_t spinNum);
};
typedef GenSingleRange<size_t,SpaceType::SPIN,4> SpinRange;
typedef GenSingleRangeFactory<size_t,SpaceType::SPIN,4> SpinRF;
std::shared_ptr<SpinRF> mkSPIN(const char* dp, size_t size);
}
#endif // #ifndef __cxz_range_type_spin_def__
#endif // #ifdef __cxz_ranges_header__
#endif // #ifdef include_range_type

View file

@ -1,3 +0,0 @@
#include "ranges/dynamic_range.cc.h"
#include "ranges/index_wrapper.cc.h"

View file

@ -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<size_t>(-1)
namespace CNORXZ
{
template <class R>
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 Index>
class RangeInterface;
// index_base.h
template <class I, typename MetaType>
class IndexInterface;
// single_range.h
template <typename U, SpaceType TYPE, size_t S>
class GenSingleRange;
// single_range.h
template <typename U, SpaceType TYPE, size_t S>
class GenSingleRangeFactory;
// single_range.h
template <typename U, SpaceType TYPE, size_t S>
class GenSingleIndex;
// subrange.h
template <class Index>
class SubIndex;
// subrange.h
template <class Range>
class SubRangeFactory;
// subrange.h
template <class Range>
class SubRange;
// multi_range.h
template <class... Ranges>
class MultiRangeFactory;
// multi_range.h
template <class... Ranges>
class MultiRange;
// multi_range.h
template <class... Indices>
class MultiIndex;
// anonymous_range.h
class AnonymousRangeFactory;
// dynamic_range.h
class IndexWrapperBase;
// dynamic_range.h
template <class Index>
class IndexWrapper;
// dynamic_range.h
class DynamicIndex;
// dynamic_range.h
class DynamicRangeFactory;
// dynamic_range.h
class DynamicRange;
// value_range.h
template <typename U>
class ValueRange;
template <typename U>
class ValueRangeFactory;
template <typename U>
class ValueIndex;
}
#endif

View file

@ -1,7 +0,0 @@
#ifndef __cxz_reg_ind_num_h__
#define __cxz_reg_ind_num_h__
#define

View file

@ -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

View file

@ -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

View file

@ -1,231 +0,0 @@
#ifndef __cxz_type_map_h__
#define __cxz_type_map_h__
#include <string>
#include <vector>
#include <array>
#include <iostream>
#include <cassert>
#include "allocator.h"
namespace CNORXZ
{
template <size_t N>
struct TypeMap
{
typedef void type;
static constexpr size_t size = 0;
};
template <typename T>
struct NumTypeMap
{
static size_t num() { assert(0); return 0; };
};
template <typename T>
struct TypeHandle
{
static inline void stringCat(vector<char>& out, const vector<T>& in)
{
//for(auto& x: in) { std::cout << x << std::endl; }
const char* scp = reinterpret_cast<const char*>(in.data());
out.insert(out.end(), scp, scp + in.size() * sizeof(T));
}
static inline size_t metaSize(const vector<T>& in)
{
return in.size() * sizeof(T);
}
static inline void metaCat(vector<T>& vec, const char* begin, size_t size)
{
const T* tp = reinterpret_cast<const T*>( begin );
vec.insert(vec.end(), tp, tp + size / sizeof(T));
}
};
template <>
struct TypeHandle<std::string>
{
static inline void stringCat(vector<char>& out, const vector<std::string>& 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<const char*>(tmp.data());
out.insert(out.end(), scp, scp + tmp.size());
}
static inline size_t metaSize(const vector<std::string>& in)
{
size_t out = 0;
for(auto& x: in){
out += x.size() + 1;
}
return out;
}
static inline void metaCat(vector<std::string>& 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 <typename T>
struct TypeHandle<vector<T>>
{
static inline void stringCat(vector<char>& out, const vector<vector<T>>& 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<const char*>(&size);
const char* scp = reinterpret_cast<const char*>(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<vector<T>>& 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<vector<T>>& vec, const char* begin, size_t size)
{
size_t pos = 0;
while(pos < size){
const size_t xsize = *reinterpret_cast<const size_t*>(begin+pos);
pos += sizeof(size_t);
const T* dbegin = reinterpret_cast<const T*>(begin+pos);
const T* dend = dbegin+xsize;
vec.emplace_back(dbegin,dend);
//vector<T> tmp(begin+pos, begin+npos);
//vec.push_back(tmp);
pos += xsize*sizeof(T);
}
assert(pos == size);
}
};
template <typename T>
inline void stringCat(vector<char>& out, const vector<T>& in)
{
TypeHandle<T>::stringCat(out,in);
}
template <typename T>
inline size_t metaSize(const vector<T>& in)
{
return TypeHandle<T>::metaSize(in);
}
template <typename T>
inline void metaCat(vector<T>& vec, const char* begin, size_t size)
{
TypeHandle<T>::metaCat(vec,begin,size);
}
#define XCOMMAX() ,
#define include_type(t,n) template <> struct TypeMap<n> { typedef t type; static constexpr size_t size = sizeof(t); }; \
template <> struct NumTypeMap<t> { 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<size_t>,101)
include_type(vector<int>,102)
include_type(vector<double>,105)
include_type(vector<std::string>,106)
include_type(std::array<size_t XCOMMAX() 2>,201)
include_type(std::array<int XCOMMAX() 2>,202)
include_type(std::array<double XCOMMAX() 2>,205)
include_type(std::array<size_t XCOMMAX() 3>,301)
include_type(std::array<int XCOMMAX() 3>,302)
include_type(std::array<double XCOMMAX() 3>,305)
include_type(std::array<size_t XCOMMAX() 4>,401)
include_type(std::array<int XCOMMAX() 4>,402)
include_type(std::array<double XCOMMAX() 4>,405)
include_type(std::array<int XCOMMAX() 5>,502)
include_type(std::array<int XCOMMAX() 6>,602)
include_type(std::array<int XCOMMAX() 7>,702)
include_type(std::array<int XCOMMAX() 8>,802)
include_type(std::array<int XCOMMAX() 9>,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<char>); }
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

View file

@ -1,26 +0,0 @@
include_type(vector<char>,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<size_t>,101)
include_type(vector<int>,102)
include_type(vector<double>,105)
include_type(vector<std::string>,106)
include_type(std::array<size_t XCOMMAX() 2>,201)
include_type(std::array<int XCOMMAX() 2>,202)
include_type(std::array<double XCOMMAX() 2>,205)
include_type(std::array<size_t XCOMMAX() 3>,301)
include_type(std::array<int XCOMMAX() 3>,302)
include_type(std::array<double XCOMMAX() 3>,305)
include_type(std::array<size_t XCOMMAX() 4>,401)
include_type(std::array<int XCOMMAX() 4>,402)
include_type(std::array<double XCOMMAX() 4>,405)
include_type(std::array<int XCOMMAX() 5>,502)
include_type(std::array<int XCOMMAX() 6>,602)
include_type(std::array<int XCOMMAX() 7>,702)
include_type(std::array<int XCOMMAX() 8>,802)
include_type(std::array<int XCOMMAX() 9>,902)

View file

@ -1,415 +0,0 @@
#ifndef __cxz_value_range_h__
#define __cxz_value_range_h__
#include <cstdlib>
#include <vector>
#include <memory>
#include <map>
#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 <typename U>
class ValueIndex : public IndexInterface<ValueIndex<U>,U>
{
public:
typedef IndexInterface<ValueIndex<U>,U> IB;
typedef U MetaType;
typedef ValueRange<U> RangeType;
typedef ValueIndex IType;
ValueIndex(const std::shared_ptr<RangeType>& 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<RangeType> range();
template <size_t N>
void getPtr();
size_t getStepSize(size_t n);
template <class Expr>
auto ifor(size_t step, Expr ex) const
-> For<ValueIndex<U>,Expr>;
template <class Expr>
auto iforh(size_t step, Expr ex) const
-> For<ValueIndex<U>,Expr,ForType::HIDDEN>;
private:
std::shared_ptr<RangeType> mExplicitRangePtr;
U mMeta;
};
template <typename U>
class ValueRangeFactory : public RangeFactoryBase
{
public:
typedef ValueRange<U> oType;
ValueRangeFactory();
std::shared_ptr<RangeBase> create();
};
template <typename U>
class ValueRange : public RangeInterface<ValueIndex<U> >
{
public:
typedef RangeBase RB;
typedef ValueIndex<U> IndexType;
typedef ValueRange RangeType;
typedef U MetaType;
typedef ValueRangeFactory<U> 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;
U get(size_t pos) const;
virtual IndexType begin() const final;
virtual IndexType end() const final;
friend ValueRangeFactory<U>;
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<ValueRange> Default()
{
ValueRangeFactory<U> vrf;
return std::dynamic_pointer_cast<ValueRange>( vrf.create() );
}
protected:
mutable U const* mMeta;
ValueRange() = default;
};
} // namespace CNORXZ
/* ========================= *
* --- TEMPLATE CODE --- *
* ========================= */
namespace CNORXZ
{
/*****************
* ValueIndex *
*****************/
namespace
{
template<typename U>
std::shared_ptr<RangeBase> mkDefaultValueRange()
{
ValueRangeFactory<U> vrf;
return vrf.create();
}
}
template <typename U>
ValueIndex<U>::ValueIndex(const std::shared_ptr<RangeType>& rptr) :
IndexInterface<ValueIndex<U>,U>(rptr, 0),
mExplicitRangePtr(std::dynamic_pointer_cast<RangeType>(IB::mRangePtr))
{}
template <typename U>
IndexType ValueIndex<U>::type() const
{
return IndexType::SINGLE;
}
template <typename U>
ValueIndex<U>& ValueIndex<U>::operator=(size_t pos)
{
IB::mPos = pos;
return *this;
}
template <typename U>
ValueIndex<U>& ValueIndex<U>::operator++()
{
++IB::mPos;
return *this;
}
template <typename U>
ValueIndex<U>& ValueIndex<U>::operator--()
{
--IB::mPos;
return *this;
}
template <typename U>
int ValueIndex<U>::pp(std::intptr_t idxPtrNum)
{
++(*this);
return 1;
}
template <typename U>
int ValueIndex<U>::mm(std::intptr_t idxPtrNum)
{
--(*this);
return 1;
}
template <typename U>
std::string ValueIndex<U>::stringMeta() const
{
return xToString(mMeta);
}
template <typename U>
const U& ValueIndex<U>::meta() const
{
return mMeta;
}
template <typename U>
const U* ValueIndex<U>::metaPtr() const
{
return &mMeta;
}
template <typename U>
ValueIndex<U>& ValueIndex<U>::at(const U& metaPos)
{
mMeta = metaPos;
return *this;
}
template <typename U>
size_t ValueIndex<U>::posAt(const U& metaPos) const
{
return 0;
}
template <typename U>
size_t ValueIndex<U>::dim() // = 1
{
return 1;
}
template <typename U>
bool ValueIndex<U>::last()
{
return IB::mPos == IB::mMax - 1;
}
template <typename U>
bool ValueIndex<U>::first()
{
return IB::mPos == 0;
}
template <typename U>
std::shared_ptr<typename ValueIndex<U>::RangeType> ValueIndex<U>::range()
{
return mExplicitRangePtr;
}
template <typename U>
template <size_t N>
void ValueIndex<U>::getPtr() {}
template <typename U>
size_t ValueIndex<U>::getStepSize(size_t n)
{
return 1;
}
template <typename U>
template <class Expr>
auto ValueIndex<U>::ifor(size_t step, Expr ex) const
-> For<ValueIndex<U>,Expr>
{
//static const size_t LAYER = typename Expr::LAYER;
return For<ValueIndex<U>,Expr>(this, step, ex);
}
template <typename U>
template <class Expr>
auto ValueIndex<U>::iforh(size_t step, Expr ex) const
-> For<ValueIndex<U>,Expr,ForType::HIDDEN>
{
//static const size_t LAYER = typename Expr::LAYER;
return For<ValueIndex<U>,Expr,ForType::HIDDEN>(this, step, ex);
}
/**************************
* ValueRangeFactory *
**************************/
template <typename U>
ValueRangeFactory<U>::ValueRangeFactory()
{
mProd = std::shared_ptr<oType>( new ValueRange<U>() );
}
template <typename U>
std::shared_ptr<RangeBase> ValueRangeFactory<U>::create()
{
setSelf();
return mProd;
}
/*******************
* ValueRange *
*******************/
template <typename U>
size_t ValueRange<U>::size() const
{
return 1;
}
template <typename U>
size_t ValueRange<U>::dim() const
{
return 1;
}
template <typename U>
SpaceType ValueRange<U>::spaceType() const
{
return SpaceType::NONE;
}
template <typename U>
vector<size_t> ValueRange<U>::typeNum() const
{
return {NumTypeMap<U>::num()};
}
template <typename U>
size_t ValueRange<U>::cmeta(char* target, size_t pos) const
{
*reinterpret_cast<U*>(target) = *mMeta;
return sizeof(U);
}
template <typename U>
size_t ValueRange<U>::cmetaSize() const
{
return sizeof(U);
}
template <typename U>
std::string ValueRange<U>::stringMeta(size_t pos) const
{
return "";
}
template <typename U>
U ValueRange<U>::get(size_t pos) const
{
return *mMeta;
}
template <typename U>
vector<char> ValueRange<U>::data() const
{
assert(0);
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));
//const char* scp = reinterpret_cast<const char*>(mSpace.data());
//out.insert(out.end(), scp, scp + h.metaSize);
return out;
}
template <typename U>
DataHeader ValueRange<U>::dataHeader() const
{
DataHeader h;
h.spaceType = static_cast<int>( SpaceType::NONE );
h.metaSize = 0;
h.metaType = NumTypeMap<U>::num();
h.multiple = 0;
return h;
}
template <typename U>
typename ValueRange<U>::IndexType ValueRange<U>::begin() const
{
ValueIndex<U> i( std::dynamic_pointer_cast<ValueRange<U> >
( std::shared_ptr<RangeBase>( RB::mThis ) ) );
i = 0;
mMeta = &i.meta();
return i;
}
template <typename U>
typename ValueRange<U>::IndexType ValueRange<U>::end() const
{
ValueIndex<U> i( std::dynamic_pointer_cast<ValueRange<U> >
( std::shared_ptr<RangeBase>( RB::mThis ) ) );
i = size();
mMeta = &i.meta();
return i;
}
} // namespace CNORXZ
#endif

View file

@ -1,127 +0,0 @@
#ifndef __cxz_x_to_string_h__
#define __cxz_x_to_string_h__
#include <string>
#include <vector>
#include <array>
#include <tuple>
#include <algorithm>
#include "ranges/dynamic_meta.h"
namespace CNORXZInternal
{
template <typename T>
inline std::string xToString(const T& x);
template <>
inline std::string xToString<char>(const char& x);
template <>
inline std::string xToString<std::string>(const std::string& x);
using CNORXZ::DynamicMetaT;
template <>
inline std::string xToString<DynamicMetaT>(const DynamicMetaT& x);
template <typename T>
inline std::string xToString(const vector<T>& x);
template <typename T, size_t N>
inline std::string xToString(const std::array<T,N>& x);
template <typename... Ts>
inline std::string xToString(const std::tuple<Ts...>& tp);
// TEMPLATE CODE
template <typename T>
inline std::string xToString(const T& x)
{
std::string out = std::to_string(x);
std::replace(out.begin(), out.end(), ',', '.');
return out;
}
template <size_t N>
struct TupleToString
{
template <typename... Ts>
static inline std::string mk(const std::tuple<Ts...>& tp)
{
return TupleToString<N-1>::mk(tp) + "," + xToString(std::get<N>(tp));
}
};
template <>
struct TupleToString<0>
{
template <typename... Ts>
static inline std::string mk(const std::tuple<Ts...>& tp)
{
return xToString(std::get<0>(tp));
}
};
template <>
inline std::string xToString<char>(const char& x)
{
std::string out = "";
return out += x;
}
template <>
inline std::string xToString<std::string>(const std::string& x)
{
return x;
}
template <>
inline std::string xToString<DynamicMetaT>(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 <typename T>
inline std::string xToString(const vector<T>& x)
{
std::string out = "[";
for(auto& y: x){
out += xToString(y) + ",";
}
//out.pop_back();
out.back() = ']';
return out;
}
template <typename T, size_t N>
inline std::string xToString(const std::array<T,N>& x)
{
std::string out = "[";
for(auto& y: x){
out += xToString(y) + ",";
}
//out.pop_back();
out.back() = ']';
return out;
}
template <typename... Ts>
inline std::string xToString(const std::tuple<Ts...>& tp)
{
return "{" + TupleToString<sizeof...(Ts)-1>::mk(tp) + "}";
}
}
#endif

View file

@ -1,300 +0,0 @@
#include "slice.h"
namespace CNORXZ
{
/*******************
* ConstSlice *
*******************/
template <typename T, class... SRanges>
void ConstSlice<T,SRanges...>::format(const std::array<size_t,sizeof...(SRanges)+1>& blocks)
{
MAB::mProtoI->format(blocks);
}
template <typename T, class... SRanges>
ConstSlice<T,SRanges...>::ConstSlice(const std::tuple<std::shared_ptr<SRanges>...>& ranges,
const T* data) :
ArrayBase<T,SRanges...>(ranges),
mData(data)
{
MAB::mInit = true;
}
template <typename T, class... SRanges>
ConstSlice<T,SRanges...>::ConstSlice(const std::shared_ptr<SRanges>&... ranges, const T* data) :
ArrayBase<T,SRanges...>(ranges...),
mData(data)
{
MAB::mInit = true;
}
template <typename T, class... SRanges>
ConstSlice<T,SRanges...>::ConstSlice(const ArrayBase<T,AnonymousRange>& ma, SIZET<SRanges>... sizes) :
ArrayBase<T,SRanges...>
( ma.range()->template get<0>().template scast<SRanges...>(sizes...)->space() ),
mData( ma.data() )
{
MAB::mInit = true;
}
template <typename T, class... SRanges>
const T& ConstSlice<T,SRanges...>::operator[](const IType& i) const
{
//assert(i.sliceMode()); // -> compare objects !!!!!
assert(i.container() == reinterpret_cast<std::intptr_t>(this));
return mData[ i.pos() ];
}
template <typename T, class... SRanges>
const T& ConstSlice<T,SRanges...>::at(const typename IType::MetaType& meta) const
{
//auto x = begin().at(meta);
//VCHECK(x.pos());
return mData[ begin().at(meta).pos() ];
}
template <typename T, class... SRanges>
const T* ConstSlice<T,SRanges...>::data() const
{
return mData;
}
template <typename T, class... SRanges>
bool ConstSlice<T,SRanges...>::isSlice() const
{
return true;
}
template <typename T, class... SRanges>
auto ConstSlice<T,SRanges...>::begin() const -> ConstSlice<T,SRanges...>::IType
{
IType i(*MAB::mProtoI,true);
i = 0;
//i = mStartPos;
return i.setData(data());
}
template <typename T, class... SRanges>
auto ConstSlice<T,SRanges...>::end() const -> ConstSlice<T,SRanges...>::IType
{
IType i(*MAB::mProtoI,true);
i = i.max(); // CHECK !!!
//i = std::get<sizeof...(SRanges)>(mBlockSizes);
return i.setData(data());
}
template <typename T, class... SRanges>
std::shared_ptr<ArrayBase<T,AnonymousRange> > ConstSlice<T,SRanges...>::anonymous(bool slice) const
{
assert(slice);
assert(not MAB::mProtoI->sliceMode()); // only originally ordered slices!
AnonymousRangeFactory arf(MAB::mRange->space());
return std::make_shared<ConstSlice<T,AnonymousRange> >
( std::dynamic_pointer_cast<AnonymousRange>( arf.create() ),
data() );
return nullptr;
}
template <typename T, class... SRanges>
auto ConstSlice<T,SRanges...>::define(const std::shared_ptr<typename SRanges::IndexType>&... inds)
-> ConstSliceDef<T,SRanges...>
{
return ConstSliceDef<T,SRanges...>(*this, inds...);
}
/**************
* Slice *
**************/
template <typename T, class... SRanges>
void Slice<T,SRanges...>::format(const std::array<size_t,sizeof...(SRanges)+1>& blocks)
{
MAB::mProtoI->format(blocks);
}
template <typename T, class... SRanges>
Slice<T,SRanges...>::Slice(const std::shared_ptr<SRanges>&... ranges, T* data) :
MutableArrayBase<T,SRanges...>(ranges...),
mData(data) {}
template <typename T, class... SRanges>
Slice<T,SRanges...>::Slice(const std::tuple<std::shared_ptr<SRanges>...>& ranges,
T* data) :
MutableArrayBase<T,SRanges...>(ranges),
mData(data)
{
MAB::mInit = true;
}
template <typename T, class... SRanges>
Slice<T,SRanges...>& Slice<T,SRanges...>::operator=(T val)
{
OperationRoot<T,SRanges...> opr(data(), begin());
OperationValue<T> opv(val);
opr = opv;
return *this;
}
template <typename T, class... SRanges>
const T& Slice<T,SRanges...>::operator[](const IType& i) const
{
//assert(i.sliceMode()); // -> compare objects !!!!!
assert(i.container() == reinterpret_cast<std::intptr_t>(this));
return mData[ i.pos() ];
}
template <typename T, class... SRanges>
T& Slice<T,SRanges...>::operator[](const IType& i)
{
//assert(i.sliceMode());
assert(i.container() == reinterpret_cast<std::intptr_t>(this));
return mData[ i.pos() ];
}
template <typename T, class... SRanges>
const T& Slice<T,SRanges...>::at(const typename IType::MetaType& meta) const
{
//auto x = begin().at(meta);
//VCHECK(x.pos());
return mData[ begin().at(meta).pos() ];
}
template <typename T, class... SRanges>
T& Slice<T,SRanges...>::at(const typename IType::MetaType& meta)
{
//auto x = begin().at(meta);
//VCHECK(x.pos());
return mData[ begin().at(meta).pos() ];
}
template <typename T, class... SRanges>
const T* Slice<T,SRanges...>::data() const
{
return mData;
}
template <typename T, class... SRanges>
T* Slice<T,SRanges...>::data()
{
return mData;
}
template <typename T, class... SRanges>
bool Slice<T,SRanges...>::isSlice() const
{
return true;
}
template <typename T, class... SRanges>
auto Slice<T,SRanges...>::begin() const -> Slice<T,SRanges...>::IType
{
IType i(*MAB::mProtoI,true);
i = 0;
//i = mStartPos;
return i.setData(data());
}
template <typename T, class... SRanges>
auto Slice<T,SRanges...>::end() const -> Slice<T,SRanges...>::IType
{
IType i(*MAB::mProtoI,true);
i = i.max(); // CHECK !!!
//i = std::get<sizeof...(SRanges)>(mBlockSizes);
return i.setData(data());
}
template <typename T, class... SRanges>
std::shared_ptr<ArrayBase<T,AnonymousRange> > Slice<T,SRanges...>::anonymous(bool slice) const
{
assert(0); // think about carefully!!!!
return nullptr;
}
/*
template <typename T, class... SRanges>
std::shared_ptr<ArrayBase<T,AnonymousRange> > Slice<T,SRanges...>::anonymousMove()
{
assert(0); // think about carefully!!!!
return nullptr;
}
*/
template <typename T, class... SRanges>
auto Slice<T,SRanges...>::define(const std::shared_ptr<typename SRanges::IndexType>&... inds)
-> SliceDef<T,SRanges...>
{
return SliceDef<T,SRanges...>(*this, inds...);
}
template <typename T, class... SRanges>
SliceDef<T,SRanges...>::SliceDef(Slice<T,SRanges...>& sl,
const std::shared_ptr<typename SRanges::IndexType>&... inds) :
mIndex(sl.begin()),
mSl(sl)
{
mIndex(inds...);
}
template <typename T, class... SRanges>
template <class... ORanges>
SliceDef<T,SRanges...>& SliceDef<T,SRanges...>::operator=(const OperationRoot<T,ORanges...>& op)
{
std::array<size_t,sizeof...(SRanges)+1> blocks;
sfor_pn<0,sizeof...(SRanges)>
( [&](auto i) {
std::get<i+1>(blocks) =
op.rootSteps(reinterpret_cast<std::intptr_t>
( mIndex.template getPtr<i>().get())).val();
return 0; } );
mSl.format(blocks);
mSl.mData = op.data();
return *this;
}
template <typename T, class... SRanges>
ConstSliceDef<T,SRanges...>::ConstSliceDef(ConstSlice<T,SRanges...>& sl,
const std::shared_ptr<typename SRanges::IndexType>&... inds) :
mIndex(sl.begin()),
mSl(sl)
{
mIndex(inds...);
}
template <typename T, class... SRanges>
template <class... ORanges>
ConstSliceDef<T,SRanges...>& ConstSliceDef<T,SRanges...>::operator=(const ConstOperationRoot<T,ORanges...>& op)
{
std::array<size_t,sizeof...(SRanges)+1> blocks;
sfor_pn<0,sizeof...(SRanges)>
( [&](auto i) {
std::get<i+1>(blocks) =
op.rootSteps(reinterpret_cast<std::intptr_t>
( mIndex.template getPtr<i>().get())).val();
return 0; } );
mSl.format(blocks);
mSl.mData = op.data();
return *this;
}
template <typename T, class... SRanges>
template <class... ORanges>
ConstSliceDef<T,SRanges...>& ConstSliceDef<T,SRanges...>::operator=(const OperationRoot<T,ORanges...>& op)
{
std::array<size_t,sizeof...(SRanges)+1> blocks;
sfor_pn<0,sizeof...(SRanges)>
( [&](auto i) {
std::get<i+1>(blocks) =
op.rootSteps(reinterpret_cast<std::intptr_t>
( mIndex.template getPtr<i>().get())).val();
return 0; } );
mSl.format(blocks);
mSl.mData = op.data();
return *this;
}
} // end namespace CNORXZ

View file

@ -1,198 +0,0 @@
#ifndef __cxz_slice_h__
#define __cxz_slice_h__
#include "cxz_array_base.h"
#include "cxz_operation.h"
namespace CNORXZ
{
template <typename T, class... SRanges>
class ConstSlice : public ArrayBase<T,SRanges...>
{
public:
typedef ContainerRange<SRanges...> CRange;
typedef ArrayBase<T,SRanges...> MAB;
typedef ConstContainerIndex<T,typename SRanges::IndexType...> IType;
using ArrayBase<T,SRanges...>::operator();
using ArrayBase<T,SRanges...>::operator[];
DEFAULT_MEMBERS(ConstSlice);
ConstSlice(const std::tuple<std::shared_ptr<SRanges>...>& ranges,
const T* data = nullptr);
ConstSlice(const std::shared_ptr<SRanges>&... ranges, const T* data = nullptr);
ConstSlice(const ArrayBase<T,AnonymousRange>& ma, SIZET<SRanges>... 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<ArrayBase<T,AnonymousRange> > anonymous(bool slice = false) const override;
auto define(const std::shared_ptr<typename SRanges::IndexType>&... inds)
-> ConstSliceDef<T,SRanges...>;
private:
friend ConstSliceDef<T,SRanges...>;
void format(const std::array<size_t,sizeof...(SRanges)+1>& blocks);
const T* mData;
};
template <typename T, class... SRanges>
class Slice : public MutableArrayBase<T,SRanges...>
{
public:
typedef ContainerRange<SRanges...> CRange;
typedef ArrayBase<T,SRanges...> MAB;
typedef ConstContainerIndex<T,typename SRanges::IndexType...> IType;
using ArrayBase<T,SRanges...>::operator();
using MutableArrayBase<T,SRanges...>::operator();
using ArrayBase<T,SRanges...>::operator[];
using MutableArrayBase<T,SRanges...>::operator[];
DEFAULT_MEMBERS(Slice);
Slice(const std::tuple<std::shared_ptr<SRanges>...>& ranges,
T* data = nullptr);
Slice(const std::shared_ptr<SRanges>&... 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<ArrayBase<T,AnonymousRange> > anonymous(bool slice = false) const override;
//virtual std::shared_ptr<ArrayBase<T,AnonymousRange> > anonymousMove() override;
auto define(const std::shared_ptr<typename SRanges::IndexType>&... inds)
-> SliceDef<T,SRanges...>;
private:
friend SliceDef<T,SRanges...>;
void format(const std::array<size_t,sizeof...(SRanges)+1>& blocks);
T* mData;
};
template <typename T, class... SRanges>
class SliceDef
{
public:
typedef ConstContainerIndex<T,typename SRanges::IndexType...> IType;
template <class Op>
static Slice<T,SRanges...> mkSlice( const typename Slice<T,SRanges...>::IndexType& ind,
const Op& op )
{
Slice<T,SRanges...> out(ind->range()->space(), &*ind);
std::array<size_t,sizeof...(SRanges)+1> ff;
sfor_pn<0,sizeof...(SRanges)>
( [&](auto i) {
std::get<i+1>(ff) =
op.rootSteps(reinterpret_cast<std::intptr_t>
( ind.template getPtr<i>().get())).val();
return 0; } );
out.format(ff);
return out;
}
private:
IType mIndex;
Slice<T,SRanges...>& mSl;
SliceDef() = default;
public:
SliceDef(Slice<T,SRanges...>& sl,
const std::shared_ptr<typename SRanges::IndexType>&... inds);
template <class... ORanges>
SliceDef& operator=(const OperationRoot<T,ORanges...>& op);
};
template <typename T, class... SRanges>
class ConstSliceDef
{
public:
typedef ConstContainerIndex<T,typename SRanges::IndexType...> IType;
template <class Op>
static ConstSlice<T,SRanges...> mkSlice( const typename ConstSlice<T,SRanges...>::IndexType& ind,
const Op& op )
{
ConstSlice<T,SRanges...> out(ind->range()->space(), &*ind);
std::array<size_t,sizeof...(SRanges)+1> ff;
sfor_pn<0,sizeof...(SRanges)>
( [&](auto i) {
std::get<i+1>(ff) =
op.rootSteps(reinterpret_cast<std::intptr_t>
( ind.template getPtr<i>().get())).val();
return 0; } );
out.format(ff);
return out;
}
private:
IType mIndex;
ConstSlice<T,SRanges...>& mSl;
ConstSliceDef() = default;
public:
ConstSliceDef(ConstSlice<T,SRanges...>& csl,
const std::shared_ptr<typename SRanges::IndexType>&... inds);
template <class... ORanges>
ConstSliceDef& operator=(const ConstOperationRoot<T,ORanges...>& op);
template <class... ORanges>
ConstSliceDef& operator=(const OperationRoot<T,ORanges...>& op);
};
template <typename T, class Op, class... Ranges>
ConstSlice<T,Ranges...> mkSlice( const typename ConstSlice<T,Ranges...>::IndexType& ind,
const Op& op )
{
return ConstSliceDef<T,Ranges...>::mkSlice(ind, op);
}
template <typename T, class Op, class... Ranges>
Slice<T,Ranges...> mkSlice( const typename Slice<T,Ranges...>::IndexType& ind,
const Op& op )
{
return SliceDef<T,Ranges...>::mkSlice(ind, op);
}
} // end namespace CNORXZ
/* ========================= *
* --- TEMPLATE CODE --- *
* ========================= */
#endif

View file

@ -1,40 +0,0 @@
#include "cnorxz.h"
#include "hl_cnorxz.h"
namespace CNORXZ
{
std::shared_ptr<DynamicIndex> mkSubSpaceX(const std::shared_ptr<DynamicIndex>& di,
size_t max)
{
auto& o = di->range()->orig();
vector<std::shared_ptr<RangeBase>> ox(o.begin(),o.begin()+max);
DynamicRangeFactory drf(ox);
auto dr = createExplicit(drf);
auto odi = getIndex(dr);
vector<std::shared_ptr<IndexW>> 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<double,CR,DynamicRange>;
template class OperationRoot<double,DynamicRange>;
template class HighLevelOpHolder<OpCD>;
template class HighLevelOpHolder<OpD>;
template class HighLevelOpBase<OpCD>;
template class HighLevelOpBase<OpD>;
template class HighLevelOpRoot<OpCD>;
template class HighLevelOpRoot<OpD>;
template HighLevelOpHolder<OpCD> mkHLO(const OpCD& op);
template HighLevelOpHolder<OpD> mkHLO(const OpD& op);
template HighLevelOpHolder<OpCD> mkHLOV(double val);
template HighLevelOpHolder<OpD> mkHLOV(double val);
}

View file

@ -1,8 +0,0 @@
#include "cnorxz.h"
#include "hl_cnorxz.h"
namespace CNORXZ
{
template class HighLevelOp<OpCD,dividesx<double,double>,2>;
template class HighLevelOp<OpD,dividesx<double,double>,2>;
}

View file

@ -1,10 +0,0 @@
#include "cnorxz.h"
#include "hl_cnorxz.h"
namespace CNORXZ
{
template class HighLevelOp<OpCD,x_exp<double>,1>;
template class HighLevelOp<OpD,x_exp<double>,1>;
template HighLevelOpHolder<OpCD> hl_exp (const HighLevelOpHolder<OpCD>& in);
template HighLevelOpHolder<OpD> hl_exp (const HighLevelOpHolder<OpD>& in);
}

View file

@ -1,8 +0,0 @@
#include "cnorxz.h"
#include "hl_cnorxz.h"
namespace CNORXZ
{
template class HighLevelOp<OpCD,minusx<double,double>,2>;
template class HighLevelOp<OpD,minusx<double,double>,2>;
}

View file

@ -1,8 +0,0 @@
#include "cnorxz.h"
#include "hl_cnorxz.h"
namespace CNORXZ
{
template class HighLevelOp<OpCD,multipliesx<double,double>,2>;
template class HighLevelOp<OpD,multipliesx<double,double>,2>;
}

View file

@ -1,8 +0,0 @@
#include "cnorxz.h"
#include "hl_cnorxz.h"
namespace CNORXZ
{
template class HighLevelOp<OpCD,negate<double>,1>;
template class HighLevelOp<OpD,negate<double>,1>;
}

View file

@ -1,8 +0,0 @@
#include "cnorxz.h"
#include "hl_cnorxz.h"
namespace CNORXZ
{
template class HighLevelOp<OpCD,plusx<double,double>,2>;
template class HighLevelOp<OpD,plusx<double,double>,2>;
}

View file

@ -1,7 +0,0 @@
#include "map_range_factory_product_map.h"
namespace CNORXZ
{
std::map<std::shared_ptr<RangeBase>,vector<std::intptr_t> > MapRangeFactoryProductMap::mAleadyCreated;
}

View file

@ -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<OpCD,x_${fff}<double>,1>;" >> ${file}
echo " template class HighLevelOp<OpD,x_${fff}<double>,1>;" >> ${file}
echo " template HighLevelOpHolder<OpCD> hl_${fff} (const HighLevelOpHolder<OpCD>& in);" >> ${file}
echo " template HighLevelOpHolder<OpD> hl_${fff} (const HighLevelOpHolder<OpD>& 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<OpCD,${fff}x<double,double>,2>;" >> ${file}
echo " template class HighLevelOp<OpD,${fff}x<double,double>,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<OpCD,${fff}<double>,1>;" >> ${file}
echo " template class HighLevelOp<OpD,${fff}<double>,1>;" >> ${file}
echo "}" >> ${file}
done

View file

@ -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<oType>( new AnonymousRange() );
}
std::map<std::shared_ptr<RangeBase>,vector<std::intptr_t> > AnonymousRangeFactory::mAleadyCreated;
AnonymousRangeFactory::AnonymousRangeFactory(const vector<std::shared_ptr<RangeBase>>& origs)
{
mProd = std::shared_ptr<oType>( new AnonymousRange( origs ) );
}
std::shared_ptr<RangeBase> AnonymousRangeFactory::checkIfCreated(const vector<std::shared_ptr<RangeBase> >& pvec)
{
std::shared_ptr<RangeBase> 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<std::intptr_t>( pvec[i].get() ) ){
check = false;
break;
}
}
if(check == true){
out = x.first;
break;
}
}
}
if(not check){
vector<std::intptr_t> app(pvec.size());
for(size_t i = 0; i != app.size(); ++i){
app[i] = reinterpret_cast<std::intptr_t>( pvec[i].get() );
}
mAleadyCreated[mProd] = app;
out = mProd;
}
return out;
}
std::shared_ptr<RangeBase> AnonymousRangeFactory::create()
{
mProd = checkIfCreated(std::dynamic_pointer_cast<AnonymousRange>(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<size_t> AnonymousRange::typeNum() const
{
vector<size_t> 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<char> AnonymousRange::data() const
{
DataHeader h = dataHeader();
vector<char> out;
char* hcp = reinterpret_cast<char*>(&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<int>( 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<AnonymousRange>
( std::shared_ptr<RangeBase>(RB::mThis) ) );
i = 0;
return i;
}
typename AnonymousRange::IndexType AnonymousRange::end() const
{
AnonymousIndex i
(std::dynamic_pointer_cast<AnonymousRange>
( std::shared_ptr<RangeBase>(RB::mThis) ) );
i = size();
return i;
}
std::shared_ptr<RangeBase> AnonymousRange::sub(size_t num) const
{
return mOrig.at(num);
}
std::shared_ptr<AnonymousRange> AnonymousRange::sreplace(const std::shared_ptr<RangeBase> 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<AnonymousRange>(arf.create());
}
std::shared_ptr<AnonymousRange> AnonymousRange::sreplace(const vector<std::shared_ptr<RangeBase>>& 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<AnonymousRange>(arf.create());
}
std::shared_ptr<AnonymousRange> AnonymousRange::sreplace(const std::shared_ptr<RangeBase>& in,
const vector<size_t>& 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<std::shared_ptr<RangeBase>> 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<AnonymousRange>(arf.create());
}
else {
return std::dynamic_pointer_cast<AnonymousRange>( std::shared_ptr<RangeBase>(RB::mThis) );
}
}
const vector<std::shared_ptr<RangeBase> >& AnonymousRange::orig() const
{
return mOrig;
}
GenSingleRange<size_t,SpaceType::ANON,MUI>::GenSingleRange(const vector<std::shared_ptr<RangeBase>>& origs) :
RangeInterface<AnonymousIndex>(),
mOrig(origs)
{
mSize = 1;
for(auto& x: mOrig){
mSize *= x->size();
}
if(mOrig.size()){
mEmpty = false;
}
}
/*****************
* Functions *
*****************/
std::shared_ptr<AnonymousRange> defaultRange(size_t size )
{
AnonymousRangeFactory arf
( std::dynamic_pointer_cast<AnonymousRange>
(AnonymousRange::factory().create() ) );
return std::dynamic_pointer_cast<AnonymousRange>( arf.create() );
}
} // end namespace CNORXZ

View file

@ -1,48 +0,0 @@
#include <cstdlib>
#include <vector>
#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

View file

@ -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<std::shared_ptr<RangeBase>>& origs)
{
mProd = std::shared_ptr<oType>( new DynamicRange( origs ) );
}
DynamicRangeFactory::DynamicRangeFactory()
{
mProd = std::shared_ptr<oType>( new DynamicRange() );
}
// INSTANCIATE IF NEEDED!!
std::map<std::shared_ptr<RangeBase>,vector<std::intptr_t> > DynamicRangeFactory::mAleadyCreated;
DynamicIndex::IMapT DynamicIndex::sIMap;
std::shared_ptr<RangeBase> DynamicRangeFactory::checkIfCreated(const vector<std::shared_ptr<RangeBase> >& pvec)
{
std::shared_ptr<RangeBase> 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<std::intptr_t>( pvec[i].get() ) ){
check = false;
break;
}
}
if(check == true){
out = x.first;
break;
}
}
}
if(not check){
vector<std::intptr_t> app(pvec.size());
for(size_t i = 0; i != app.size(); ++i){
app[i] = reinterpret_cast<std::intptr_t>( pvec[i].get() );
}
mAleadyCreated[mProd] = app;
out = mProd;
}
return out;
}
std::shared_ptr<RangeBase> DynamicRangeFactory::create()
{
mProd = checkIfCreated(std::dynamic_pointer_cast<DynamicRange>(mProd)->mOrig);
setSelf();
mProductCreated = true;
return mProd;
}
/*********************
* DynamicIndex *
*********************/
DynamicIndex::DynamicIndex(const std::shared_ptr<DynamicRange >& range) :
IndexInterface<DynamicIndex,MetaType>(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<std::shared_ptr<IndexW>>& 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<std::string>& 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<DynamicRange const>( IB::mRangePtr )->stringMeta(IB::mPos);
}
typename DynamicIndex::MetaType DynamicIndex::meta() const
{
return std::dynamic_pointer_cast<DynamicRange const>( 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<DynamicRange const>( IB::mRangePtr )->getMeta( metaPos );
return *this;
}
size_t DynamicIndex::posAt(const MetaType& metaPos) const
{
return std::dynamic_pointer_cast<DynamicRange const>( 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<IndexW>& DynamicIndex::getP(size_t n) const
{
MA_ASSERT(mIvecInit, "ivec not initialized");
return mIVec[n].first;
}
std::shared_ptr<typename DynamicIndex::RangeType> DynamicIndex::range()
{
return std::dynamic_pointer_cast<RangeType>( 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<char> 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<size_t> DynamicRange::typeNum() const
{
vector<size_t> 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<char> DynamicRange::data() const
{
DataHeader h = dataHeader();
vector<char> out;
char* hcp = reinterpret_cast<char*>(&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<int>( SpaceType::DYN );
h.metaSize = mOrig.size();
h.multiple = 1;
return h;
}
typename DynamicRange::IndexType DynamicRange::begin() const
{
DynamicIndex i
(std::dynamic_pointer_cast<DynamicRange>
( std::shared_ptr<RangeBase>(RB::mThis) ) );
i = 0;
return i;
}
typename DynamicRange::IndexType DynamicRange::end() const
{
DynamicIndex i
(std::dynamic_pointer_cast<DynamicRange>
( std::shared_ptr<RangeBase>(RB::mThis) ) );
i = size();
return i;
}
std::shared_ptr<RangeBase> DynamicRange::sub(size_t num) const
{
return mOrig.at(num);
}
void DynamicRange::sreplace(const std::shared_ptr<RangeBase> 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<std::shared_ptr<RangeBase>>& origs) :
RangeInterface<DynamicIndex>(),
mOrig(origs)
{
mSize = 1;
for(auto& x: mOrig){
mSize *= x->size();
}
if(mOrig.size()){
mEmpty = false;
}
}
const vector<std::shared_ptr<RangeBase> >& DynamicRange::orig() const
{
return mOrig;
}
} // end namespace CNORXZ

View file

@ -1,8 +0,0 @@
#include "ranges/multi_range_factory_product_map.h"
#include "ranges/ranges_header.cc.h"
namespace CNORXZ
{
std::map<std::shared_ptr<RangeBase>,vector<std::intptr_t> > MultiRangeFactoryProductMap::mAleadyCreated;
}

View file

@ -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<PSpaceRF> mkPSPACE(const char* dp, size_t size)
{
size_t max = *reinterpret_cast<const size_t*>(dp);
return std::make_shared<PSpaceRF>(max);
}
/********************
* GenSingleRange *
********************/
GenSingleRangeFactory<int,SpaceType::PSPACE,MUI>::GenSingleRangeFactory(size_t size)
{
// Quasi Singleton
if(not mProd){
mProd = std::shared_ptr<oType>( new GenSingleRange<int,SpaceType::PSPACE,MUI>(size) );
setSelf();
}
}
std::shared_ptr<RangeBase> GenSingleRangeFactory<int,SpaceType::PSPACE,MUI>::create()
{
return mProd;
}
/********************
* GenSingleRange *
********************/
GenSingleRange<int,SpaceType::PSPACE,MUI>::GenSingleRange(size_t size) : mSize(size) { }
int GenSingleRange<int,SpaceType::PSPACE,MUI>::get(size_t pos) const
{
return pos > mSize / 2 ? pos - mSize : pos;
}
size_t GenSingleRange<int,SpaceType::PSPACE,MUI>::getMeta(int metaPos) const
{
return metaPos < 0 ? metaPos + mSize : metaPos;
}
size_t GenSingleRange<int,SpaceType::PSPACE,MUI>::size() const
{
return mSize;
}
size_t GenSingleRange<int,SpaceType::PSPACE,MUI>::dim() const
{
return 1;
}
SpaceType GenSingleRange<int,SpaceType::PSPACE,MUI>::spaceType() const
{
return SpaceType::PSPACE;
}
vector<size_t> GenSingleRange<int,SpaceType::PSPACE,MUI>::typeNum() const
{
return {NumTypeMap<int>::num()};
}
size_t GenSingleRange<int,SpaceType::PSPACE,MUI>::cmeta(char* target, size_t pos) const
{
*reinterpret_cast<int*>(target) = get(pos);
return sizeof(int);
}
size_t GenSingleRange<int,SpaceType::PSPACE,MUI>::cmetaSize() const
{
return sizeof(int);
}
std::string GenSingleRange<int,SpaceType::PSPACE,MUI>::stringMeta(size_t pos) const
{
return std::to_string(get(pos));
}
vector<char> GenSingleRange<int,SpaceType::PSPACE,MUI>::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));
const char* scp = reinterpret_cast<const char*>(&mSize);
out.insert(out.end(), scp, scp + h.metaSize);
return out;
}
DataHeader GenSingleRange<int,SpaceType::PSPACE,MUI>::dataHeader() const
{
DataHeader h;
h.spaceType = static_cast<int>( SpaceType::PSPACE );
h.metaSize = sizeof(size_t);
h.multiple = 0;
return h;
}
typename GenSingleRange<int,SpaceType::PSPACE,MUI>::IndexType GenSingleRange<int,SpaceType::PSPACE,MUI>::begin() const
{
GenSingleIndex<int,SpaceType::PSPACE,MUI> i( std::dynamic_pointer_cast<GenSingleRange<int,SpaceType::PSPACE,MUI> >
( std::shared_ptr<RangeBase>( RB::mThis ) ) );
i = 0;
return i;
}
typename GenSingleRange<int,SpaceType::PSPACE,MUI>::IndexType GenSingleRange<int,SpaceType::PSPACE,MUI>::end() const
{
GenSingleIndex<int,SpaceType::PSPACE,MUI> i( std::dynamic_pointer_cast<GenSingleRange<int,SpaceType::PSPACE,MUI> >
( std::shared_ptr<RangeBase>( RB::mThis ) ) );
i = size();
return i;
}
}

View file

@ -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<SpinRF> mkSPIN(const char* dp, size_t size)
{
return std::make_shared<SpinRF>();
}
/********************
* GenSingleRange *
********************/
GenSingleRangeFactory<size_t,SpaceType::SPIN,4>::GenSingleRangeFactory()
{
// Quasi Singleton
if(not mProd){
mProd = std::shared_ptr<oType>( new GenSingleRange<size_t,SpaceType::SPIN,4>() );
setSelf();
}
}
std::shared_ptr<RangeBase> GenSingleRangeFactory<size_t,SpaceType::SPIN,4>::create()
{
return mProd;
}
/********************
* GenSingleRange *
********************/
size_t GenSingleRange<size_t,SpaceType::SPIN,4>::get(size_t pos) const
{
return pos;
}
size_t GenSingleRange<size_t,SpaceType::SPIN,4>::getMeta(size_t metaPos) const
{
return metaPos;
}
size_t GenSingleRange<size_t,SpaceType::SPIN,4>::size() const
{
return mSpinNum;
}
size_t GenSingleRange<size_t,SpaceType::SPIN,4>::dim() const
{
return 1;
}
SpaceType GenSingleRange<size_t,SpaceType::SPIN,4>::spaceType() const
{
return SpaceType::SPIN;
}
vector<size_t> GenSingleRange<size_t,SpaceType::SPIN,4>::typeNum() const
{
return {NumTypeMap<size_t>::num()};
}
size_t GenSingleRange<size_t,SpaceType::SPIN,4>::cmeta(char* target, size_t pos) const
{
*reinterpret_cast<size_t*>(target) = pos;
return sizeof(size_t);
}
size_t GenSingleRange<size_t,SpaceType::SPIN,4>::cmetaSize() const
{
return sizeof(size_t);
}
std::string GenSingleRange<size_t,SpaceType::SPIN,4>::stringMeta(size_t pos) const
{
return std::to_string(get(pos));
}
vector<char> GenSingleRange<size_t,SpaceType::SPIN,4>::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));
return out;
}
DataHeader GenSingleRange<size_t,SpaceType::SPIN,4>::dataHeader() const
{
DataHeader h;
h.spaceType = static_cast<int>( SpaceType::SPIN );
h.metaSize = 0;
h.multiple = 0;
return h;
}
typename GenSingleRange<size_t,SpaceType::SPIN,4>::IndexType GenSingleRange<size_t,SpaceType::SPIN,4>::begin() const
{
GenSingleIndex<size_t,SpaceType::SPIN,4> i( std::dynamic_pointer_cast<GenSingleRange<size_t,SpaceType::SPIN,4> >
( std::shared_ptr<RangeBase>( RB::mThis ) ) );
i = 0;
return i;
}
typename GenSingleRange<size_t,SpaceType::SPIN,4>::IndexType GenSingleRange<size_t,SpaceType::SPIN,4>::end() const
{
GenSingleIndex<size_t,SpaceType::SPIN,4> i( std::dynamic_pointer_cast<GenSingleRange<size_t,SpaceType::SPIN,4> >
( std::shared_ptr<RangeBase>( RB::mThis ) ) );
i = size();
return i;
}
// put this in the interface class !!!
/*
std::shared_ptr<VIWB> GenSingleRange<size_t,SpaceType::SPIN,4>::index() const
{
typedef IndexWrapper<IndexType> IW;
return std::make_shared<IW>
( std::make_shared<IndexType>
( std::dynamic_pointer_cast<GenSingleRange<size_t,SpaceType::SPIN,4> >
( std::shared_ptr<RangeBase>( RB::mThis ) ) ) );
}
*/
}

View file

@ -1,175 +0,0 @@
namespace CNORXZ
{
template <class... Ranges>
using STP = std::tuple<std::shared_ptr<Ranges>...>;
typedef vector<std::shared_ptr<RangeBase> > RVEC;
template <class... Ranges>
inline bool compareSpaceTypes(const RVEC& rvec)
{
return RangeHelper::compareSpaceTypes<sizeof...(Ranges)-1,sizeof...(Ranges),Ranges...>(rvec);
}
template <class... Ranges>
inline bool setFactory(const RVEC& rvec, std::shared_ptr<RangeFactoryBase>& fptr)
{
if(compareSpaceTypes<Ranges...>(rvec)) {
STP<Ranges...> stp;
RangeHelper::setSpace<sizeof...(Ranges)-1>(rvec, stp);
fptr = std::make_shared<MultiRangeFactory<Ranges...> >(stp);
return true;
}
else {
return false;
}
}
size_t indexId()
{
static size_t id = 0;
++id;
return id;
}
std::shared_ptr<RangeFactoryBase> mkMULTI(char const** dp, size_t metaSize)
{
std::shared_ptr<RangeFactoryBase> 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<TT0>(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<TT0,TT1>(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<TT0,TT1,TT2>(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<TT0,TT1,TT2,TT3>(rvec, out)) {} else
#include "ranges/multi_range_register.h"
#undef register_multi4
assert(0);
}
else {
assert(0);
}
return out;
}
std::shared_ptr<RangeFactoryBase> mkANONYMOUS(char const** dp, size_t metaSize)
{
std::shared_ptr<RangeFactoryBase> out = nullptr;
auto arf = std::make_shared<AnonymousRangeFactory>();
for(size_t i = 0; i != metaSize; ++i){
auto ff = createRangeFactory(dp);
arf->append( ff->create() );
}
out = arf;
return out;
}
std::shared_ptr<RangeFactoryBase> mkANY(int metaType, size_t metaSize, char const** dp)
{
std::shared_ptr<RangeFactoryBase> out = nullptr;
if(metaType == -1){
assert(0);
}
#define register_type(x) else if(x == metaType) { \
vector<TypeMap<x>::type> vd; \
metaCat(vd, *dp, metaSize); \
out = std::make_shared<SingleRangeFactory<TypeMap<x>::type, \
SpaceType::ANY> >(vd); }
#include "ranges/type_map.h"
#undef register_type
else {
assert(0);
}
return out;
}
std::shared_ptr<RangeFactoryBase> createSingleRangeFactory(const vector<char>*& d, int metaType, size_t size)
{
std::shared_ptr<RangeFactoryBase> out = nullptr;
if(metaType == -1){
assert(0);
}
#define register_type(x) else if(x == metaType) { \
vector<TypeMap<x>::type> vd(size); \
std::transform(d,d+size,vd.begin(), \
[](const vector<char>& c) \
{ assert(c.size() == sizeof(TypeMap<x>::type)); \
return *reinterpret_cast<TypeMap<x>::type const*>(c.data()); }); \
out = std::make_shared<SingleRangeFactory<TypeMap<x>::type, \
SpaceType::ANY> >(vd); }
#include "ranges/type_map.h"
#undef register_type
else {
assert(0);
}
return out;
}
std::shared_ptr<RangeFactoryBase> createRangeFactory(char const** dp)
{
DataHeader h = *reinterpret_cast<const DataHeader*>(*dp);
*dp += sizeof(DataHeader);
std::shared_ptr<RangeFactoryBase> out = nullptr;
if(h.multiple != 0){
if(h.spaceType == static_cast<int>( SpaceType::ANY )) {
// multi range
out = mkMULTI(dp, h.metaSize);
}
else if(h.spaceType == static_cast<int>( SpaceType::ANON ) ) {
// anonymous range
out = mkANONYMOUS(dp, h.metaSize);
}
else {
assert(0);
}
}
else {
if(h.spaceType == static_cast<int>( SpaceType::ANY ) ) {
// generic single range
out = mkANY(h.metaType, h.metaSize, dp);
}
else if(h.spaceType == static_cast<int>( SpaceType::NONE ) ) {
// classic range
size_t size = *reinterpret_cast<const size_t*>(*dp);
out = std::make_shared<SingleRangeFactory<size_t,SpaceType::NONE> >(size);
}
#define include_range_type(x,n) else if(h.spaceType == static_cast<int>( 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;
}
}

View file

@ -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<n>; \
template struct NumTypeMap<t>;
#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<size_t>,101)
include_type(vector<int>,102)
include_type(vector<double>,105)
include_type(vector<std::string>,106)
include_type(std::array<size_t XCOMMAX() 2>,201)
include_type(std::array<int XCOMMAX() 2>,202)
include_type(std::array<double XCOMMAX() 2>,205)
include_type(std::array<size_t XCOMMAX() 3>,301)
include_type(std::array<int XCOMMAX() 3>,302)
include_type(std::array<double XCOMMAX() 3>,305)
include_type(std::array<size_t XCOMMAX() 4>,401)
include_type(std::array<int XCOMMAX() 4>,402)
include_type(std::array<double XCOMMAX() 4>,405)
include_type(std::array<int XCOMMAX() 5>,502)
include_type(std::array<int XCOMMAX() 6>,602)
include_type(std::array<int XCOMMAX() 7>,702)
include_type(std::array<int XCOMMAX() 8>,802)
include_type(std::array<int XCOMMAX() 9>,902)
*/
#undef include_type
#undef XCOMMAX
}

View file

@ -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
...!!!