fix compile errors

This commit is contained in:
Christian Zimmermann 2020-09-10 22:50:26 +02:00
parent 0d045c006d
commit 65ecc27c3e
8 changed files with 225 additions and 105 deletions

View file

@ -302,13 +302,130 @@ namespace MultiArrayTools
#undef regFunc1 #undef regFunc1
#undef SP #undef SP
/*
template <class ROP> template <size_t N>
HighLevelOpHolder<ROP> exp(const HighLevelOpHolder<ROP>& in) template <class ITuple>
inline void SetLInds<N>::mkLIT(const ITuple& itp, const std::shared_ptr<DynamicIndex>& di)
{ {
return HighLevelOpHolder<ROP> constexpr size_t NN = std::tuple_size<ITuple>::value-N-1;
( std::make_shared<HighLevelOp<ROP,x_exp<double>,1>> const size_t nn = di->dim()-N-1;
( std::array<std::shared_ptr<HighLevelOpBase<ROP>>,1>( {in.op()} ) ) ); typedef typename std::remove_reference<decltype(*std::get<NN>(itp))>::type T;
std::get<NN>(itp) =
std::dynamic_pointer_cast<T>(di->get(nn))->getIndex();
SetLInds<N-1>::mkLIT(itp, di);
}
template <size_t N>
template <class Tar, class ITp, typename... Args>
template <class... Is>
inline void SetLInds<N>::xx<Tar,ITp,Args...>::
assign(Tar& tar, const Args&... args, const ITp& itp, const std::shared_ptr<Is>&... is)
{
SetLInds<N-1>::template xx<ITp,Args...>::assign(tar, args..., itp, std::get<N>(itp), is...);
}
template <size_t N>
template <class Tar, class ITp, typename... Args>
template <class... Is>
inline void SetLInds<N>::xx<Tar,ITp,Args...>::
plus(Tar& tar, const Args&... args, const ITp& itp, const std::shared_ptr<Is>&... is)
{
SetLInds<N-1>::template xx<ITp,Args...>::plus(tar, args..., itp, std::get<N>(itp), is...);
}
//template <>
template <class ITuple>
inline void SetLInds<0>::mkLIT(const ITuple& itp, const std::shared_ptr<DynamicIndex>& di)
{
constexpr size_t NN = std::tuple_size<ITuple>::value-1;
const size_t nn = di->dim()-1;
typedef typename std::remove_reference<decltype(*std::get<NN>(itp))>::type T;
std::get<NN>(itp) =
std::dynamic_pointer_cast<T>(di->get(nn))->getIndex();
}
//template <>
template <class Tar, class ITp, typename... Args>
template <class... Is>
inline void SetLInds<0>::xx<Tar,ITp,Args...>::
assign(Tar& tar, const Args&... args, const ITp& itp, const std::shared_ptr<Is>&... is)
{
tar.assign(args..., std::get<0>(itp), is...);
}
//template <>
template <class Tar, class ITp, typename... Args>
template <class... Is>
inline void SetLInds<0>::xx<Tar,ITp,Args...>::
plus(Tar& tar, const Args&... args, const ITp& itp, const std::shared_ptr<Is>&... is)
{
tar.plus(args..., std::get<0>(itp), is...);
}
template <class ROP, class... Indices>
size_t INDS<ROP,Indices...>::CallHLOpBase::depth() const
{
return mDepth;
}
std::shared_ptr<DynamicIndex> mkSubSpaceX(const std::shared_ptr<DynamicIndex>& di,
size_t max)
{
auto& o = di->range()->orig();
vector<std::shared_ptr<RangeBase>> ox(o.begin(),o.begin()+max);
DynamicRangeFactory drf(ox);
auto dr = createExplicit(drf);
auto odi = getIndex(dr);
vector<std::shared_ptr<IndexW>> iv;
iv.reserve(max);
for(size_t i = 0; i != max; ++i){
iv.push_back(di->getP(i));
}
(*odi)(iv);
return odi;
}
template <class ROP, class... Indices>
template <class... LIndices>
void INDS<ROP,Indices...>::CallHLOp<LIndices...>::
assign(HighLevelOpHolder<ROP>& target, const HighLevelOpHolder<ROP>& source,
const std::shared_ptr<Indices>&... is,
const std::shared_ptr<DynamicIndex>& di) const
{
auto ip = di->get(di->dim() - this->depth());
auto iregn = ip->regN();
if(iregn.type >= 0 and iregn.depth > sizeof...(LIndices)){
sNext[iregn.type]->assign(target, source, is..., di);
}
else {
ITuple itp;
SetLInds<sizeof...(LIndices)-1>::mkLIT(itp,di);
auto mi = mkIndex(is...,mkSubSpaceX(di, di->dim() - this->depth()));
SetLInds<sizeof...(LIndices)-1>::
template xx<HighLevelOpHolder<ROP>,ITuple,HighLevelOpHolder<ROP>,decltype(mi)>::
assign(target, source, mi, itp);
}
}
template <class ROP, class... Indices>
template <class... LIndices>
void INDS<ROP,Indices...>::CallHLOp<LIndices...>::
plus(HighLevelOpHolder<ROP>& target, const HighLevelOpHolder<ROP>& source,
const std::shared_ptr<Indices>&... is,
const std::shared_ptr<DynamicIndex>& di) const
{
auto ip = di->get(di->dim() - this->depth());
auto iregn = ip->regN();
if(iregn.type >= 0 and iregn.depth > sizeof...(LIndices)){
sNext[iregn.type]->plus(target, source, is..., di);
}
else {
ITuple itp;
SetLInds<sizeof...(LIndices)-1>::mkLIT(itp,di);
auto mi = mkIndex(is...,mkSubSpaceX(di, di->dim() - this->depth()));
SetLInds<sizeof...(LIndices)-1>::
template xx<HighLevelOpHolder<ROP>,ITuple,HighLevelOpHolder<ROP>,decltype(mi)>::
plus(target, source, mi, itp);
}
} }
*/
} }

View file

@ -174,11 +174,81 @@ namespace MultiArrayTools
#include "extensions/math.h" #include "extensions/math.h"
#undef regFunc1 #undef regFunc1
#undef SP #undef SP
/*
template <class ROP> template <size_t N>
HighLevelOpHolder<ROP> exp(const HighLevelOpHolder<ROP>& in); struct SetLInds
*/ {
template <class ITuple>
static inline void mkLIT(const ITuple& itp, const std::shared_ptr<DynamicIndex>& di);
template <class Tar, class ITp, typename... Args>
struct xx
{
template <class... Is>
static inline void assign(Tar& tar, const Args&... args,
const ITp& itp, const std::shared_ptr<Is>&... is);
template <class... Is>
static inline void plus(Tar& tar, const Args&... args,
const ITp& itp, const std::shared_ptr<Is>&... is);
};
};
template <>
struct SetLInds<0>
{
template <class ITuple>
static inline void mkLIT(const ITuple& itp, const std::shared_ptr<DynamicIndex>& di);
template <class Tar, class ITp, typename... Args>
struct xx
{
template <class... Is>
static inline void assign(Tar& tar, const Args&... args,
const ITp& itp, const std::shared_ptr<Is>&... is);
template <class... Is>
static inline void plus(Tar& tar, const Args&... args,
const ITp& itp, const std::shared_ptr<Is>&... is);
};
};
template <class ROP, class... Indices>
struct INDS
{
class CallHLOpBase
{
private:
size_t mDepth;
public:
size_t depth() const;
void assign(const HighLevelOpHolder<ROP>& target, const HighLevelOpHolder<ROP>& source,
const std::shared_ptr<Indices>&... is,
const std::shared_ptr<DynamicIndex>& di) const = 0;
void plus(const HighLevelOpHolder<ROP>& target, const HighLevelOpHolder<ROP>& source,
const std::shared_ptr<Indices>&... is,
const std::shared_ptr<DynamicIndex>& di) const = 0;
};
template <class... LIndices>
class CallHLOp
{
private:
typedef std::tuple<std::shared_ptr<LIndices>...> ITuple;
static vector<std::shared_ptr<CallHLOpBase>> sNext;
public:
void assign(HighLevelOpHolder<ROP>& target, const HighLevelOpHolder<ROP>& source,
const std::shared_ptr<Indices>&... is,
const std::shared_ptr<DynamicIndex>& di) const override final;
void plus(HighLevelOpHolder<ROP>& target, const HighLevelOpHolder<ROP>& source,
const std::shared_ptr<Indices>&... is,
const std::shared_ptr<DynamicIndex>& di) const override final;
};
};
} }
#endif #endif

View file

@ -2,6 +2,8 @@
#ifndef __hl_reg_ind_h__ #ifndef __hl_reg_ind_h__
#define __hl_reg_ind_h__ #define __hl_reg_ind_h__
#include "ranges/rheader.h"
namespace MultiArrayTools namespace MultiArrayTools
{ {
@ -30,101 +32,9 @@ namespace MultiArrayTools
{ {
type = RegIndNum<Index>::VALUE; type = RegIndNum<Index>::VALUE;
depth = RegIndNum<Index>::DEPTH; depth = RegIndNum<Index>::DEPTH;
return *this;
} }
}; };
template <size_t N>
struct SetLInds
{
template <class Tar, class ITp, typename... Args>
struct xx
{
template <class... Is>
static inline void assign(Tar& tar, const Args&... args, const ITp& itp, const std::shared_ptr<Is>&... is)
{
SetLInds<N-1>::template xx<ITp,Args...>::assign(tar, args..., itp, std::get<N>(itp), is...);
}
template <class... Is>
static inline void plus(Tar& tar, const Args&... args, const ITp& itp, const std::shared_ptr<Is>&... is)
{
SetLInds<N-1>::template xx<ITp,Args...>::plus(tar, args..., itp, std::get<N>(itp), is...);
}
};
};
template <>
struct SetLInds<0>
{
template <class ITp, typename... Args>
struct xx
{
template <class... Is>
static inline void assign(Tar& tar, const Args&... args, const ITp& itp, const std::shared_ptr<Is>&... is)
{
tar.assign(args..., std::get<0>(itp), is...);
}
template <class... Is>
static inline void plus(Tar& tar, const Args&... args, const ITp& itp, const std::shared_ptr<Is>&... is)
{
tar.plus(args..., std::get<0>(itp), is...);
}
};
};
template <class... Indices>
struct INDS
{
class CallHLOpBase
{
private:
size_t mDepth;
public:
void assign(const HighLevelOpHolder& target, const HighLevelOpHolder& source,
const std::shared_ptr<Indices>&... is,
const std::shared_ptr<DynamicIndex>& di) const = 0;
void plus(const HighLevelOpHolder& target, const HighLevelOpHolder& source,
const std::shared_ptr<Indices>&... is,
const std::shared_ptr<DynamicIndex>& di) const = 0;
};
template <class... LIndices>
class CallHLOp
{
private:
typedef std::tuple<std::shared_ptr<LIndices>...> ITuple;
static vector<std::shared_ptr<CallHLOpBase>> sNext;
public:
void assign(HighLevelOpHolder& target, const HighLevelOpHolder& source,
const std::shared_ptr<Indices>&... is,
const std::shared_ptr<DynamicIndex>& di) const override final
{
auto ip = di->get(di->dim()-mDepth);
auto iregn = ip->regN();
if(iregn.type >= 0 and iregn.depth > sizeof...(LIndices)){
sCall[iregn.type]->assign(target, source, is..., di);
}
else {
auto mi = mkIndex(is...,di->subSpaceI(0, di->dim()-mDepth));
SetLInds<sizeof...(LIndices)-1>::
template xx<HighLevelOpHolder,ITuple,HighLevelOpHolder,decltype(mi)>::
assign(target, source, mi,
SetLInds<sizeof...(LIndices)-1>::template mkLIT<LIndices...>(di));
}
}
void plus(HighLevelOpHolder& target, const HighLevelOpHolder& source,
const std::shared_ptr<Indices>&... is,
const std::shared_ptr<DynamicIndex>& di) const override final
{
auto mi = mkIndex(is...,di);
SetLInds::template xx<HighLevelOpHolder,ITuple,HighLevelOpHolder,decltype(mi)>::plus
(target, source, mi, mLInds);
}
};
};
} }
#endif #endif

View file

@ -92,6 +92,7 @@ namespace MultiArrayTools
bool first() const; bool first() const;
const IndexW& get(size_t n) const; const IndexW& get(size_t n) const;
const std::shared_ptr<IndexW>& getP(size_t n) const;
std::shared_ptr<RangeType> range(); std::shared_ptr<RangeType> range();

View file

@ -144,6 +144,13 @@ namespace MultiArrayTools
return std::make_shared<IndexWrapper>( std::make_shared<Index>( *mI ) ); return std::make_shared<IndexWrapper>( std::make_shared<Index>( *mI ) );
} }
template <class Index>
RegIndInfo IndexWrapper<Index>::regN() const
{
RegIndInfo out;
return out.set(mI);
}
template <class Index> template <class Index>
inline std::shared_ptr<IndexWrapperBase> mkIndexWrapper(const Index& i) inline std::shared_ptr<IndexWrapperBase> mkIndexWrapper(const Index& i)
{ {

View file

@ -4,6 +4,7 @@
#include "ranges/rbase_def.h" #include "ranges/rbase_def.h"
#include "xfor/xfor.h" #include "xfor/xfor.h"
#include "hl_reg_ind.h"
namespace MultiArrayTools namespace MultiArrayTools
{ {
@ -48,7 +49,8 @@ namespace MultiArrayTools
virtual std::intptr_t ptrNum() const = 0; virtual std::intptr_t ptrNum() const = 0;
virtual std::shared_ptr<IndexWrapperBase> duplicate() const = 0; virtual std::shared_ptr<IndexWrapperBase> duplicate() const = 0;
virtual RegIndInfo regN() const = 0;
//virtual DynamicMetaT meta() const = 0; //virtual DynamicMetaT meta() const = 0;
//virtual const DynamicMetaT* metaPtr() const = 0; //virtual const DynamicMetaT* metaPtr() const = 0;
//virtual AbstractIW& at(const U& metaPos) = 0; //virtual AbstractIW& at(const U& metaPos) = 0;
@ -134,6 +136,7 @@ namespace MultiArrayTools
virtual DynamicExpression iforh(size_t step, DynamicExpression ex) const override final; virtual DynamicExpression iforh(size_t step, DynamicExpression ex) const override final;
virtual std::shared_ptr<IndexWrapperBase> duplicate() const override final; virtual std::shared_ptr<IndexWrapperBase> duplicate() const override final;
virtual RegIndInfo regN() const override final;
std::shared_ptr<Index> getIndex() const { return mI; } std::shared_ptr<Index> getIndex() const { return mI; }

View file

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

View file

@ -268,6 +268,11 @@ namespace MultiArrayTools
return *mIVec[n].first; return *mIVec[n].first;
} }
const std::shared_ptr<IndexW>& DynamicIndex::getP(size_t n) const
{
assert(mIvecInit);
return mIVec[n].first;
}
std::shared_ptr<typename DynamicIndex::RangeType> DynamicIndex::range() std::shared_ptr<typename DynamicIndex::RangeType> DynamicIndex::range()
{ {