some fixes / utility extensions regarding extarnal usage/linking
This commit is contained in:
parent
e4a34ba644
commit
69e4e4bf8e
5 changed files with 74 additions and 25 deletions
|
@ -75,10 +75,10 @@ namespace MultiArrayTools
|
||||||
std::shared_ptr<EC> makeec(const std::shared_ptr<Index>& i);
|
std::shared_ptr<EC> makeec(const std::shared_ptr<Index>& i);
|
||||||
|
|
||||||
#define V_IFOR_X(Expr) \
|
#define V_IFOR_X(Expr) \
|
||||||
virtual ExpressionHolder<Expr> iforx(size_t step, ExpressionHolder<Expr> ex) const = 0; \
|
virtual MultiArrayTools::ExpressionHolder<Expr> iforx(size_t step, MultiArrayTools::ExpressionHolder<Expr> ex) const = 0; \
|
||||||
virtual ExpressionHolder<Expr> iforhx(size_t step, ExpressionHolder<Expr> ex) const = 0; \
|
virtual MultiArrayTools::ExpressionHolder<Expr> iforhx(size_t step, MultiArrayTools::ExpressionHolder<Expr> ex) const = 0; \
|
||||||
virtual ExpressionHolder<Expr> iforxi(size_t step, Expr ex) const = 0; \
|
virtual MultiArrayTools::ExpressionHolder<Expr> iforxi(size_t step, Expr ex) const = 0; \
|
||||||
virtual ExpressionHolder<Expr> iforhxi(size_t step, Expr ex) const = 0
|
virtual MultiArrayTools::ExpressionHolder<Expr> iforhxi(size_t step, Expr ex) const = 0
|
||||||
|
|
||||||
#define V_IFOR_A(EC,OpF) \
|
#define V_IFOR_A(EC,OpF) \
|
||||||
V_IFOR_X(AEX_B_MM<EC XCOMMAX() OpF>); \
|
V_IFOR_X(AEX_B_MM<EC XCOMMAX() OpF>); \
|
||||||
|
@ -103,36 +103,36 @@ namespace MultiArrayTools
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
V_IFOR_A(EX,plus);
|
V_IFOR_A(EX,MultiArrayTools::plus);
|
||||||
V_IFOR_A(EX,minus);
|
V_IFOR_A(EX,MultiArrayTools::minus);
|
||||||
V_IFOR_A(EX,multiplies);
|
V_IFOR_A(EX,MultiArrayTools::multiplies);
|
||||||
V_IFOR_A(EX,divides);
|
V_IFOR_A(EX,MultiArrayTools::divides);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
template <class Expr>
|
template <class Expr>
|
||||||
inline ExpressionHolder<Expr> ifor(size_t step, ExpressionHolder<Expr> ex) const;
|
inline MultiArrayTools::ExpressionHolder<Expr> ifor(size_t step, MultiArrayTools::ExpressionHolder<Expr> ex) const;
|
||||||
|
|
||||||
template <class Expr>
|
template <class Expr>
|
||||||
inline ExpressionHolder<Expr> iforh(size_t step, ExpressionHolder<Expr> ex) const;
|
inline MultiArrayTools::ExpressionHolder<Expr> iforh(size_t step, MultiArrayTools::ExpressionHolder<Expr> ex) const;
|
||||||
|
|
||||||
template <class Expr>
|
template <class Expr>
|
||||||
inline ExpressionHolder<Expr> ifori(size_t step, Expr ex) const;
|
inline MultiArrayTools::ExpressionHolder<Expr> ifori(size_t step, Expr ex) const;
|
||||||
|
|
||||||
template <class Expr>
|
template <class Expr>
|
||||||
inline ExpressionHolder<Expr> iforhi(size_t step, Expr ex) const;
|
inline MultiArrayTools::ExpressionHolder<Expr> iforhi(size_t step, Expr ex) const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#define D_IFOR_X(Expr,Ind) \
|
#define D_IFOR_X(Expr,Ind) \
|
||||||
ExpressionHolder<Expr> iforx(size_t step, ExpressionHolder<Expr> ex) const \
|
MultiArrayTools::ExpressionHolder<Expr> iforx(size_t step, MultiArrayTools::ExpressionHolder<Expr> ex) const \
|
||||||
{ return ExpressionHolder<Expr>(Ind->ifor(step, ex)); } \
|
{ return MultiArrayTools::ExpressionHolder<Expr>(Ind->ifor(step, ex)); } \
|
||||||
ExpressionHolder<Expr> iforhx(size_t step, ExpressionHolder<Expr> ex) const \
|
MultiArrayTools::ExpressionHolder<Expr> iforhx(size_t step, MultiArrayTools::ExpressionHolder<Expr> ex) const \
|
||||||
{ return ExpressionHolder<Expr>(Ind->iforh(step, ex)); } \
|
{ return MultiArrayTools::ExpressionHolder<Expr>(Ind->iforh(step, ex)); } \
|
||||||
ExpressionHolder<Expr> iforxi(size_t step, Expr ex) const \
|
MultiArrayTools::ExpressionHolder<Expr> iforxi(size_t step, Expr ex) const \
|
||||||
{ return ExpressionHolder<Expr>(Ind->ifor(step, ex)); } \
|
{ return MultiArrayTools::ExpressionHolder<Expr>(Ind->ifor(step, ex)); } \
|
||||||
ExpressionHolder<Expr> iforhxi(size_t step, Expr ex) const \
|
MultiArrayTools::ExpressionHolder<Expr> iforhxi(size_t step, Expr ex) const \
|
||||||
{ return ExpressionHolder<Expr>(Ind->iforh(step, ex)); }
|
{ return MultiArrayTools::ExpressionHolder<Expr>(Ind->iforh(step, ex)); }
|
||||||
|
|
||||||
#define D_IFOR_A(EC,OpF,Ind) \
|
#define D_IFOR_A(EC,OpF,Ind) \
|
||||||
D_IFOR_X(AEX_B_MM<EC XCOMMAX() OpF>,Ind); \
|
D_IFOR_X(AEX_B_MM<EC XCOMMAX() OpF>,Ind); \
|
||||||
|
@ -151,10 +151,10 @@ namespace MultiArrayTools
|
||||||
|
|
||||||
std::shared_ptr<Index> mI;
|
std::shared_ptr<Index> mI;
|
||||||
|
|
||||||
D_IFOR_A(EX,plus,mI);
|
D_IFOR_A(EX,MultiArrayTools::plus,mI);
|
||||||
D_IFOR_A(EX,minus,mI);
|
D_IFOR_A(EX,MultiArrayTools::minus,mI);
|
||||||
D_IFOR_A(EX,multiplies,mI);
|
D_IFOR_A(EX,MultiArrayTools::multiplies,mI);
|
||||||
D_IFOR_A(EX,divides,mI);
|
D_IFOR_A(EX,MultiArrayTools::divides,mI);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
E1(const E1& in) = default;
|
E1(const E1& in) = default;
|
||||||
|
|
|
@ -88,6 +88,8 @@ namespace MultiArrayTools
|
||||||
template <class... Ranges>
|
template <class... Ranges>
|
||||||
std::shared_ptr<MultiRange<Ranges...> > scast(SIZET<Ranges>... sizes) const; // save cast
|
std::shared_ptr<MultiRange<Ranges...> > scast(SIZET<Ranges>... sizes) const; // save cast
|
||||||
|
|
||||||
|
const std::vector<std::shared_ptr<RangeBase> >& orig() const;
|
||||||
|
|
||||||
void sreplace(const std::shared_ptr<RangeBase> in, size_t num);
|
void sreplace(const std::shared_ptr<RangeBase> in, size_t num);
|
||||||
|
|
||||||
bool isEmpty() const;
|
bool isEmpty() const;
|
||||||
|
|
|
@ -71,6 +71,12 @@ namespace MultiArrayTools
|
||||||
mProd = std::shared_ptr<oType>( new DynamicRange<EC>( origs... ) );
|
mProd = std::shared_ptr<oType>( new DynamicRange<EC>( origs... ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <class EC>
|
||||||
|
DynamicRangeFactory<EC>::DynamicRangeFactory(const std::vector<std::shared_ptr<RangeBase>>& origs)
|
||||||
|
{
|
||||||
|
mProd = std::shared_ptr<oType>( new DynamicRange<EC>( origs ) );
|
||||||
|
}
|
||||||
|
|
||||||
template <class EC>
|
template <class EC>
|
||||||
template <class Range>
|
template <class Range>
|
||||||
void DynamicRangeFactory<EC>::append(std::shared_ptr<Range> r)
|
void DynamicRangeFactory<EC>::append(std::shared_ptr<Range> r)
|
||||||
|
@ -202,6 +208,16 @@ namespace MultiArrayTools
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <class EC>
|
||||||
|
DynamicIndex<EC>& DynamicIndex<EC>::operator()(const std::vector<std::shared_ptr<IndexW<EC>>>& ivec)
|
||||||
|
{
|
||||||
|
assert(mIVec.size() == ivec.size());
|
||||||
|
for(size_t i = 0; i != mIVec.size(); ++i){
|
||||||
|
mIVec[i].first = ivec[i];
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
template <class EC>
|
template <class EC>
|
||||||
template <class... Indices>
|
template <class... Indices>
|
||||||
DynamicIndex<EC>& DynamicIndex<EC>::operator()(const std::shared_ptr<Indices>&... is)
|
DynamicIndex<EC>& DynamicIndex<EC>::operator()(const std::shared_ptr<Indices>&... is)
|
||||||
|
@ -515,6 +531,20 @@ namespace MultiArrayTools
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <class EC>
|
||||||
|
DynamicRange<EC>::DynamicRange(const std::vector<std::shared_ptr<RangeBase>>& origs) :
|
||||||
|
RangeInterface<DynamicIndex<EC>>(),
|
||||||
|
mOrig(origs)
|
||||||
|
{
|
||||||
|
mSize = 1;
|
||||||
|
for(auto& x: mOrig){
|
||||||
|
mSize *= x->size();
|
||||||
|
}
|
||||||
|
if(mOrig.size()){
|
||||||
|
mEmpty = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
template <class EC>
|
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<EC>::fullsub(size_t num) const
|
||||||
|
@ -532,5 +562,10 @@ namespace MultiArrayTools
|
||||||
return std::dynamic_pointer_cast<MultiRange<Ranges...> >( mrf.create() );
|
return std::dynamic_pointer_cast<MultiRange<Ranges...> >( mrf.create() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <class EC>
|
||||||
|
const std::vector<std::shared_ptr<RangeBase> >& DynamicRange<EC>::orig() const
|
||||||
|
{
|
||||||
|
return mOrig;
|
||||||
|
}
|
||||||
|
|
||||||
} // end namespace MultiArrayTools
|
} // end namespace MultiArrayTools
|
||||||
|
|
|
@ -177,6 +177,7 @@ namespace MultiArrayTools
|
||||||
DynamicIndex& operator--();
|
DynamicIndex& operator--();
|
||||||
|
|
||||||
DynamicIndex& operator()(const IVecT& ivec);
|
DynamicIndex& operator()(const IVecT& ivec);
|
||||||
|
DynamicIndex& operator()(const std::vector<std::shared_ptr<IndexW<EC>>>& ivec);
|
||||||
|
|
||||||
template <class... Indices>
|
template <class... Indices>
|
||||||
DynamicIndex& operator()(const std::shared_ptr<Indices>&... is);
|
DynamicIndex& operator()(const std::shared_ptr<Indices>&... is);
|
||||||
|
@ -233,6 +234,8 @@ namespace MultiArrayTools
|
||||||
template <class... RangeTypes>
|
template <class... RangeTypes>
|
||||||
DynamicRangeFactory(std::shared_ptr<RangeTypes>... origs);
|
DynamicRangeFactory(std::shared_ptr<RangeTypes>... origs);
|
||||||
|
|
||||||
|
DynamicRangeFactory(const std::vector<std::shared_ptr<RangeBase>>& origs);
|
||||||
|
|
||||||
template <class Range>
|
template <class Range>
|
||||||
void append(std::shared_ptr<Range> r);
|
void append(std::shared_ptr<Range> r);
|
||||||
|
|
||||||
|
@ -271,6 +274,8 @@ namespace MultiArrayTools
|
||||||
template <class... RangeTypes>
|
template <class... RangeTypes>
|
||||||
DynamicRange(std::shared_ptr<RangeTypes>... origs);
|
DynamicRange(std::shared_ptr<RangeTypes>... origs);
|
||||||
|
|
||||||
|
DynamicRange(const std::vector<std::shared_ptr<RangeBase>>& origs);
|
||||||
|
|
||||||
size_t mSize = 1;
|
size_t mSize = 1;
|
||||||
bool mEmpty = true;
|
bool mEmpty = true;
|
||||||
|
|
||||||
|
@ -299,6 +304,8 @@ namespace MultiArrayTools
|
||||||
template <class... Ranges>
|
template <class... Ranges>
|
||||||
std::shared_ptr<MultiRange<Ranges...> > scast(SIZET<Ranges>... sizes) const; // save cast
|
std::shared_ptr<MultiRange<Ranges...> > scast(SIZET<Ranges>... sizes) const; // save cast
|
||||||
|
|
||||||
|
const std::vector<std::shared_ptr<RangeBase> >& orig() const;
|
||||||
|
|
||||||
void sreplace(const std::shared_ptr<RangeBase> in, size_t num);
|
void sreplace(const std::shared_ptr<RangeBase> in, size_t num);
|
||||||
|
|
||||||
bool isEmpty() const;
|
bool isEmpty() const;
|
||||||
|
|
|
@ -153,6 +153,11 @@ namespace MultiArrayTools
|
||||||
mOrig[num] = in;
|
mOrig[num] = in;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const std::vector<std::shared_ptr<RangeBase> >& AnonymousRange::orig() const
|
||||||
|
{
|
||||||
|
return mOrig;
|
||||||
|
}
|
||||||
|
|
||||||
/*****************
|
/*****************
|
||||||
* Functions *
|
* Functions *
|
||||||
*****************/
|
*****************/
|
||||||
|
|
Loading…
Reference in a new issue