start removing expression collection stuff -> so far compile errors + seg fault...
This commit is contained in:
parent
9ab27d1e5a
commit
f7549a230b
11 changed files with 345 additions and 324 deletions
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
namespace MultiArrayTools
|
namespace MultiArrayTools
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
template <class Expr>
|
template <class Expr>
|
||||||
inline ExpressionHolder<Expr> Expressions1::ifor(size_t step,
|
inline ExpressionHolder<Expr> Expressions1::ifor(size_t step,
|
||||||
ExpressionHolder<Expr> ex) const
|
ExpressionHolder<Expr> ex) const
|
||||||
|
@ -35,5 +35,5 @@ namespace MultiArrayTools
|
||||||
{
|
{
|
||||||
return std::make_shared<EC>(i);
|
return std::make_shared<EC>(i);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
} // namespace MultiArrayTools
|
} // namespace MultiArrayTools
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
namespace MultiArrayTools
|
namespace MultiArrayTools
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
//class Expressions1;
|
//class Expressions1;
|
||||||
|
|
||||||
template <class EC>
|
template <class EC>
|
||||||
|
@ -55,7 +55,7 @@ namespace MultiArrayTools
|
||||||
|
|
||||||
template <class EC, template <class> class OpF>
|
template <class EC, template <class> class OpF>
|
||||||
using AEX_B_CC = AEX<EC,oo<EC,DDMMA<EC>>,OpF,DDMA<EC>,DDMA<EC>>;
|
using AEX_B_CC = AEX<EC,oo<EC,DDMMA<EC>>,OpF,DDMA<EC>,DDMA<EC>>;
|
||||||
|
*/
|
||||||
/*
|
/*
|
||||||
template <class EC>
|
template <class EC>
|
||||||
class ECInterface
|
class ECInterface
|
||||||
|
@ -80,6 +80,7 @@ namespace MultiArrayTools
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
*/
|
*/
|
||||||
|
/*
|
||||||
template <class EC, class Index>
|
template <class EC, class Index>
|
||||||
std::shared_ptr<EC> makeec(const std::shared_ptr<Index>& i);
|
std::shared_ptr<EC> makeec(const std::shared_ptr<Index>& i);
|
||||||
|
|
||||||
|
@ -182,8 +183,7 @@ namespace MultiArrayTools
|
||||||
|
|
||||||
E1(const std::shared_ptr<Index>& i) : mI(i) {}
|
E1(const std::shared_ptr<Index>& i) : mI(i) {}
|
||||||
};
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
} // namespace MultiArrayTools
|
} // namespace MultiArrayTools
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -169,36 +169,36 @@ namespace MultiArrayTools
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <class EC, class MArray>
|
template <class MArray>
|
||||||
auto dynamic(const MArray& ma, bool slice)
|
auto dynamic(const MArray& ma, bool slice)
|
||||||
-> std::shared_ptr<MultiArrayBase<typename MArray::value_type,DynamicRange<EC>>>
|
-> std::shared_ptr<MultiArrayBase<typename MArray::value_type,DynamicRange>>
|
||||||
{
|
{
|
||||||
DynamicRangeFactory<EC> drf(ma.range()->space());
|
DynamicRangeFactory drf(ma.range()->space());
|
||||||
if(slice){
|
if(slice){
|
||||||
return std::make_shared<ConstSlice<typename MArray::value_type,DynamicRange<EC>>>
|
return std::make_shared<ConstSlice<typename MArray::value_type,DynamicRange>>
|
||||||
( std::dynamic_pointer_cast<DynamicRange<EC>>( drf.create() ),
|
( std::dynamic_pointer_cast<DynamicRange>( drf.create() ),
|
||||||
ma.data() );
|
ma.data() );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return std::make_shared<MultiArray<typename MArray::value_type,DynamicRange<EC>>>
|
return std::make_shared<MultiArray<typename MArray::value_type,DynamicRange>>
|
||||||
( std::dynamic_pointer_cast<DynamicRange<EC>>( drf.create() ),
|
( std::dynamic_pointer_cast<DynamicRange>( drf.create() ),
|
||||||
ma.vdata() );
|
ma.vdata() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class EC, class MArray>
|
template <class MArray>
|
||||||
auto mdynamic(MArray& ma, bool slice)
|
auto mdynamic(MArray& ma, bool slice)
|
||||||
-> std::shared_ptr<MutableMultiArrayBase<typename MArray::value_type,DynamicRange<EC>>>
|
-> std::shared_ptr<MutableMultiArrayBase<typename MArray::value_type,DynamicRange>>
|
||||||
{
|
{
|
||||||
DynamicRangeFactory<EC> drf(ma.range()->space());
|
DynamicRangeFactory drf(ma.range()->space());
|
||||||
if(slice){
|
if(slice){
|
||||||
return std::make_shared<Slice<typename MArray::value_type,DynamicRange<EC>>>
|
return std::make_shared<Slice<typename MArray::value_type,DynamicRange>>
|
||||||
( std::dynamic_pointer_cast<DynamicRange<EC>>( drf.create() ),
|
( std::dynamic_pointer_cast<DynamicRange>( drf.create() ),
|
||||||
ma.data() );
|
ma.data() );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return std::make_shared<MultiArray<typename MArray::value_type,DynamicRange<EC>>>
|
return std::make_shared<MultiArray<typename MArray::value_type,DynamicRange>>
|
||||||
( std::dynamic_pointer_cast<DynamicRange<EC>>( drf.create() ),
|
( std::dynamic_pointer_cast<DynamicRange>( drf.create() ),
|
||||||
ma.vdata() );
|
ma.vdata() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -227,34 +227,34 @@ namespace MultiArrayTools
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, class EC, class Range1, class... RangeTypes>
|
template <typename T, class Range1, class... RangeTypes>
|
||||||
auto anonToDynView(const MultiArrayBase<T,Range1,RangeTypes...,AnonymousRange>& ma)
|
auto anonToDynView(const MultiArrayBase<T,Range1,RangeTypes...,AnonymousRange>& ma)
|
||||||
-> ConstSlice<T,Range1,RangeTypes...,DynamicRange<EC>>
|
-> ConstSlice<T,Range1,RangeTypes...,DynamicRange>
|
||||||
{
|
{
|
||||||
constexpr size_t LAST = sizeof...(RangeTypes)+1;
|
constexpr size_t LAST = sizeof...(RangeTypes)+1;
|
||||||
DynamicRangeFactory<EC> drf(rptr<LAST>(ma)->orig());
|
DynamicRangeFactory drf(rptr<LAST>(ma)->orig());
|
||||||
std::tuple<std::shared_ptr<Range1>,std::shared_ptr<RangeTypes>...,
|
std::tuple<std::shared_ptr<Range1>,std::shared_ptr<RangeTypes>...,
|
||||||
std::shared_ptr<DynamicRange<EC>>> mNSpace;
|
std::shared_ptr<DynamicRange>> mNSpace;
|
||||||
CopyRanges<LAST-1>::exec(ma.range()->space(),mNSpace);
|
CopyRanges<LAST-1>::exec(ma.range()->space(),mNSpace);
|
||||||
std::get<LAST>(mNSpace) = createExplicit( drf );
|
std::get<LAST>(mNSpace) = createExplicit( drf );
|
||||||
return ConstSlice<T,Range1,RangeTypes...,DynamicRange<EC>>(mNSpace, ma.data());
|
return ConstSlice<T,Range1,RangeTypes...,DynamicRange>(mNSpace, ma.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, class EC, class Range1, class... RangeTypes>
|
template <typename T, class Range1, class... RangeTypes>
|
||||||
auto anonToDynView(MutableMultiArrayBase<T,Range1,RangeTypes...,AnonymousRange>& ma)
|
auto anonToDynView(MutableMultiArrayBase<T,Range1,RangeTypes...,AnonymousRange>& ma)
|
||||||
-> Slice<T,Range1,RangeTypes...,DynamicRange<EC>>
|
-> Slice<T,Range1,RangeTypes...,DynamicRange>
|
||||||
{
|
{
|
||||||
constexpr size_t LAST = sizeof...(RangeTypes)+1;
|
constexpr size_t LAST = sizeof...(RangeTypes)+1;
|
||||||
DynamicRangeFactory<EC> drf(rptr<LAST>(ma)->orig());
|
DynamicRangeFactory drf(rptr<LAST>(ma)->orig());
|
||||||
std::tuple<std::shared_ptr<Range1>,std::shared_ptr<RangeTypes>...,
|
std::tuple<std::shared_ptr<Range1>,std::shared_ptr<RangeTypes>...,
|
||||||
std::shared_ptr<DynamicRange<EC>>> mNSpace;
|
std::shared_ptr<DynamicRange>> mNSpace;
|
||||||
CopyRanges<LAST-1>::exec(ma.range()->space(),mNSpace);
|
CopyRanges<LAST-1>::exec(ma.range()->space(),mNSpace);
|
||||||
std::get<LAST>(mNSpace) = createExplicit( drf );
|
std::get<LAST>(mNSpace) = createExplicit( drf );
|
||||||
return Slice<T,Range1,RangeTypes...,DynamicRange<EC>>(mNSpace, ma.data());
|
return Slice<T,Range1,RangeTypes...,DynamicRange>(mNSpace, ma.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, class EC, class Range1, class... RangeTypes>
|
template <typename T, class Range1, class... RangeTypes>
|
||||||
auto dynToAnonMove(MultiArray<T,Range1,RangeTypes...,DynamicRange<EC>>&& ma)
|
auto dynToAnonMove(MultiArray<T,Range1,RangeTypes...,DynamicRange>&& ma)
|
||||||
-> MultiArray<T,Range1,RangeTypes...,AnonymousRange>
|
-> MultiArray<T,Range1,RangeTypes...,AnonymousRange>
|
||||||
{
|
{
|
||||||
constexpr size_t LAST = sizeof...(RangeTypes)+1;
|
constexpr size_t LAST = sizeof...(RangeTypes)+1;
|
||||||
|
@ -266,26 +266,26 @@ namespace MultiArrayTools
|
||||||
return ma.format(mNSpace);
|
return ma.format(mNSpace);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, class EC>
|
template <typename T>
|
||||||
auto anonToDynView(const MultiArrayBase<T,AnonymousRange>& ma)
|
auto anonToDynView(const MultiArrayBase<T,AnonymousRange>& ma)
|
||||||
-> ConstSlice<T,DynamicRange<EC>>
|
-> ConstSlice<T,DynamicRange>
|
||||||
{
|
{
|
||||||
DynamicRangeFactory<EC> drf(rptr<0>(ma)->orig());
|
DynamicRangeFactory drf(rptr<0>(ma)->orig());
|
||||||
auto mNSpace = std::make_tuple( createExplicit( drf ) );
|
auto mNSpace = std::make_tuple( createExplicit( drf ) );
|
||||||
return ConstSlice<T,DynamicRange<EC>>(mNSpace, ma.data());
|
return ConstSlice<T,DynamicRange>(mNSpace, ma.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, class EC>
|
template <typename T>
|
||||||
auto anonToDynView(MutableMultiArrayBase<T,AnonymousRange>& ma)
|
auto anonToDynView(MutableMultiArrayBase<T,AnonymousRange>& ma)
|
||||||
-> Slice<T,DynamicRange<EC>>
|
-> Slice<T,DynamicRange>
|
||||||
{
|
{
|
||||||
DynamicRangeFactory<EC> drf(rptr<0>(ma)->orig());
|
DynamicRangeFactory drf(rptr<0>(ma)->orig());
|
||||||
auto mNSpace = std::make_tuple( createExplicit( drf ) );
|
auto mNSpace = std::make_tuple( createExplicit( drf ) );
|
||||||
return Slice<T,DynamicRange<EC>>(mNSpace, ma.data());
|
return Slice<T,DynamicRange>(mNSpace, ma.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, class EC>
|
template <typename T>
|
||||||
auto dynToAnonMove(MultiArray<T,DynamicRange<EC>>&& ma)
|
auto dynToAnonMove(MultiArray<T,DynamicRange>&& ma)
|
||||||
-> MultiArray<T,AnonymousRange>
|
-> MultiArray<T,AnonymousRange>
|
||||||
{
|
{
|
||||||
AnonymousRangeFactory arf(rptr<0>(ma)->orig());
|
AnonymousRangeFactory arf(rptr<0>(ma)->orig());
|
||||||
|
|
|
@ -98,36 +98,36 @@ namespace MultiArrayTools
|
||||||
return i->template getPtr<I>();
|
return i->template getPtr<I>();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class EC, class MArray>
|
template <class MArray>
|
||||||
auto dynamic(const MArray& ma, bool slice = false)
|
auto dynamic(const MArray& ma, bool slice = false)
|
||||||
-> std::shared_ptr<MultiArrayBase<typename MArray::value_type,DynamicRange<EC>>>;
|
-> std::shared_ptr<MultiArrayBase<typename MArray::value_type,DynamicRange>>;
|
||||||
|
|
||||||
template <class EC, class MArray>
|
template <class MArray>
|
||||||
auto mdynamic(MArray& ma, bool slice)
|
auto mdynamic(MArray& ma, bool slice)
|
||||||
-> std::shared_ptr<MutableMultiArrayBase<typename MArray::value_type,DynamicRange<EC>>>;
|
-> std::shared_ptr<MutableMultiArrayBase<typename MArray::value_type,DynamicRange>>;
|
||||||
|
|
||||||
template <typename T, class EC, class Range1, class... RangeTypes>
|
template <typename T, class Range1, class... RangeTypes>
|
||||||
auto anonToDynView(const MultiArrayBase<T,Range1,RangeTypes...,AnonymousRange>& ma)
|
auto anonToDynView(const MultiArrayBase<T,Range1,RangeTypes...,AnonymousRange>& ma)
|
||||||
-> ConstSlice<T,Range1,RangeTypes...,DynamicRange<EC>>;
|
-> ConstSlice<T,Range1,RangeTypes...,DynamicRange>;
|
||||||
|
|
||||||
template <typename T, class EC, class Range1, class... RangeTypes>
|
template <typename T, class Range1, class... RangeTypes>
|
||||||
auto anonToDynView(MutableMultiArrayBase<T,Range1,RangeTypes...,AnonymousRange>& ma)
|
auto anonToDynView(MutableMultiArrayBase<T,Range1,RangeTypes...,AnonymousRange>& ma)
|
||||||
-> Slice<T,Range1,RangeTypes...,DynamicRange<EC>>;
|
-> Slice<T,Range1,RangeTypes...,DynamicRange>;
|
||||||
|
|
||||||
template <typename T, class EC, class Range1, class... RangeTypes>
|
template <typename T, class Range1, class... RangeTypes>
|
||||||
auto dynToAnonMove(MultiArray<T,Range1,RangeTypes...,DynamicRange<EC>>&& ma)
|
auto dynToAnonMove(MultiArray<T,Range1,RangeTypes...,DynamicRange>&& ma)
|
||||||
-> MultiArray<T,Range1,RangeTypes...,AnonymousRange>;
|
-> MultiArray<T,Range1,RangeTypes...,AnonymousRange>;
|
||||||
|
|
||||||
template <typename T, class EC>
|
template <typename T>
|
||||||
auto anonToDynView(const MultiArrayBase<T,AnonymousRange>& ma)
|
auto anonToDynView(const MultiArrayBase<T,AnonymousRange>& ma)
|
||||||
-> ConstSlice<T,DynamicRange<EC>>;
|
-> ConstSlice<T,DynamicRange>;
|
||||||
|
|
||||||
template <typename T, class EC>
|
template <typename T>
|
||||||
auto anonToDynView(MutableMultiArrayBase<T,AnonymousRange>& ma)
|
auto anonToDynView(MutableMultiArrayBase<T,AnonymousRange>& ma)
|
||||||
-> Slice<T,DynamicRange<EC>>;
|
-> Slice<T,DynamicRange>;
|
||||||
|
|
||||||
template <typename T, class EC>
|
template <typename T>
|
||||||
auto dynToAnonMove(MultiArray<T,DynamicRange<EC>>&& ma)
|
auto dynToAnonMove(MultiArray<T,DynamicRange>&& ma)
|
||||||
-> MultiArray<T,AnonymousRange>;
|
-> MultiArray<T,AnonymousRange>;
|
||||||
|
|
||||||
template <class Range>
|
template <class Range>
|
||||||
|
|
|
@ -192,6 +192,13 @@ namespace MultiArrayTools
|
||||||
//mDataPtr[start] += mSec.template get<ExtType>(last);
|
//mDataPtr[start] += mSec.template get<ExtType>(last);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T, class Target, class OpClass>
|
||||||
|
inline void AddExpr<T,Target,OpClass>::operator()(size_t start)
|
||||||
|
{
|
||||||
|
ExtType last;
|
||||||
|
mDataPtr[last.val()] += mSec.get(last.next());
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T, class Target, class OpClass>
|
template <typename T, class Target, class OpClass>
|
||||||
typename AddExpr<T,Target,OpClass>::ExtType AddExpr<T,Target,OpClass>::rootSteps(std::intptr_t iPtrNum) const
|
typename AddExpr<T,Target,OpClass>::ExtType AddExpr<T,Target,OpClass>::rootSteps(std::intptr_t iPtrNum) const
|
||||||
{
|
{
|
||||||
|
@ -199,6 +206,25 @@ namespace MultiArrayTools
|
||||||
//return mSec.rootSteps(iPtrNum);
|
//return mSec.rootSteps(iPtrNum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T, class Target, class OpClass>
|
||||||
|
inline void AddExpr<T,Target,OpClass>::operator()(size_t mlast, DExt last)
|
||||||
|
{
|
||||||
|
(*this)(mlast, std::dynamic_pointer_cast<ExtT<ExtType>>(last)->ext());
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T, class Target, class OpClass>
|
||||||
|
inline DExt AddExpr<T,Target,OpClass>::dRootSteps(std::intptr_t iPtrNum) const
|
||||||
|
{
|
||||||
|
return std::make_shared<ExtT<ExtType>>(rootSteps(iPtrNum));
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T, class Target, class OpClass>
|
||||||
|
inline DExt AddExpr<T,Target,OpClass>::dExtension() const
|
||||||
|
{
|
||||||
|
CHECK;
|
||||||
|
return nullptr; //???!!!
|
||||||
|
}
|
||||||
|
|
||||||
/****************************
|
/****************************
|
||||||
* ConstOperationRoot *
|
* ConstOperationRoot *
|
||||||
****************************/
|
****************************/
|
||||||
|
|
|
@ -139,7 +139,7 @@ namespace MultiArrayTools
|
||||||
|
|
||||||
//template <typename T, class OpClass>
|
//template <typename T, class OpClass>
|
||||||
template <typename T, class Target, class OpClass>
|
template <typename T, class Target, class OpClass>
|
||||||
class AddExpr
|
class AddExpr : public ExpressionBase
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
AddExpr() = default;
|
AddExpr() = default;
|
||||||
|
@ -165,6 +165,11 @@ namespace MultiArrayTools
|
||||||
inline void operator()(size_t start = 0);
|
inline void operator()(size_t start = 0);
|
||||||
inline void operator()(size_t start, ExtType last);
|
inline void operator()(size_t start, ExtType last);
|
||||||
auto rootSteps(std::intptr_t iPtrNum = 0) const -> ExtType;
|
auto rootSteps(std::intptr_t iPtrNum = 0) const -> ExtType;
|
||||||
|
|
||||||
|
inline void operator()(size_t mlast, DExt last) override final;
|
||||||
|
|
||||||
|
inline DExt dRootSteps(std::intptr_t iPtrNum = 0) const override final;
|
||||||
|
inline DExt dExtension() const override final;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T, class... Ranges>
|
template <typename T, class... Ranges>
|
||||||
|
|
|
@ -11,44 +11,8 @@ namespace MultiArrayTools
|
||||||
using namespace MultiArrayHelper;
|
using namespace MultiArrayHelper;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*************************
|
template <class Index>
|
||||||
* IndexWrapperBase *
|
size_t IndexWrapper<Index>::getStepSizeComp(std::intptr_t j) const
|
||||||
*************************/
|
|
||||||
|
|
||||||
template <class ExpressionCollection>
|
|
||||||
template <class Expr>
|
|
||||||
ExpressionHolder<Expr>
|
|
||||||
IndexWrapperBase<ExpressionCollection>::ifor(size_t step, ExpressionHolder<Expr> ex) const
|
|
||||||
{
|
|
||||||
return mEc->ifor(step, ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class ExpressionCollection>
|
|
||||||
template <class Expr>
|
|
||||||
ExpressionHolder<Expr>
|
|
||||||
IndexWrapperBase<ExpressionCollection>::iforh(size_t step, ExpressionHolder<Expr> ex) const
|
|
||||||
{
|
|
||||||
return mEc->iforh(step, ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class ExpressionCollection>
|
|
||||||
template <class Expr>
|
|
||||||
ExpressionHolder<Expr>
|
|
||||||
IndexWrapperBase<ExpressionCollection>::ifori(size_t step, Expr ex) const
|
|
||||||
{
|
|
||||||
return mEc->ifori(step, ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class ExpressionCollection>
|
|
||||||
template <class Expr>
|
|
||||||
ExpressionHolder<Expr>
|
|
||||||
IndexWrapperBase<ExpressionCollection>::iforhi(size_t step, Expr ex) const
|
|
||||||
{
|
|
||||||
return mEc->iforhi(step, ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class Index, class ExpressionCollection>
|
|
||||||
size_t IndexWrapper<Index,ExpressionCollection>::getStepSizeComp(std::intptr_t j) const
|
|
||||||
{
|
{
|
||||||
return MultiArrayHelper::getStepSize(*mI, j);
|
return MultiArrayHelper::getStepSize(*mI, j);
|
||||||
}
|
}
|
||||||
|
@ -57,33 +21,33 @@ namespace MultiArrayTools
|
||||||
* DynamicRangeFactory *
|
* DynamicRangeFactory *
|
||||||
****************************/
|
****************************/
|
||||||
|
|
||||||
template <class EC>
|
|
||||||
template <class... RangeTypes>
|
template <class... RangeTypes>
|
||||||
DynamicRangeFactory<EC>::DynamicRangeFactory(const std::tuple<std::shared_ptr<RangeTypes>...>& origs)
|
DynamicRangeFactory::DynamicRangeFactory(const std::tuple<std::shared_ptr<RangeTypes>...>& origs)
|
||||||
{
|
{
|
||||||
mProd = std::shared_ptr<oType>( new DynamicRange<EC>( origs ) );
|
mProd = std::shared_ptr<oType>( new DynamicRange( origs ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class EC>
|
|
||||||
template <class... RangeTypes>
|
template <class... RangeTypes>
|
||||||
DynamicRangeFactory<EC>::DynamicRangeFactory(std::shared_ptr<RangeTypes>... origs)
|
DynamicRangeFactory::DynamicRangeFactory(std::shared_ptr<RangeTypes>... origs)
|
||||||
{
|
{
|
||||||
mProd = std::shared_ptr<oType>( new DynamicRange<EC>( origs... ) );
|
mProd = std::shared_ptr<oType>( new DynamicRange( origs... ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class EC>
|
|
||||||
DynamicRangeFactory<EC>::DynamicRangeFactory(const vector<std::shared_ptr<RangeBase>>& origs)
|
DynamicRangeFactory::DynamicRangeFactory(const vector<std::shared_ptr<RangeBase>>& origs)
|
||||||
{
|
{
|
||||||
mProd = std::shared_ptr<oType>( new DynamicRange<EC>( origs ) );
|
mProd = std::shared_ptr<oType>( new DynamicRange( origs ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class EC>
|
|
||||||
template <class Range>
|
template <class Range>
|
||||||
void DynamicRangeFactory<EC>::append(std::shared_ptr<Range> r)
|
void DynamicRangeFactory::append(std::shared_ptr<Range> r)
|
||||||
{
|
{
|
||||||
if(mProductCreated){
|
if(mProductCreated){
|
||||||
|
|
||||||
mProd = std::shared_ptr<oType>( new DynamicRange<EC>( *std::dynamic_pointer_cast<oType>(mProd) ) );
|
mProd = std::shared_ptr<oType>( new DynamicRange( *std::dynamic_pointer_cast<oType>(mProd) ) );
|
||||||
mProductCreated = false;
|
mProductCreated = false;
|
||||||
}
|
}
|
||||||
std::dynamic_pointer_cast<oType>(mProd)->mOrig.push_back(r);
|
std::dynamic_pointer_cast<oType>(mProd)->mOrig.push_back(r);
|
||||||
|
@ -91,18 +55,18 @@ namespace MultiArrayTools
|
||||||
std::dynamic_pointer_cast<oType>(mProd)->mEmpty = false;
|
std::dynamic_pointer_cast<oType>(mProd)->mEmpty = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class EC>
|
|
||||||
DynamicRangeFactory<EC>::DynamicRangeFactory()
|
DynamicRangeFactory::DynamicRangeFactory()
|
||||||
{
|
{
|
||||||
mProd = std::shared_ptr<oType>( new DynamicRange<EC>() );
|
mProd = std::shared_ptr<oType>( new DynamicRange() );
|
||||||
}
|
}
|
||||||
|
|
||||||
// INSTANCIATE IF NEEDED!!
|
// INSTANCIATE IF NEEDED!!
|
||||||
template <class EC>
|
|
||||||
std::map<std::shared_ptr<RangeBase>,vector<std::intptr_t> > DynamicRangeFactory<EC>::mAleadyCreated;
|
|
||||||
|
|
||||||
template <class EC>
|
std::map<std::shared_ptr<RangeBase>,vector<std::intptr_t> > DynamicRangeFactory::mAleadyCreated;
|
||||||
std::shared_ptr<RangeBase> DynamicRangeFactory<EC>::checkIfCreated(const vector<std::shared_ptr<RangeBase> >& pvec)
|
|
||||||
|
|
||||||
|
std::shared_ptr<RangeBase> DynamicRangeFactory::checkIfCreated(const vector<std::shared_ptr<RangeBase> >& pvec)
|
||||||
{
|
{
|
||||||
std::shared_ptr<RangeBase> out;
|
std::shared_ptr<RangeBase> out;
|
||||||
bool check = false;
|
bool check = false;
|
||||||
|
@ -133,10 +97,10 @@ namespace MultiArrayTools
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <class EC>
|
|
||||||
std::shared_ptr<RangeBase> DynamicRangeFactory<EC>::create()
|
std::shared_ptr<RangeBase> DynamicRangeFactory::create()
|
||||||
{
|
{
|
||||||
mProd = checkIfCreated(std::dynamic_pointer_cast<DynamicRange<EC>>(mProd)->mOrig);
|
mProd = checkIfCreated(std::dynamic_pointer_cast<DynamicRange>(mProd)->mOrig);
|
||||||
setSelf();
|
setSelf();
|
||||||
mProductCreated = true;
|
mProductCreated = true;
|
||||||
return mProd;
|
return mProd;
|
||||||
|
@ -147,8 +111,8 @@ namespace MultiArrayTools
|
||||||
* DynamicIndex *
|
* DynamicIndex *
|
||||||
*********************/
|
*********************/
|
||||||
|
|
||||||
template <class EC>
|
|
||||||
DynamicIndex<EC>::DynamicIndex(const std::shared_ptr<DynamicRange<EC> >& range) :
|
DynamicIndex::DynamicIndex(const std::shared_ptr<DynamicRange >& range) :
|
||||||
IndexInterface<DynamicIndex,MetaType>(range, 0),
|
IndexInterface<DynamicIndex,MetaType>(range, 0),
|
||||||
mIVec(range->dim())
|
mIVec(range->dim())
|
||||||
{
|
{
|
||||||
|
@ -160,21 +124,21 @@ namespace MultiArrayTools
|
||||||
mIVec[0].second = xx;
|
mIVec[0].second = xx;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class EC>
|
|
||||||
IndexType DynamicIndex<EC>::type() const
|
IndexType DynamicIndex::type() const
|
||||||
{
|
{
|
||||||
return IndexType::SINGLE;
|
return IndexType::SINGLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class EC>
|
|
||||||
DynamicIndex<EC>& DynamicIndex<EC>::operator=(size_t pos)
|
DynamicIndex& DynamicIndex::operator=(size_t pos)
|
||||||
{
|
{
|
||||||
IB::mPos = pos;
|
IB::mPos = pos;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class EC>
|
|
||||||
DynamicIndex<EC>& DynamicIndex<EC>::operator++()
|
DynamicIndex& DynamicIndex::operator++()
|
||||||
{
|
{
|
||||||
++IB::mPos;
|
++IB::mPos;
|
||||||
if(mIvecInit){
|
if(mIvecInit){
|
||||||
|
@ -190,8 +154,8 @@ namespace MultiArrayTools
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class EC>
|
|
||||||
DynamicIndex<EC>& DynamicIndex<EC>::operator--()
|
DynamicIndex& DynamicIndex::operator--()
|
||||||
{
|
{
|
||||||
--IB::mPos;
|
--IB::mPos;
|
||||||
if(mIvecInit){
|
if(mIvecInit){
|
||||||
|
@ -207,8 +171,8 @@ namespace MultiArrayTools
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class EC>
|
|
||||||
DynamicIndex<EC>& DynamicIndex<EC>::sync()
|
DynamicIndex& DynamicIndex::sync()
|
||||||
{
|
{
|
||||||
assert(mIvecInit);
|
assert(mIvecInit);
|
||||||
size_t sv = 1;
|
size_t sv = 1;
|
||||||
|
@ -221,8 +185,8 @@ namespace MultiArrayTools
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class EC>
|
|
||||||
DynamicIndex<EC>& DynamicIndex<EC>::operator()(const IVecT& ivec)
|
DynamicIndex& DynamicIndex::operator()(const IVecT& ivec)
|
||||||
{
|
{
|
||||||
mIvecInit = true;
|
mIvecInit = true;
|
||||||
mIVec = ivec;
|
mIVec = ivec;
|
||||||
|
@ -230,8 +194,8 @@ namespace MultiArrayTools
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class EC>
|
|
||||||
DynamicIndex<EC>& DynamicIndex<EC>::operator()(const vector<std::shared_ptr<IndexW<EC>>>& ivec)
|
DynamicIndex& DynamicIndex::operator()(const vector<std::shared_ptr<IndexW>>& ivec)
|
||||||
{
|
{
|
||||||
mIvecInit = true;
|
mIvecInit = true;
|
||||||
assert(mIVec.size() == ivec.size());
|
assert(mIVec.size() == ivec.size());
|
||||||
|
@ -242,13 +206,13 @@ namespace MultiArrayTools
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class EC>
|
|
||||||
template <class... Indices>
|
template <class... Indices>
|
||||||
DynamicIndex<EC>& DynamicIndex<EC>::operator()(const std::shared_ptr<Indices>&... is)
|
DynamicIndex& DynamicIndex::operator()(const std::shared_ptr<Indices>&... is)
|
||||||
{
|
{
|
||||||
mIvecInit = true;
|
mIvecInit = true;
|
||||||
vector<std::shared_ptr<IndexW<EC>>> tmp =
|
vector<std::shared_ptr<IndexW>> tmp =
|
||||||
{ std::make_shared<IndexWrapper<Indices,EC>>(is)... };
|
{ std::make_shared<IndexWrapper<Indices>>(is)... };
|
||||||
|
|
||||||
assert(mIVec.size() == tmp.size());
|
assert(mIVec.size() == tmp.size());
|
||||||
for(size_t i = 0; i != mIVec.size(); ++i){
|
for(size_t i = 0; i != mIVec.size(); ++i){
|
||||||
|
@ -258,107 +222,107 @@ namespace MultiArrayTools
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class EC>
|
|
||||||
int DynamicIndex<EC>::pp(std::intptr_t idxPtrNum)
|
int DynamicIndex::pp(std::intptr_t idxPtrNum)
|
||||||
{
|
{
|
||||||
++(*this);
|
++(*this);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class EC>
|
|
||||||
int DynamicIndex<EC>::mm(std::intptr_t idxPtrNum)
|
int DynamicIndex::mm(std::intptr_t idxPtrNum)
|
||||||
{
|
{
|
||||||
--(*this);
|
--(*this);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class EC>
|
|
||||||
std::string DynamicIndex<EC>::stringMeta() const
|
std::string DynamicIndex::stringMeta() const
|
||||||
{
|
{
|
||||||
return std::dynamic_pointer_cast<DynamicRange<EC> const>( IB::mRangePtr )->stringMeta(IB::mPos);
|
return std::dynamic_pointer_cast<DynamicRange const>( IB::mRangePtr )->stringMeta(IB::mPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class EC>
|
|
||||||
typename DynamicIndex<EC>::MetaType DynamicIndex<EC>::meta() const
|
typename DynamicIndex::MetaType DynamicIndex::meta() const
|
||||||
{
|
{
|
||||||
return std::dynamic_pointer_cast<DynamicRange<EC> const>( IB::mRangePtr )->get(IB::mPos);
|
return std::dynamic_pointer_cast<DynamicRange const>( IB::mRangePtr )->get(IB::mPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class EC>
|
|
||||||
const typename DynamicIndex<EC>::MetaType* DynamicIndex<EC>::metaPtr() const
|
const typename DynamicIndex::MetaType* DynamicIndex::metaPtr() const
|
||||||
{
|
{
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
bool DynamicIndex<EC>::isMeta(const MetaType& metaPos) const
|
bool DynamicIndex::isMeta(const MetaType& metaPos) const
|
||||||
{
|
{
|
||||||
return mExplicitRangePtr->isMeta(metaPos);
|
return mExplicitRangePtr->isMeta(metaPos);
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
template <class EC>
|
|
||||||
DynamicIndex<EC>& DynamicIndex<EC>::at(const MetaType& metaPos)
|
DynamicIndex& DynamicIndex::at(const MetaType& metaPos)
|
||||||
{
|
{
|
||||||
(*this) = std::dynamic_pointer_cast<DynamicRange<EC> const>( IB::mRangePtr )->getMeta( metaPos );
|
(*this) = std::dynamic_pointer_cast<DynamicRange const>( IB::mRangePtr )->getMeta( metaPos );
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class EC>
|
|
||||||
size_t DynamicIndex<EC>::posAt(const MetaType& metaPos) const
|
size_t DynamicIndex::posAt(const MetaType& metaPos) const
|
||||||
{
|
{
|
||||||
return std::dynamic_pointer_cast<DynamicRange<EC> const>( IB::mRangePtr )->getMeta( metaPos );
|
return std::dynamic_pointer_cast<DynamicRange const>( IB::mRangePtr )->getMeta( metaPos );
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class EC>
|
|
||||||
size_t DynamicIndex<EC>::dim() const // = 1
|
size_t DynamicIndex::dim() const // = 1
|
||||||
{
|
{
|
||||||
return mIVec.size();
|
return mIVec.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class EC>
|
|
||||||
bool DynamicIndex<EC>::last() const
|
bool DynamicIndex::last() const
|
||||||
{
|
{
|
||||||
return IB::mPos == IB::mMax - 1;
|
return IB::mPos == IB::mMax - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class EC>
|
|
||||||
bool DynamicIndex<EC>::first() const
|
bool DynamicIndex::first() const
|
||||||
{
|
{
|
||||||
return IB::mPos == 0;
|
return IB::mPos == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class EC>
|
|
||||||
const IndexW<EC>& DynamicIndex<EC>::get(size_t n) const
|
const IndexW& DynamicIndex::get(size_t n) const
|
||||||
{
|
{
|
||||||
assert(mIvecInit);
|
assert(mIvecInit);
|
||||||
return *mIVec[n].first;
|
return *mIVec[n].first;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class EC>
|
|
||||||
std::shared_ptr<typename DynamicIndex<EC>::RangeType> DynamicIndex<EC>::range()
|
std::shared_ptr<typename DynamicIndex::RangeType> DynamicIndex::range()
|
||||||
{
|
{
|
||||||
return std::dynamic_pointer_cast<RangeType>( IB::mRangePtr );
|
return std::dynamic_pointer_cast<RangeType>( IB::mRangePtr );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <class EC>
|
|
||||||
template <size_t N>
|
|
||||||
void DynamicIndex<EC>::getPtr() {}
|
|
||||||
|
|
||||||
template <class EC>
|
template <size_t N>
|
||||||
size_t DynamicIndex<EC>::getStepSize(size_t n) const
|
void DynamicIndex::getPtr() {}
|
||||||
|
|
||||||
|
|
||||||
|
size_t DynamicIndex::getStepSize(size_t n) const
|
||||||
{
|
{
|
||||||
return mIVec[n].second;
|
return mIVec[n].second;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class EC>
|
|
||||||
std::string DynamicIndex<EC>::id() const
|
std::string DynamicIndex::id() const
|
||||||
{
|
{
|
||||||
return std::string("dyn") + std::to_string(IB::mId);
|
return std::string("dyn") + std::to_string(IB::mId);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class EC>
|
|
||||||
void DynamicIndex<EC>::print(size_t offset)
|
void DynamicIndex::print(size_t offset)
|
||||||
{
|
{
|
||||||
if(offset == 0){
|
if(offset == 0){
|
||||||
std::cout << " === " << std::endl;
|
std::cout << " === " << std::endl;
|
||||||
|
@ -368,13 +332,12 @@ namespace MultiArrayTools
|
||||||
<< "](" << IB::mRangePtr << "): " /*<< meta().first*/ << std::endl;
|
<< "](" << IB::mRangePtr << "): " /*<< meta().first*/ << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Expr>
|
|
||||||
struct ForMaker
|
struct ForMaker
|
||||||
{
|
{
|
||||||
template <class IVecT>
|
template <class IVecT>
|
||||||
static inline auto mk(size_t i, size_t step, ExpressionHolder<Expr> ex,
|
static inline auto mk(size_t i, size_t step, DynamicExpression ex,
|
||||||
const IVecT& ivec, bool hidden = false)
|
const IVecT& ivec, bool hidden = false)
|
||||||
-> ExpressionHolder<Expr>
|
-> DynamicExpression
|
||||||
{
|
{
|
||||||
if(i == 0) {
|
if(i == 0) {
|
||||||
auto& ii = *ivec[0].first;
|
auto& ii = *ivec[0].first;
|
||||||
|
@ -393,9 +356,9 @@ namespace MultiArrayTools
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
template <class EC>
|
|
||||||
template <class Expr>
|
template <class Expr>
|
||||||
inline auto DynamicIndex<EC>::mkFor(size_t i, size_t step,
|
inline auto DynamicIndex::mkFor(size_t i, size_t step,
|
||||||
ExpressionHolder<Expr> ex,
|
ExpressionHolder<Expr> ex,
|
||||||
bool hidden) const
|
bool hidden) const
|
||||||
-> ExpressionHolder<Expr>
|
-> ExpressionHolder<Expr>
|
||||||
|
@ -410,35 +373,36 @@ namespace MultiArrayTools
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
template <class EC>
|
|
||||||
template <class Expr>
|
template <class Expr>
|
||||||
ExpressionHolder<Expr> DynamicIndex<EC>::ifor(size_t step, Expr ex) const
|
ExpressionHolder<Expr> DynamicIndex::ifor(size_t step, Expr ex) const
|
||||||
{
|
{
|
||||||
if(mIVec.size() == 1){
|
if(mIVec.size() == 1){
|
||||||
return mIVec.back().first->ifori(step,ex);
|
return ExpressionHolder<Expr>(mIVec.back().first->ifor(step,ex));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return ForMaker<Expr>::mk(mIVec.size()-2, step, mIVec.back().first->ifori(step,ex),
|
return ExpressionHolder<Expr>(ForMaker::mk(mIVec.size()-2, step,
|
||||||
mIVec);
|
mIVec.back().first->ifor(step,ex),mIVec));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class EC>
|
|
||||||
template <class Expr>
|
template <class Expr>
|
||||||
ExpressionHolder<Expr> DynamicIndex<EC>::iforh(size_t step, Expr ex) const
|
ExpressionHolder<Expr> DynamicIndex::iforh(size_t step, Expr ex) const
|
||||||
{
|
{
|
||||||
if(mIVec.size() == 1){
|
if(mIVec.size() == 1){
|
||||||
return mIVec.back().first->iforhi(step,ex);
|
return ExpressionHolder<Expr>(mIVec.back().first->iforh(step,ex));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return ForMaker<Expr>::mk(mIVec.size()-2, step, mIVec.back().first->iforhi(step,ex),
|
return ExpressionHolder<Expr>(ForMaker::mk(mIVec.size()-2, step,
|
||||||
mIVec, true);
|
mIVec.back().first->iforh(step,ex),
|
||||||
|
mIVec, true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class EC>
|
|
||||||
template <class Expr>
|
template <class Expr>
|
||||||
ExpressionHolder<Expr> DynamicIndex<EC>::pifor(size_t step, Expr ex) const
|
ExpressionHolder<Expr> DynamicIndex::pifor(size_t step, Expr ex) const
|
||||||
{
|
{
|
||||||
return ifor(step, ex); // no multithreading here at the moment...
|
return ifor(step, ex); // no multithreading here at the moment...
|
||||||
}
|
}
|
||||||
|
@ -447,46 +411,46 @@ namespace MultiArrayTools
|
||||||
* DynamicRange *
|
* DynamicRange *
|
||||||
***********************/
|
***********************/
|
||||||
|
|
||||||
template <class EC>
|
|
||||||
typename DynamicRange<EC>::MetaType DynamicRange<EC>::get(size_t pos) const
|
typename DynamicRange::MetaType DynamicRange::get(size_t pos) const
|
||||||
{
|
{
|
||||||
vector<char> out(cmetaSize());
|
vector<char> out(cmetaSize());
|
||||||
cmeta(out.data(),pos);
|
cmeta(out.data(),pos);
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class EC>
|
|
||||||
size_t DynamicRange<EC>::getMeta(const MetaType& metaPos) const
|
size_t DynamicRange::getMeta(const MetaType& metaPos) const
|
||||||
{
|
{
|
||||||
return 0; // !!!
|
return 0; // !!!
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class EC>
|
|
||||||
size_t DynamicRange<EC>::size() const
|
size_t DynamicRange::size() const
|
||||||
{
|
{
|
||||||
return mSize;
|
return mSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class EC>
|
|
||||||
size_t DynamicRange<EC>::dim() const
|
size_t DynamicRange::dim() const
|
||||||
{
|
{
|
||||||
return mOrig.size();
|
return mOrig.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class EC>
|
|
||||||
SpaceType DynamicRange<EC>::spaceType() const
|
SpaceType DynamicRange::spaceType() const
|
||||||
{
|
{
|
||||||
return SpaceType::DYN;
|
return SpaceType::DYN;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class EC>
|
|
||||||
bool DynamicRange<EC>::isEmpty() const
|
bool DynamicRange::isEmpty() const
|
||||||
{
|
{
|
||||||
return mEmpty;
|
return mEmpty;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class EC>
|
|
||||||
vector<size_t> DynamicRange<EC>::typeNum() const
|
vector<size_t> DynamicRange::typeNum() const
|
||||||
{
|
{
|
||||||
vector<size_t> o;
|
vector<size_t> o;
|
||||||
for(auto& x: mOrig){
|
for(auto& x: mOrig){
|
||||||
|
@ -496,8 +460,8 @@ namespace MultiArrayTools
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class EC>
|
|
||||||
size_t DynamicRange<EC>::cmeta(char* target, size_t pos) const
|
size_t DynamicRange::cmeta(char* target, size_t pos) const
|
||||||
{
|
{
|
||||||
size_t out = 0;
|
size_t out = 0;
|
||||||
size_t off = cmetaSize();
|
size_t off = cmetaSize();
|
||||||
|
@ -515,8 +479,8 @@ namespace MultiArrayTools
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class EC>
|
|
||||||
size_t DynamicRange<EC>::cmetaSize() const
|
size_t DynamicRange::cmetaSize() const
|
||||||
{
|
{
|
||||||
size_t out = 0;
|
size_t out = 0;
|
||||||
for(size_t i = mOrig.size(); i != 0; --i) {
|
for(size_t i = mOrig.size(); i != 0; --i) {
|
||||||
|
@ -526,8 +490,8 @@ namespace MultiArrayTools
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class EC>
|
|
||||||
std::string DynamicRange<EC>::stringMeta(size_t pos) const
|
std::string DynamicRange::stringMeta(size_t pos) const
|
||||||
{
|
{
|
||||||
std::string out = "";
|
std::string out = "";
|
||||||
//size_t xpos = pos;
|
//size_t xpos = pos;
|
||||||
|
@ -542,8 +506,8 @@ namespace MultiArrayTools
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class EC>
|
|
||||||
vector<char> DynamicRange<EC>::data() const
|
vector<char> DynamicRange::data() const
|
||||||
{
|
{
|
||||||
DataHeader h = dataHeader();
|
DataHeader h = dataHeader();
|
||||||
vector<char> out;
|
vector<char> out;
|
||||||
|
@ -556,8 +520,8 @@ namespace MultiArrayTools
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class EC>
|
|
||||||
DataHeader DynamicRange<EC>::dataHeader() const
|
DataHeader DynamicRange::dataHeader() const
|
||||||
{
|
{
|
||||||
DataHeader h;
|
DataHeader h;
|
||||||
h.spaceType = static_cast<int>( SpaceType::DYN );
|
h.spaceType = static_cast<int>( SpaceType::DYN );
|
||||||
|
@ -566,43 +530,43 @@ namespace MultiArrayTools
|
||||||
return h;
|
return h;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class EC>
|
|
||||||
typename DynamicRange<EC>::IndexType DynamicRange<EC>::begin() const
|
typename DynamicRange::IndexType DynamicRange::begin() const
|
||||||
{
|
{
|
||||||
DynamicIndex<EC> i
|
DynamicIndex i
|
||||||
(std::dynamic_pointer_cast<DynamicRange>
|
(std::dynamic_pointer_cast<DynamicRange>
|
||||||
( std::shared_ptr<RangeBase>(RB::mThis) ) );
|
( std::shared_ptr<RangeBase>(RB::mThis) ) );
|
||||||
i = 0;
|
i = 0;
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class EC>
|
|
||||||
typename DynamicRange<EC>::IndexType DynamicRange<EC>::end() const
|
typename DynamicRange::IndexType DynamicRange::end() const
|
||||||
{
|
{
|
||||||
DynamicIndex<EC> i
|
DynamicIndex i
|
||||||
(std::dynamic_pointer_cast<DynamicRange>
|
(std::dynamic_pointer_cast<DynamicRange>
|
||||||
( std::shared_ptr<RangeBase>(RB::mThis) ) );
|
( std::shared_ptr<RangeBase>(RB::mThis) ) );
|
||||||
i = size();
|
i = size();
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class EC>
|
|
||||||
std::shared_ptr<RangeBase> DynamicRange<EC>::sub(size_t num) const
|
std::shared_ptr<RangeBase> DynamicRange::sub(size_t num) const
|
||||||
{
|
{
|
||||||
return mOrig.at(num);
|
return mOrig.at(num);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class EC>
|
|
||||||
void DynamicRange<EC>::sreplace(const std::shared_ptr<RangeBase> in, size_t num)
|
void DynamicRange::sreplace(const std::shared_ptr<RangeBase> in, size_t num)
|
||||||
{
|
{
|
||||||
assert(mOrig[num]->size() == in->size());
|
assert(mOrig[num]->size() == in->size());
|
||||||
mOrig[num] = in;
|
mOrig[num] = in;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class EC>
|
|
||||||
template <class... RangeTypes>
|
template <class... RangeTypes>
|
||||||
DynamicRange<EC>::DynamicRange(const std::tuple<std::shared_ptr<RangeTypes>...>& origs) :
|
DynamicRange::DynamicRange(const std::tuple<std::shared_ptr<RangeTypes>...>& origs) :
|
||||||
RangeInterface<DynamicIndex<EC>>()
|
RangeInterface<DynamicIndex>()
|
||||||
{
|
{
|
||||||
RPackNum<sizeof...(RangeTypes)-1>::RangesToVec( origs, mOrig );
|
RPackNum<sizeof...(RangeTypes)-1>::RangesToVec( origs, mOrig );
|
||||||
mSize = RPackNum<sizeof...(RangeTypes)-1>::getSize( origs );
|
mSize = RPackNum<sizeof...(RangeTypes)-1>::getSize( origs );
|
||||||
|
@ -611,10 +575,10 @@ namespace MultiArrayTools
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class EC>
|
|
||||||
template <class... RangeTypes>
|
template <class... RangeTypes>
|
||||||
DynamicRange<EC>::DynamicRange(std::shared_ptr<RangeTypes>... origs) :
|
DynamicRange::DynamicRange(std::shared_ptr<RangeTypes>... origs) :
|
||||||
RangeInterface<DynamicIndex<EC>>()
|
RangeInterface<DynamicIndex>()
|
||||||
{
|
{
|
||||||
auto rst = std::make_tuple(origs...);
|
auto rst = std::make_tuple(origs...);
|
||||||
RPackNum<sizeof...(RangeTypes)-1>::RangesToVec( rst, mOrig );
|
RPackNum<sizeof...(RangeTypes)-1>::RangesToVec( rst, mOrig );
|
||||||
|
@ -624,9 +588,9 @@ namespace MultiArrayTools
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class EC>
|
|
||||||
DynamicRange<EC>::DynamicRange(const vector<std::shared_ptr<RangeBase>>& origs) :
|
DynamicRange::DynamicRange(const vector<std::shared_ptr<RangeBase>>& origs) :
|
||||||
RangeInterface<DynamicIndex<EC>>(),
|
RangeInterface<DynamicIndex>(),
|
||||||
mOrig(origs)
|
mOrig(origs)
|
||||||
{
|
{
|
||||||
mSize = 1;
|
mSize = 1;
|
||||||
|
@ -638,16 +602,16 @@ namespace MultiArrayTools
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class EC>
|
|
||||||
template <class Range>
|
template <class Range>
|
||||||
std::shared_ptr<Range> DynamicRange<EC>::fullsub(size_t num) const
|
std::shared_ptr<Range> DynamicRange::fullsub(size_t num) const
|
||||||
{
|
{
|
||||||
return std::dynamic_pointer_cast<Range>( mOrig.at(num) );
|
return std::dynamic_pointer_cast<Range>( mOrig.at(num) );
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class EC>
|
|
||||||
template <class... Ranges>
|
template <class... Ranges>
|
||||||
std::shared_ptr<MultiRange<Ranges...> > DynamicRange<EC>::scast(SIZET<Ranges>... sizes) const
|
std::shared_ptr<MultiRange<Ranges...> > DynamicRange::scast(SIZET<Ranges>... sizes) const
|
||||||
{
|
{
|
||||||
std::tuple<std::shared_ptr<Ranges>...> rtp;
|
std::tuple<std::shared_ptr<Ranges>...> rtp;
|
||||||
RPackNum<sizeof...(Ranges)-1>::resolveRangeType(mOrig, rtp, 0, sizes...);
|
RPackNum<sizeof...(Ranges)-1>::resolveRangeType(mOrig, rtp, 0, sizes...);
|
||||||
|
@ -655,8 +619,8 @@ namespace MultiArrayTools
|
||||||
return std::dynamic_pointer_cast<MultiRange<Ranges...> >( mrf.create() );
|
return std::dynamic_pointer_cast<MultiRange<Ranges...> >( mrf.create() );
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class EC>
|
|
||||||
const vector<std::shared_ptr<RangeBase> >& DynamicRange<EC>::orig() const
|
const vector<std::shared_ptr<RangeBase> >& DynamicRange::orig() const
|
||||||
{
|
{
|
||||||
return mOrig;
|
return mOrig;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ namespace MultiArrayTools
|
||||||
//using MultiArrayHelper::DynamicExpression;
|
//using MultiArrayHelper::DynamicExpression;
|
||||||
|
|
||||||
//using MultiArrayHelper::ExpressionHolder;
|
//using MultiArrayHelper::ExpressionHolder;
|
||||||
|
/*
|
||||||
class AbstractIW
|
class AbstractIW
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -36,11 +36,23 @@ namespace MultiArrayTools
|
||||||
AbstractIW& operator=(const AbstractIW& in) = default;
|
AbstractIW& operator=(const AbstractIW& in) = default;
|
||||||
AbstractIW& operator=(AbstractIW&& in) = default;
|
AbstractIW& operator=(AbstractIW&& in) = default;
|
||||||
|
|
||||||
|
};
|
||||||
|
*/
|
||||||
|
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 IndexType type() const = 0;
|
||||||
|
|
||||||
virtual AbstractIW& operator=(size_t pos) = 0;
|
virtual IndexWrapperBase& operator=(size_t pos) = 0;
|
||||||
virtual AbstractIW& operator++() = 0;
|
virtual IndexWrapperBase& operator++() = 0;
|
||||||
virtual AbstractIW& operator--() = 0;
|
virtual IndexWrapperBase& operator--() = 0;
|
||||||
|
|
||||||
virtual int pp(std::intptr_t idxPtrNum) = 0;
|
virtual int pp(std::intptr_t idxPtrNum) = 0;
|
||||||
virtual int mm(std::intptr_t idxPtrNum) = 0;
|
virtual int mm(std::intptr_t idxPtrNum) = 0;
|
||||||
|
@ -61,7 +73,7 @@ namespace MultiArrayTools
|
||||||
virtual std::intptr_t get() const = 0;
|
virtual std::intptr_t get() const = 0;
|
||||||
virtual std::intptr_t ptrNum() const = 0;
|
virtual std::intptr_t ptrNum() const = 0;
|
||||||
|
|
||||||
virtual std::shared_ptr<AbstractIW> duplicate() const = 0;
|
virtual std::shared_ptr<IndexWrapperBase> duplicate() const = 0;
|
||||||
|
|
||||||
//virtual DynamicMetaT meta() const = 0;
|
//virtual DynamicMetaT meta() const = 0;
|
||||||
//virtual const DynamicMetaT* metaPtr() const = 0;
|
//virtual const DynamicMetaT* metaPtr() const = 0;
|
||||||
|
@ -69,7 +81,7 @@ namespace MultiArrayTools
|
||||||
//virtual size_t posAt(const U& metaPos) const = 0;
|
//virtual size_t posAt(const U& metaPos) const = 0;
|
||||||
|
|
||||||
//virtual bool isMeta(const U& metaPos) const = 0;
|
//virtual bool isMeta(const U& metaPos) const = 0;
|
||||||
inline AbstractIW& at(const std::string smeta)
|
inline IndexWrapperBase& at(const std::string smeta)
|
||||||
{
|
{
|
||||||
for((*this) = 0; this->pos() != this->max(); ++(*this)){
|
for((*this) = 0; this->pos() != this->max(); ++(*this)){
|
||||||
if(this->stringMeta() == smeta){
|
if(this->stringMeta() == smeta){
|
||||||
|
@ -78,48 +90,22 @@ namespace MultiArrayTools
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
template <class ExpressionCollection>
|
|
||||||
class IndexWrapperBase : public AbstractIW
|
|
||||||
{
|
|
||||||
protected:
|
|
||||||
std::shared_ptr<ExpressionCollection> mEc;
|
|
||||||
public:
|
|
||||||
|
|
||||||
IndexWrapperBase() = default;
|
|
||||||
IndexWrapperBase(const IndexWrapperBase& in) = default;
|
|
||||||
IndexWrapperBase(IndexWrapperBase&& in) = default;
|
|
||||||
IndexWrapperBase& operator=(const IndexWrapperBase& in) = default;
|
|
||||||
IndexWrapperBase& operator=(IndexWrapperBase&& in) = default;
|
|
||||||
|
|
||||||
using AbstractIW::operator=;
|
|
||||||
|
|
||||||
template <class Expr>
|
|
||||||
ExpressionHolder<Expr> ifor(size_t step, ExpressionHolder<Expr> ex) const;
|
|
||||||
|
|
||||||
template <class Expr>
|
|
||||||
ExpressionHolder<Expr> iforh(size_t step, ExpressionHolder<Expr> ex) const;
|
|
||||||
|
|
||||||
template <class Expr>
|
|
||||||
ExpressionHolder<Expr> ifori(size_t step, Expr ex) const;
|
|
||||||
|
|
||||||
template <class Expr>
|
|
||||||
ExpressionHolder<Expr> iforhi(size_t step, Expr ex) const;
|
|
||||||
|
|
||||||
|
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
|
std::shared_ptr<IndexWrapperBase> duplicateI() const
|
||||||
{ return std::dynamic_pointer_cast<IndexWrapperBase>( this->duplicate() ); }
|
{ return std::dynamic_pointer_cast<IndexWrapperBase>( this->duplicate() ); }
|
||||||
|
*/
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class EC>
|
typedef IndexWrapperBase IndexW;
|
||||||
using IndexW = IndexWrapperBase<EC>;
|
|
||||||
|
|
||||||
template <class Index, class ExpressionCollection>
|
template <class Index>
|
||||||
class IndexWrapper : public IndexWrapperBase<ExpressionCollection>
|
class IndexWrapper : public IndexWrapperBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef IndexWrapperBase<ExpressionCollection> IWB;
|
typedef IndexWrapperBase IWB;
|
||||||
typedef typename Index::MetaType MetaType;
|
typedef typename Index::MetaType MetaType;
|
||||||
|
|
||||||
static constexpr IndexType sType() { return IndexType::SINGLE; }
|
static constexpr IndexType sType() { return IndexType::SINGLE; }
|
||||||
|
@ -136,8 +122,7 @@ namespace MultiArrayTools
|
||||||
IndexWrapper& operator=(const IndexWrapper& in) = default;
|
IndexWrapper& operator=(const IndexWrapper& in) = default;
|
||||||
IndexWrapper& operator=(IndexWrapper&& in) = default;
|
IndexWrapper& operator=(IndexWrapper&& in) = default;
|
||||||
|
|
||||||
IndexWrapper(const std::shared_ptr<Index>& i) : mI(i)
|
IndexWrapper(const std::shared_ptr<Index>& i) : mI(i) {}
|
||||||
{ IWB::mEc = ExpressionCollection::make(mI); }
|
|
||||||
|
|
||||||
virtual IndexType type() const final { return mI->type(); }
|
virtual IndexType type() const final { return mI->type(); }
|
||||||
|
|
||||||
|
@ -171,26 +156,30 @@ namespace MultiArrayTools
|
||||||
virtual std::intptr_t get() const override final { return reinterpret_cast<std::intptr_t>(mI.get()); }
|
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(); }
|
virtual std::intptr_t ptrNum() const override final { return mI->ptrNum(); }
|
||||||
|
|
||||||
virtual std::shared_ptr<AbstractIW> duplicate() const override final
|
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
|
||||||
{ return std::make_shared<IndexWrapper>( std::make_shared<Index>( *mI ) ); }
|
{ return std::make_shared<IndexWrapper>( std::make_shared<Index>( *mI ) ); }
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//typedef SingleRange<size_t,SpaceType::DYN> DynamicRange;
|
//typedef SingleRange<size_t,SpaceType::DYN> DynamicRange;
|
||||||
|
|
||||||
template <class EC>
|
class DynamicIndex : public IndexInterface<DynamicIndex,vector<char>>
|
||||||
class DynamicIndex : public IndexInterface<DynamicIndex<EC>,vector<char>>
|
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
typedef vector<std::pair<std::shared_ptr<IndexW<EC>>,size_t>> IVecT;
|
typedef vector<std::pair<std::shared_ptr<IndexW>,size_t>> IVecT;
|
||||||
|
|
||||||
IVecT mIVec;
|
IVecT mIVec;
|
||||||
bool mIvecInit = false;
|
bool mIvecInit = false;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef IndexInterface<DynamicIndex<EC>,vector<char>> IB;
|
typedef IndexInterface<DynamicIndex,vector<char>> IB;
|
||||||
typedef vector<char> MetaType;
|
typedef vector<char> MetaType;
|
||||||
typedef DynamicRange<EC> RangeType;
|
typedef DynamicRange RangeType;
|
||||||
typedef DynamicIndex IType;
|
typedef DynamicIndex IType;
|
||||||
|
|
||||||
DynamicIndex(const std::shared_ptr<RangeType>& range);
|
DynamicIndex(const std::shared_ptr<RangeType>& range);
|
||||||
|
@ -208,12 +197,12 @@ namespace MultiArrayTools
|
||||||
DynamicIndex& operator--();
|
DynamicIndex& operator--();
|
||||||
|
|
||||||
DynamicIndex& operator()(const IVecT& ivec);
|
DynamicIndex& operator()(const IVecT& ivec);
|
||||||
DynamicIndex& operator()(const vector<std::shared_ptr<IndexW<EC>>>& ivec);
|
DynamicIndex& operator()(const vector<std::shared_ptr<IndexW>>& ivec);
|
||||||
|
|
||||||
template <class... Indices>
|
template <class... Indices>
|
||||||
DynamicIndex& operator()(const std::shared_ptr<Indices>&... is);
|
DynamicIndex& operator()(const std::shared_ptr<Indices>&... is);
|
||||||
|
|
||||||
DynamicIndex<EC>& sync();
|
DynamicIndex& sync();
|
||||||
|
|
||||||
int pp(std::intptr_t idxPtrNum);
|
int pp(std::intptr_t idxPtrNum);
|
||||||
int mm(std::intptr_t idxPtrNum);
|
int mm(std::intptr_t idxPtrNum);
|
||||||
|
@ -230,7 +219,7 @@ namespace MultiArrayTools
|
||||||
bool last() const;
|
bool last() const;
|
||||||
bool first() const;
|
bool first() const;
|
||||||
|
|
||||||
const IndexW<EC>& get(size_t n) const;
|
const IndexW& get(size_t n) const;
|
||||||
|
|
||||||
std::shared_ptr<RangeType> range();
|
std::shared_ptr<RangeType> range();
|
||||||
|
|
||||||
|
@ -255,12 +244,11 @@ namespace MultiArrayTools
|
||||||
|
|
||||||
|
|
||||||
// NOT THREAD SAVE!!
|
// NOT THREAD SAVE!!
|
||||||
template <class EC>
|
|
||||||
class DynamicRangeFactory : public RangeFactoryBase
|
class DynamicRangeFactory : public RangeFactoryBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
typedef DynamicRange<EC> oType;
|
typedef DynamicRange oType;
|
||||||
|
|
||||||
DynamicRangeFactory();
|
DynamicRangeFactory();
|
||||||
|
|
||||||
|
@ -286,8 +274,7 @@ namespace MultiArrayTools
|
||||||
bool mProductCreated = false;
|
bool mProductCreated = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class EC>
|
class DynamicRange : public RangeInterface<DynamicIndex>
|
||||||
class DynamicRange : public RangeInterface<DynamicIndex<EC>>
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static constexpr bool defaultable = true;
|
static constexpr bool defaultable = true;
|
||||||
|
@ -296,10 +283,10 @@ namespace MultiArrayTools
|
||||||
static constexpr bool HASMETACONT = false;
|
static constexpr bool HASMETACONT = false;
|
||||||
|
|
||||||
typedef RangeBase RB;
|
typedef RangeBase RB;
|
||||||
typedef DynamicIndex<EC> IndexType;
|
typedef DynamicIndex IndexType;
|
||||||
typedef DynamicRange RangeType;
|
typedef DynamicRange RangeType;
|
||||||
typedef vector<char> MetaType;
|
typedef vector<char> MetaType;
|
||||||
typedef DynamicRangeFactory<EC> FType;
|
typedef DynamicRangeFactory FType;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DynamicRange() = default;
|
DynamicRange() = default;
|
||||||
|
@ -351,10 +338,10 @@ namespace MultiArrayTools
|
||||||
|
|
||||||
bool isEmpty() const;
|
bool isEmpty() const;
|
||||||
|
|
||||||
friend DynamicRangeFactory<EC>;
|
friend DynamicRangeFactory;
|
||||||
|
|
||||||
static DynamicRangeFactory<EC> factory()
|
static DynamicRangeFactory factory()
|
||||||
{ return DynamicRangeFactory<EC>(); }
|
{ return DynamicRangeFactory(); }
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -365,22 +352,20 @@ namespace MultiArrayHelper
|
||||||
{
|
{
|
||||||
using namespace MultiArrayTools;
|
using namespace MultiArrayTools;
|
||||||
|
|
||||||
template <class EC>
|
inline void resolveSetRange(std::shared_ptr<DynamicRange>& rp,
|
||||||
inline void resolveSetRange(std::shared_ptr<DynamicRange<EC>>& rp,
|
|
||||||
const vector<std::shared_ptr<RangeBase> >& orig,
|
const vector<std::shared_ptr<RangeBase> >& orig,
|
||||||
size_t origpos, size_t size)
|
size_t origpos, size_t size)
|
||||||
{
|
{
|
||||||
DynamicRangeFactory<EC> arf;
|
DynamicRangeFactory arf;
|
||||||
for(size_t op = origpos; op != origpos + size; ++op){
|
for(size_t op = origpos; op != origpos + size; ++op){
|
||||||
//VCHECK(op);
|
//VCHECK(op);
|
||||||
arf.append(orig[op]);
|
arf.append(orig[op]);
|
||||||
}
|
}
|
||||||
rp = std::dynamic_pointer_cast<DynamicRange<EC>>( arf.create() );
|
rp = std::dynamic_pointer_cast<DynamicRange>( arf.create() );
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class EC>
|
|
||||||
inline void setRangeToVec(vector<std::shared_ptr<RangeBase> >& v,
|
inline void setRangeToVec(vector<std::shared_ptr<RangeBase> >& v,
|
||||||
std::shared_ptr<DynamicRange<EC>> r)
|
std::shared_ptr<DynamicRange> r)
|
||||||
{
|
{
|
||||||
if(not r->isEmpty()){
|
if(not r->isEmpty()){
|
||||||
for(size_t i = r->dim(); i != 0; --i){
|
for(size_t i = r->dim(); i != 0; --i){
|
||||||
|
@ -389,8 +374,7 @@ namespace MultiArrayHelper
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class EC>
|
inline size_t getStepSize(const DynamicIndex& ii, std::intptr_t j)
|
||||||
inline size_t getStepSize(const DynamicIndex<EC>& ii, std::intptr_t j)
|
|
||||||
{
|
{
|
||||||
size_t ss = 0;
|
size_t ss = 0;
|
||||||
size_t sx = 1;
|
size_t sx = 1;
|
||||||
|
|
|
@ -103,18 +103,18 @@ namespace MultiArrayTools
|
||||||
//class AnonymousRange;
|
//class AnonymousRange;
|
||||||
|
|
||||||
// dynamic_range.h
|
// dynamic_range.h
|
||||||
class AbstractIW;
|
//class AbstractIW;
|
||||||
|
|
||||||
// dynamic_range.h
|
// dynamic_range.h
|
||||||
template <class EC>
|
//template <class EC>
|
||||||
class DynamicIndex;
|
class DynamicIndex;
|
||||||
|
|
||||||
// dynamic_range.h
|
// dynamic_range.h
|
||||||
template <class EC>
|
//template <class EC>
|
||||||
class DynamicRangeFactory;
|
class DynamicRangeFactory;
|
||||||
|
|
||||||
// dynamic_range.h
|
// dynamic_range.h
|
||||||
template <class EC>
|
//template <class EC>
|
||||||
class DynamicRange;
|
class DynamicRange;
|
||||||
|
|
||||||
// value_range.h
|
// value_range.h
|
||||||
|
|
|
@ -34,8 +34,12 @@ namespace MultiArrayHelper
|
||||||
|
|
||||||
virtual size_t size() const = 0;
|
virtual size_t size() const = 0;
|
||||||
//virtual size_t rootSteps() const = 0;
|
//virtual size_t rootSteps() const = 0;
|
||||||
|
virtual std::shared_ptr<ExtBase> operator+(const ExtBase& in) const = 0;
|
||||||
|
virtual std::shared_ptr<ExtBase> operator*(size_t in) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef std::shared_ptr<ExtBase> DExt;
|
||||||
|
|
||||||
template <class ExtType>
|
template <class ExtType>
|
||||||
class ExtT : public ExtBase
|
class ExtT : public ExtBase
|
||||||
{
|
{
|
||||||
|
@ -53,9 +57,35 @@ namespace MultiArrayHelper
|
||||||
virtual size_t size() const override final { return sizeof(ExtType)/sizeof(size_t); }
|
virtual size_t size() const override final { return sizeof(ExtType)/sizeof(size_t); }
|
||||||
//virtual size_t rootSteps() const override final;
|
//virtual size_t rootSteps() const override final;
|
||||||
const ExtType& ext() const { return mExt; }
|
const ExtType& ext() const { return mExt; }
|
||||||
|
|
||||||
|
virtual DExt operator+(const ExtBase& in) const override final
|
||||||
|
{ return std::make_shared<ExtT>( mExt + dynamic_cast<const ExtT&>(in).mExt ); }
|
||||||
|
virtual DExt operator*(size_t in) const override final
|
||||||
|
{ return std::make_shared<ExtT>( mExt * in ); }
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::shared_ptr<ExtBase> DExt;
|
|
||||||
|
class DExtT
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
DExt mDExt;
|
||||||
|
public:
|
||||||
|
DExtT() = default;
|
||||||
|
DExtT(const DExtT& in) = default;
|
||||||
|
DExtT(DExtT&& in) = default;
|
||||||
|
DExtT& operator=(const DExtT& in) = default;
|
||||||
|
DExtT& operator=(DExtT&& in) = default;
|
||||||
|
DExtT(const DExt& in) : mDExt(in) {}
|
||||||
|
|
||||||
|
virtual size_t size() const { return mDExt->size(); }
|
||||||
|
inline const DExt& get() const { return mDExt; }
|
||||||
|
|
||||||
|
inline DExtT operator+(const DExtT& in) const
|
||||||
|
{ return DExtT( (*mDExt) + (*in.mDExt) ) ; }
|
||||||
|
inline DExtT operator*(size_t in) const
|
||||||
|
{ return DExtT( (*mDExt) * in ) ; }
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
inline MExt<void> mkExt(size_t s) { return MExt<void>(s); }
|
inline MExt<void> mkExt(size_t s) { return MExt<void>(s); }
|
||||||
|
|
||||||
|
@ -333,6 +363,9 @@ namespace MultiArrayHelper
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
static constexpr size_t LAYER = 0;
|
||||||
|
static constexpr size_t SIZE = 0;
|
||||||
|
|
||||||
DynamicExpression(const DynamicExpression& in) = default;
|
DynamicExpression(const DynamicExpression& in) = default;
|
||||||
DynamicExpression(DynamicExpression&& in) = default;
|
DynamicExpression(DynamicExpression&& in) = default;
|
||||||
DynamicExpression& operator=(const DynamicExpression& in) = default;
|
DynamicExpression& operator=(const DynamicExpression& in) = default;
|
||||||
|
@ -342,15 +375,24 @@ namespace MultiArrayHelper
|
||||||
mNext(next)
|
mNext(next)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
template <class Expr>
|
||||||
|
DynamicExpression(const ExpressionBase& next) :
|
||||||
|
mNext(std::make_shared<Expr>(next))
|
||||||
|
{}
|
||||||
|
|
||||||
template <class Expr>
|
template <class Expr>
|
||||||
DynamicExpression(Expr ex) : mNext( std::make_shared<Expr>(ex) ) {}
|
DynamicExpression(Expr ex) : mNext( std::make_shared<Expr>(ex) ) {}
|
||||||
|
|
||||||
inline void operator()(size_t mlast, DExt last) override final;
|
inline void operator()(size_t mlast, DExt last) override final;
|
||||||
|
inline void operator()(size_t mlast, DExtT last) { (*this)(mlast,last.get()); }
|
||||||
inline void operator()(size_t mlast = 0) override final;
|
inline void operator()(size_t mlast = 0) override final;
|
||||||
|
|
||||||
inline DExt dRootSteps(std::intptr_t iPtrNum = 0) const override final;
|
inline DExt dRootSteps(std::intptr_t iPtrNum = 0) const override final;
|
||||||
inline DExt dExtension() const override final;
|
inline DExt dExtension() const override final;
|
||||||
|
|
||||||
|
inline DExtT rootSteps(std::intptr_t iPtrNum = 0) const { return dRootSteps(iPtrNum); }
|
||||||
|
inline DExtT extension() const { return dExtension(); }
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,7 @@ namespace {
|
||||||
return std::make_tuple(static_cast<size_t>( ts )...);
|
return std::make_tuple(static_cast<size_t>( ts )...);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef Expressions1 EC1;
|
//typedef Expressions1 EC1;
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct Pow
|
struct Pow
|
||||||
|
@ -736,17 +736,17 @@ namespace {
|
||||||
TEST_F(OpTest_MDim, ExecDOp)
|
TEST_F(OpTest_MDim, ExecDOp)
|
||||||
{
|
{
|
||||||
//typedef MultiArray<double,AnonymousRange> AMA;
|
//typedef MultiArray<double,AnonymousRange> AMA;
|
||||||
typedef MultiArray<double,DynamicRange<EC1> > DMA;
|
typedef MultiArray<double,DynamicRange> DMA;
|
||||||
|
|
||||||
MultiArray<double,MRange,SRange> ma1(mr1ptr,sr4ptr,v5);
|
MultiArray<double,MRange,SRange> ma1(mr1ptr,sr4ptr,v5);
|
||||||
MultiArray<double,SRange> ma2(sr2ptr,v1);
|
MultiArray<double,SRange> ma2(sr2ptr,v1);
|
||||||
MultiArray<double,SRange,MRange> res(sr4ptr,mr1ptr);
|
MultiArray<double,SRange,MRange> res(sr4ptr,mr1ptr);
|
||||||
MultiArray<double,MRange,SRange> res2(mr1ptr,sr4ptr);
|
MultiArray<double,MRange,SRange> res2(mr1ptr,sr4ptr);
|
||||||
|
|
||||||
DMA dma1 = *std::dynamic_pointer_cast<DMA>( dynamic<EC1>( ma1 ) );
|
DMA dma1 = *std::dynamic_pointer_cast<DMA>( dynamic( ma1 ) );
|
||||||
DMA dma2 = *std::dynamic_pointer_cast<DMA>( dynamic<EC1>( ma2 ) );
|
DMA dma2 = *std::dynamic_pointer_cast<DMA>( dynamic( ma2 ) );
|
||||||
DMA dres = *std::dynamic_pointer_cast<DMA>( dynamic<EC1>( res ) );
|
DMA dres = *std::dynamic_pointer_cast<DMA>( dynamic( res ) );
|
||||||
DMA dres2 = *std::dynamic_pointer_cast<DMA>( dynamic<EC1>( res2 ) );
|
DMA dres2 = *std::dynamic_pointer_cast<DMA>( dynamic( res2 ) );
|
||||||
|
|
||||||
auto si2 = MAT::getIndex( sr2ptr );
|
auto si2 = MAT::getIndex( sr2ptr );
|
||||||
auto si3 = MAT::getIndex( sr3ptr );
|
auto si3 = MAT::getIndex( sr3ptr );
|
||||||
|
@ -782,7 +782,7 @@ namespace {
|
||||||
EXPECT_EQ( xround( res.at( mkt('B',mkt('3','a')) ) ), xround( 13.836 + 0.373 ) );
|
EXPECT_EQ( xround( res.at( mkt('B',mkt('3','a')) ) ), xround( 13.836 + 0.373 ) );
|
||||||
EXPECT_EQ( xround( res.at( mkt('B',mkt('3','b')) ) ), xround( 41.339 + 0.373 ) );
|
EXPECT_EQ( xround( res.at( mkt('B',mkt('3','b')) ) ), xround( 41.339 + 0.373 ) );
|
||||||
|
|
||||||
//dres = *std::dynamic_pointer_cast<DMA>( dynamic<EC1>( res ) );
|
//dres = *std::dynamic_pointer_cast<DMA>( dynamic( res ) );
|
||||||
dres2(dir2) = dres(dir);
|
dres2(dir2) = dres(dir);
|
||||||
res2 = dres2.format(mr1ptr,sr4ptr);
|
res2 = dres2.format(mr1ptr,sr4ptr);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue