2018-10-22 14:27:55 +02:00
|
|
|
|
|
|
|
#ifndef __dynamic_range_h__
|
|
|
|
#define __dynamic_range_h__
|
|
|
|
|
2018-10-30 15:06:29 +01:00
|
|
|
#include <cassert>
|
|
|
|
|
2018-10-22 14:27:55 +02:00
|
|
|
#include "ranges/rbase_def.h"
|
|
|
|
#include "ranges/range_base.h"
|
|
|
|
#include "ranges/index_base.h"
|
|
|
|
|
2018-10-29 14:19:42 +01:00
|
|
|
#include "xfor/xfor.h"
|
2018-10-22 14:27:55 +02:00
|
|
|
|
2018-10-29 14:19:42 +01:00
|
|
|
#include <map>
|
2018-10-30 15:06:29 +01:00
|
|
|
//#include "ranges/rpheader.h"
|
2018-10-29 14:19:42 +01:00
|
|
|
#include "ranges/x_to_string.h"
|
|
|
|
#include "ranges/type_map.h"
|
2018-10-22 14:27:55 +02:00
|
|
|
|
2018-10-29 14:19:42 +01:00
|
|
|
#include "ranges/dynamic_meta.h"
|
2018-10-22 14:27:55 +02:00
|
|
|
|
2018-10-29 14:19:42 +01:00
|
|
|
namespace MultiArrayTools
|
|
|
|
{
|
2018-11-01 22:11:08 +01:00
|
|
|
namespace
|
|
|
|
{
|
|
|
|
using namespace MultiArrayHelper;
|
|
|
|
}
|
|
|
|
//using MultiArrayHelper::DynamicExpression;
|
2018-10-23 20:02:01 +02:00
|
|
|
|
2018-11-01 22:11:08 +01:00
|
|
|
//using MultiArrayHelper::ExpressionHolder;
|
2020-07-08 17:55:51 +02:00
|
|
|
/*
|
2018-11-06 16:35:37 +01:00
|
|
|
class AbstractIW
|
2018-10-22 14:27:55 +02:00
|
|
|
{
|
|
|
|
public:
|
2018-11-06 16:35:37 +01:00
|
|
|
AbstractIW() = default;
|
|
|
|
AbstractIW(const AbstractIW& in) = default;
|
|
|
|
AbstractIW(AbstractIW&& in) = default;
|
|
|
|
AbstractIW& operator=(const AbstractIW& in) = default;
|
|
|
|
AbstractIW& operator=(AbstractIW&& in) = default;
|
2018-10-22 14:27:55 +02:00
|
|
|
|
2020-07-08 17:55:51 +02:00
|
|
|
};
|
|
|
|
*/
|
|
|
|
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;
|
|
|
|
|
2018-10-22 14:27:55 +02:00
|
|
|
virtual IndexType type() const = 0;
|
|
|
|
|
2020-07-08 17:55:51 +02:00
|
|
|
virtual IndexWrapperBase& operator=(size_t pos) = 0;
|
|
|
|
virtual IndexWrapperBase& operator++() = 0;
|
|
|
|
virtual IndexWrapperBase& operator--() = 0;
|
2018-10-22 14:27:55 +02:00
|
|
|
|
|
|
|
virtual int pp(std::intptr_t idxPtrNum) = 0;
|
|
|
|
virtual int mm(std::intptr_t idxPtrNum) = 0;
|
|
|
|
|
|
|
|
virtual std::string stringMeta() const = 0;
|
2018-12-02 17:40:50 +01:00
|
|
|
|
2018-10-29 14:19:42 +01:00
|
|
|
virtual size_t pos() const = 0;
|
|
|
|
virtual size_t max() const = 0;
|
2018-10-27 14:58:34 +02:00
|
|
|
virtual size_t dim() const = 0;
|
|
|
|
virtual bool last() const = 0;
|
|
|
|
virtual bool first() const = 0;
|
2018-10-22 14:27:55 +02:00
|
|
|
|
2018-10-27 14:58:34 +02:00
|
|
|
virtual std::shared_ptr<RangeBase> range() const = 0;
|
2018-10-22 14:27:55 +02:00
|
|
|
|
2018-10-27 14:58:34 +02:00
|
|
|
virtual size_t getStepSize(size_t n) const = 0;
|
2018-10-29 14:19:42 +01:00
|
|
|
virtual size_t getStepSizeComp(std::intptr_t j) const = 0;
|
|
|
|
|
2018-10-22 14:27:55 +02:00
|
|
|
virtual std::intptr_t get() const = 0;
|
2018-11-01 22:11:08 +01:00
|
|
|
virtual std::intptr_t ptrNum() const = 0;
|
2018-11-06 16:35:37 +01:00
|
|
|
|
2020-07-08 17:55:51 +02:00
|
|
|
virtual std::shared_ptr<IndexWrapperBase> duplicate() const = 0;
|
2019-09-13 15:08:33 +02:00
|
|
|
|
2018-11-06 16:35:37 +01:00
|
|
|
//virtual DynamicMetaT meta() const = 0;
|
|
|
|
//virtual const DynamicMetaT* metaPtr() const = 0;
|
|
|
|
//virtual AbstractIW& at(const U& metaPos) = 0;
|
|
|
|
//virtual size_t posAt(const U& metaPos) const = 0;
|
|
|
|
|
|
|
|
//virtual bool isMeta(const U& metaPos) const = 0;
|
2020-07-08 17:55:51 +02:00
|
|
|
inline IndexWrapperBase& at(const std::string smeta)
|
2018-12-02 17:40:50 +01:00
|
|
|
{
|
|
|
|
for((*this) = 0; this->pos() != this->max(); ++(*this)){
|
|
|
|
if(this->stringMeta() == smeta){
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return *this;
|
|
|
|
}
|
2018-10-30 15:06:29 +01:00
|
|
|
|
2020-07-08 17:55:51 +02:00
|
|
|
virtual DynamicExpression ifor(size_t step, DynamicExpression ex) const = 0;
|
|
|
|
virtual DynamicExpression iforh(size_t step, DynamicExpression ex) const = 0;
|
|
|
|
/*
|
2019-09-13 15:08:33 +02:00
|
|
|
std::shared_ptr<IndexWrapperBase> duplicateI() const
|
|
|
|
{ return std::dynamic_pointer_cast<IndexWrapperBase>( this->duplicate() ); }
|
2020-07-08 17:55:51 +02:00
|
|
|
*/
|
2018-10-22 14:27:55 +02:00
|
|
|
};
|
|
|
|
|
2020-07-08 17:55:51 +02:00
|
|
|
typedef IndexWrapperBase IndexW;
|
2018-10-22 14:27:55 +02:00
|
|
|
|
2020-07-08 17:55:51 +02:00
|
|
|
template <class Index>
|
|
|
|
class IndexWrapper : public IndexWrapperBase
|
2018-10-22 14:27:55 +02:00
|
|
|
{
|
2018-10-30 15:06:29 +01:00
|
|
|
public:
|
2020-07-08 17:55:51 +02:00
|
|
|
typedef IndexWrapperBase IWB;
|
2018-11-01 22:11:08 +01:00
|
|
|
typedef typename Index::MetaType MetaType;
|
|
|
|
|
|
|
|
static constexpr IndexType sType() { return IndexType::SINGLE; }
|
|
|
|
|
2018-10-23 20:02:01 +02:00
|
|
|
protected:
|
2018-10-22 14:27:55 +02:00
|
|
|
IndexWrapper() = default;
|
2018-10-23 20:02:01 +02:00
|
|
|
|
|
|
|
private:
|
2018-10-22 14:27:55 +02:00
|
|
|
std::shared_ptr<Index> mI;
|
|
|
|
public:
|
|
|
|
|
|
|
|
IndexWrapper(const IndexWrapper& in) = default;
|
|
|
|
IndexWrapper(IndexWrapper&& in) = default;
|
|
|
|
IndexWrapper& operator=(const IndexWrapper& in) = default;
|
|
|
|
IndexWrapper& operator=(IndexWrapper&& in) = default;
|
|
|
|
|
2020-07-08 17:55:51 +02:00
|
|
|
IndexWrapper(const std::shared_ptr<Index>& i) : mI(i) {}
|
2018-10-22 14:27:55 +02:00
|
|
|
|
|
|
|
virtual IndexType type() const final { return mI->type(); }
|
|
|
|
|
2019-03-14 19:10:06 +01:00
|
|
|
virtual IndexWrapper& operator=(size_t pos) override final { (*mI) = pos; return *this; }
|
|
|
|
virtual IndexWrapper& operator++() override final { ++(*mI); return *this; }
|
|
|
|
virtual IndexWrapper& operator--() override final { --(*mI); return *this; }
|
2018-10-22 14:27:55 +02:00
|
|
|
|
2019-03-14 19:10:06 +01:00
|
|
|
virtual size_t pos() const override final { return mI->pos(); }
|
|
|
|
virtual size_t max() const override final { return mI->max(); }
|
2018-10-29 14:19:42 +01:00
|
|
|
|
2019-03-14 19:10:06 +01:00
|
|
|
virtual int pp(std::intptr_t idxPtrNum) override final { return mI->pp(idxPtrNum); }
|
|
|
|
virtual int mm(std::intptr_t idxPtrNum) override final { return mI->mm(idxPtrNum); }
|
2018-10-22 14:27:55 +02:00
|
|
|
|
2019-03-14 19:10:06 +01:00
|
|
|
virtual std::string stringMeta() const override final { return mI->stringMeta(); }
|
2018-11-01 22:11:08 +01:00
|
|
|
//virtual DynamicMetaT meta() const final { return DynamicMetaT(mI->meta()); }
|
|
|
|
//virtual const DynamicMetaT* metaPtr() const final { return nullptr; }
|
2018-10-30 15:06:29 +01:00
|
|
|
IndexWrapper& at(const typename Index::MetaType& metaPos) { mI->at(metaPos); return *this; }
|
2018-10-27 14:58:34 +02:00
|
|
|
size_t posAt(const typename Index::MetaType& metaPos) const { return mI->posAt(metaPos); }
|
2018-10-22 14:27:55 +02:00
|
|
|
|
|
|
|
//virtual bool isMeta(const U& metaPos) const final { return mI->isMeta(); }
|
|
|
|
|
2019-03-14 19:10:06 +01:00
|
|
|
virtual size_t dim() const override final { return mI->dim(); }
|
|
|
|
virtual bool last() const override final { return mI->last(); }
|
|
|
|
virtual bool first() const override final { return mI->first(); }
|
2018-10-22 14:27:55 +02:00
|
|
|
|
2019-03-14 19:10:06 +01:00
|
|
|
virtual std::shared_ptr<RangeBase> range() const override final { return mI->range(); }
|
2018-10-22 14:27:55 +02:00
|
|
|
|
2019-03-14 19:10:06 +01:00
|
|
|
virtual size_t getStepSize(size_t n) const override final { return mI->getStepSize(n); }
|
|
|
|
virtual size_t getStepSizeComp(std::intptr_t j) const override final;
|
2018-10-29 14:19:42 +01:00
|
|
|
|
2019-03-14 19:10:06 +01:00
|
|
|
virtual std::intptr_t get() const override final { return reinterpret_cast<std::intptr_t>(mI.get()); }
|
|
|
|
virtual std::intptr_t ptrNum() const override final { return mI->ptrNum(); }
|
2019-09-13 15:08:33 +02:00
|
|
|
|
2020-07-08 17:55:51 +02:00
|
|
|
virtual DynamicExpression ifor(size_t step, DynamicExpression ex) const override final
|
|
|
|
{ return mI->ifor(step, ex); }
|
|
|
|
virtual DynamicExpression iforh(size_t step, DynamicExpression ex) const override final
|
|
|
|
{ return mI->iforh(step, ex); }
|
|
|
|
|
|
|
|
virtual std::shared_ptr<IndexWrapperBase> duplicate() const override final
|
2019-09-13 15:08:33 +02:00
|
|
|
{ return std::make_shared<IndexWrapper>( std::make_shared<Index>( *mI ) ); }
|
2018-10-27 14:58:34 +02:00
|
|
|
|
2018-10-23 20:02:01 +02:00
|
|
|
};
|
|
|
|
|
2018-10-30 15:06:29 +01:00
|
|
|
//typedef SingleRange<size_t,SpaceType::DYN> DynamicRange;
|
|
|
|
|
2020-07-08 17:55:51 +02:00
|
|
|
class DynamicIndex : public IndexInterface<DynamicIndex,vector<char>>
|
2018-10-22 14:27:55 +02:00
|
|
|
{
|
|
|
|
private:
|
2020-07-08 17:55:51 +02:00
|
|
|
typedef vector<std::pair<std::shared_ptr<IndexW>,size_t>> IVecT;
|
2020-08-26 23:24:10 +02:00
|
|
|
typedef std::map<std::string,std::shared_ptr<IndexW>> IMapT;
|
|
|
|
|
|
|
|
static IMapT sIMap;
|
|
|
|
|
2018-10-29 14:19:42 +01:00
|
|
|
IVecT mIVec;
|
2019-03-19 20:58:59 +01:00
|
|
|
bool mIvecInit = false;
|
|
|
|
|
2018-10-22 14:27:55 +02:00
|
|
|
public:
|
2020-07-08 17:55:51 +02:00
|
|
|
typedef IndexInterface<DynamicIndex,vector<char>> IB;
|
2019-03-14 19:10:06 +01:00
|
|
|
typedef vector<char> MetaType;
|
2020-07-08 17:55:51 +02:00
|
|
|
typedef DynamicRange RangeType;
|
2018-10-22 14:27:55 +02:00
|
|
|
typedef DynamicIndex IType;
|
|
|
|
|
2018-10-30 15:06:29 +01:00
|
|
|
DynamicIndex(const std::shared_ptr<RangeType>& range);
|
2018-10-22 14:27:55 +02:00
|
|
|
|
2020-08-26 23:24:10 +02:00
|
|
|
static void clearIMap() { sIMap.clear(); }
|
2018-10-22 14:27:55 +02:00
|
|
|
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--();
|
|
|
|
|
2018-10-29 14:19:42 +01:00
|
|
|
DynamicIndex& operator()(const IVecT& ivec);
|
2020-07-08 17:55:51 +02:00
|
|
|
DynamicIndex& operator()(const vector<std::shared_ptr<IndexW>>& ivec);
|
2020-08-26 23:24:10 +02:00
|
|
|
DynamicIndex& operator()(const vector<std::string>& inames);
|
2018-12-02 22:08:51 +01:00
|
|
|
|
2018-11-01 22:11:08 +01:00
|
|
|
template <class... Indices>
|
|
|
|
DynamicIndex& operator()(const std::shared_ptr<Indices>&... is);
|
2018-12-02 22:08:51 +01:00
|
|
|
|
2020-07-08 17:55:51 +02:00
|
|
|
DynamicIndex& sync();
|
2018-12-02 22:08:51 +01:00
|
|
|
|
2018-10-22 14:27:55 +02:00
|
|
|
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;
|
|
|
|
|
2018-10-29 14:19:42 +01:00
|
|
|
size_t dim() const;
|
|
|
|
bool last() const;
|
|
|
|
bool first() const;
|
|
|
|
|
2020-07-08 17:55:51 +02:00
|
|
|
const IndexW& get(size_t n) const;
|
2018-10-22 14:27:55 +02:00
|
|
|
|
|
|
|
std::shared_ptr<RangeType> range();
|
|
|
|
|
|
|
|
template <size_t N>
|
|
|
|
void getPtr();
|
|
|
|
|
2018-10-29 14:19:42 +01:00
|
|
|
size_t getStepSize(size_t n) const;
|
|
|
|
|
2018-10-22 14:27:55 +02:00
|
|
|
std::string id() const;
|
|
|
|
void print(size_t offset);
|
|
|
|
|
|
|
|
template <class Expr>
|
2020-07-09 17:37:28 +02:00
|
|
|
DynamicExpression ifor(size_t step, Expr ex) const;
|
2018-10-22 14:27:55 +02:00
|
|
|
|
|
|
|
template <class Expr>
|
2020-07-09 17:37:28 +02:00
|
|
|
DynamicExpression iforh(size_t step, Expr ex) const;
|
2018-10-22 14:27:55 +02:00
|
|
|
|
2019-01-15 17:41:43 +01:00
|
|
|
template <class Expr>
|
2020-07-09 17:37:28 +02:00
|
|
|
DynamicExpression pifor(size_t step, Expr ex) const;
|
2019-01-15 17:41:43 +01:00
|
|
|
|
2018-10-22 14:27:55 +02:00
|
|
|
};
|
|
|
|
|
2018-10-27 14:58:34 +02:00
|
|
|
|
2018-10-22 14:27:55 +02:00
|
|
|
// NOT THREAD SAVE!!
|
|
|
|
class DynamicRangeFactory : public RangeFactoryBase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2020-07-08 17:55:51 +02:00
|
|
|
typedef DynamicRange oType;
|
2018-10-22 14:27:55 +02:00
|
|
|
|
|
|
|
DynamicRangeFactory();
|
|
|
|
|
|
|
|
template <class... RangeTypes>
|
|
|
|
DynamicRangeFactory(const std::tuple<std::shared_ptr<RangeTypes>...>& origs);
|
|
|
|
|
|
|
|
template <class... RangeTypes>
|
|
|
|
DynamicRangeFactory(std::shared_ptr<RangeTypes>... origs);
|
|
|
|
|
2019-02-13 21:59:13 +01:00
|
|
|
DynamicRangeFactory(const vector<std::shared_ptr<RangeBase>>& origs);
|
2018-11-02 18:58:58 +01:00
|
|
|
|
2018-10-22 14:27:55 +02:00
|
|
|
template <class Range>
|
|
|
|
void append(std::shared_ptr<Range> r);
|
|
|
|
|
|
|
|
std::shared_ptr<RangeBase> create();
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
2019-02-13 21:59:13 +01:00
|
|
|
std::shared_ptr<RangeBase> checkIfCreated(const vector<std::shared_ptr<RangeBase> >& pvec);
|
2018-10-22 14:27:55 +02:00
|
|
|
|
2019-02-13 21:59:13 +01:00
|
|
|
static std::map<std::shared_ptr<RangeBase>,vector<std::intptr_t> > mAleadyCreated;
|
2018-10-22 14:27:55 +02:00
|
|
|
|
|
|
|
bool mProductCreated = false;
|
|
|
|
};
|
2018-10-27 14:58:34 +02:00
|
|
|
|
2020-07-08 17:55:51 +02:00
|
|
|
class DynamicRange : public RangeInterface<DynamicIndex>
|
2018-10-22 14:27:55 +02:00
|
|
|
{
|
|
|
|
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;
|
2020-07-08 17:55:51 +02:00
|
|
|
typedef DynamicIndex IndexType;
|
2018-10-22 14:27:55 +02:00
|
|
|
typedef DynamicRange RangeType;
|
2019-03-14 19:10:06 +01:00
|
|
|
typedef vector<char> MetaType;
|
2020-07-08 17:55:51 +02:00
|
|
|
typedef DynamicRangeFactory FType;
|
2019-03-14 19:10:06 +01:00
|
|
|
|
2018-10-22 14:27:55 +02:00
|
|
|
private:
|
2018-10-30 15:06:29 +01:00
|
|
|
DynamicRange() = default;
|
|
|
|
DynamicRange(const DynamicRange& in) = default;
|
2018-10-22 14:27:55 +02:00
|
|
|
|
|
|
|
template <class... RangeTypes>
|
2018-10-30 15:06:29 +01:00
|
|
|
DynamicRange(const std::tuple<std::shared_ptr<RangeTypes>...>& origs);
|
2018-10-22 14:27:55 +02:00
|
|
|
|
|
|
|
template <class... RangeTypes>
|
2018-10-30 15:06:29 +01:00
|
|
|
DynamicRange(std::shared_ptr<RangeTypes>... origs);
|
2018-10-22 14:27:55 +02:00
|
|
|
|
2019-02-13 21:59:13 +01:00
|
|
|
DynamicRange(const vector<std::shared_ptr<RangeBase>>& origs);
|
2018-11-02 18:58:58 +01:00
|
|
|
|
2018-10-22 14:27:55 +02:00
|
|
|
size_t mSize = 1;
|
|
|
|
bool mEmpty = true;
|
|
|
|
|
2019-02-13 21:59:13 +01:00
|
|
|
vector<std::shared_ptr<RangeBase> > mOrig;
|
2018-10-22 14:27:55 +02:00
|
|
|
|
|
|
|
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;
|
2018-11-07 10:58:07 +01:00
|
|
|
virtual DataHeader dataHeader() const final;
|
|
|
|
|
2019-03-19 20:58:59 +01:00
|
|
|
virtual vector<size_t> typeNum() const final;
|
2019-03-14 14:20:38 +01:00
|
|
|
virtual size_t cmeta(char* target, size_t pos) const final;
|
2019-03-19 20:58:59 +01:00
|
|
|
virtual size_t cmetaSize() const final;
|
2018-10-22 14:27:55 +02:00
|
|
|
virtual std::string stringMeta(size_t pos) const final;
|
2019-02-13 21:59:13 +01:00
|
|
|
virtual vector<char> data() const final;
|
2018-10-22 14:27:55 +02:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2019-02-13 21:59:13 +01:00
|
|
|
const vector<std::shared_ptr<RangeBase> >& orig() const;
|
2018-11-02 18:58:58 +01:00
|
|
|
|
2018-10-22 14:27:55 +02:00
|
|
|
void sreplace(const std::shared_ptr<RangeBase> in, size_t num);
|
|
|
|
|
|
|
|
bool isEmpty() const;
|
|
|
|
|
2020-07-08 17:55:51 +02:00
|
|
|
friend DynamicRangeFactory;
|
2018-10-22 14:27:55 +02:00
|
|
|
|
2020-07-08 17:55:51 +02:00
|
|
|
static DynamicRangeFactory factory()
|
|
|
|
{ return DynamicRangeFactory(); }
|
2018-10-22 14:27:55 +02:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace MultiArrayTools
|
|
|
|
|
|
|
|
|
|
|
|
namespace MultiArrayHelper
|
|
|
|
{
|
|
|
|
using namespace MultiArrayTools;
|
|
|
|
|
2020-07-08 17:55:51 +02:00
|
|
|
inline void resolveSetRange(std::shared_ptr<DynamicRange>& rp,
|
2019-02-13 21:59:13 +01:00
|
|
|
const vector<std::shared_ptr<RangeBase> >& orig,
|
2018-10-30 15:06:29 +01:00
|
|
|
size_t origpos, size_t size)
|
2018-10-22 14:27:55 +02:00
|
|
|
{
|
2020-07-08 17:55:51 +02:00
|
|
|
DynamicRangeFactory arf;
|
2018-10-22 14:27:55 +02:00
|
|
|
for(size_t op = origpos; op != origpos + size; ++op){
|
|
|
|
//VCHECK(op);
|
|
|
|
arf.append(orig[op]);
|
|
|
|
}
|
2020-07-08 17:55:51 +02:00
|
|
|
rp = std::dynamic_pointer_cast<DynamicRange>( arf.create() );
|
2018-10-22 14:27:55 +02:00
|
|
|
}
|
|
|
|
|
2019-02-13 21:59:13 +01:00
|
|
|
inline void setRangeToVec(vector<std::shared_ptr<RangeBase> >& v,
|
2020-07-08 17:55:51 +02:00
|
|
|
std::shared_ptr<DynamicRange> r)
|
2018-10-22 14:27:55 +02:00
|
|
|
{
|
|
|
|
if(not r->isEmpty()){
|
2018-10-27 14:58:34 +02:00
|
|
|
for(size_t i = r->dim(); i != 0; --i){
|
2018-10-22 14:27:55 +02:00
|
|
|
v.insert(v.begin(), r->sub(i-1));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-08 17:55:51 +02:00
|
|
|
inline size_t getStepSize(const DynamicIndex& ii, std::intptr_t j)
|
2018-10-29 14:19:42 +01:00
|
|
|
{
|
|
|
|
size_t ss = 0;
|
|
|
|
size_t sx = 1;
|
2018-11-01 22:11:08 +01:00
|
|
|
for(size_t k = ii.dim(); k != 0; --k){
|
|
|
|
const size_t i = k-1;
|
2018-10-29 14:19:42 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2018-10-22 14:27:55 +02:00
|
|
|
}
|
|
|
|
|
2018-11-01 22:11:08 +01:00
|
|
|
//#include "dynamic_range.cc.h"
|
2018-10-22 14:27:55 +02:00
|
|
|
|
|
|
|
#endif
|