2020-09-03 10:52:31 +02:00
|
|
|
|
2021-07-28 20:59:31 +02:00
|
|
|
#ifndef __cxz_high_level_operation_h__
|
|
|
|
#define __cxz_high_level_operation_h__
|
2020-09-03 10:52:31 +02:00
|
|
|
|
|
|
|
#include "base_def.h"
|
|
|
|
#include "ranges/rheader.h"
|
|
|
|
#include "dynamic_operation.h"
|
|
|
|
|
2021-07-28 20:29:56 +02:00
|
|
|
namespace CNORXZ
|
2020-09-03 10:52:31 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
typedef ClassicRange CR;
|
|
|
|
typedef CR::IndexType CI;
|
|
|
|
typedef std::shared_ptr<CI> CIP;
|
|
|
|
|
2020-09-16 20:19:21 +02:00
|
|
|
typedef OperationRoot<double,CR,DynamicRange> OpCD;
|
|
|
|
typedef OperationRoot<double,DynamicRange> OpD;
|
|
|
|
extern template class OperationRoot<double,CR,DynamicRange>;
|
|
|
|
extern template class OperationRoot<double,DynamicRange>;
|
|
|
|
|
2020-09-03 10:52:31 +02:00
|
|
|
template <typename T, class Op>
|
|
|
|
DynamicO<T> mkDynOp1(const Op& op);
|
|
|
|
|
2020-09-11 13:12:37 +02:00
|
|
|
std::shared_ptr<DynamicIndex> mkSubSpaceX(const std::shared_ptr<DynamicIndex>& di, size_t max);
|
|
|
|
|
2020-09-03 10:52:31 +02:00
|
|
|
template <class ROP>
|
|
|
|
class HighLevelOpBase
|
|
|
|
{
|
|
|
|
public:
|
2020-09-20 13:37:44 +02:00
|
|
|
|
|
|
|
typedef OperationValue<double> VOP;
|
|
|
|
|
2020-09-03 10:52:31 +02:00
|
|
|
template <class... Indices>
|
|
|
|
struct RetT
|
|
|
|
{
|
|
|
|
DynamicO<OpH<OperationRoot<double,typename Indices::RangeType...>>> op;
|
|
|
|
DynamicO<size_t> outer;
|
|
|
|
|
|
|
|
template <class Op, class... Ops>
|
|
|
|
void appendOuterM(const Op& op, const Ops&... ops);
|
|
|
|
|
|
|
|
void appendOuterM();
|
|
|
|
void appendOuter(const DynamicO<size_t>& in);
|
|
|
|
void appendOuter(const RetT& in);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
virtual bool root() const = 0;
|
2020-09-10 13:27:24 +02:00
|
|
|
|
|
|
|
#define reg_ind1(I1) virtual RetT<I1> create \
|
|
|
|
(const std::shared_ptr<I1>& ind1) = 0
|
|
|
|
#define reg_ind2(I1,I2) virtual RetT<I1,I2> create \
|
|
|
|
(const std::shared_ptr<I1>& ind1,const std::shared_ptr<I2>& ind2) = 0
|
|
|
|
#define reg_ind3(I1,I2,I3) virtual RetT<I1,I2,I3> create \
|
|
|
|
(const std::shared_ptr<I1>& ind1,const std::shared_ptr<I2>& ind2,const std::shared_ptr<I3>& ind3) = 0
|
|
|
|
|
2021-06-11 18:57:00 +02:00
|
|
|
//#include "hl_reg_ind.h"
|
|
|
|
reg_ind1(ClassicRange::IndexType);
|
|
|
|
reg_ind2(ClassicRange::IndexType,ClassicRange::IndexType);
|
|
|
|
reg_ind3(ClassicRange::IndexType,ClassicRange::IndexType,ClassicRange::IndexType);
|
2020-09-10 13:27:24 +02:00
|
|
|
|
|
|
|
#undef reg_ind1
|
|
|
|
#undef reg_ind2
|
|
|
|
#undef reg_ind3
|
2020-09-03 10:52:31 +02:00
|
|
|
|
2020-09-16 00:09:55 +02:00
|
|
|
virtual ROP* get() = 0;
|
2020-09-20 13:37:44 +02:00
|
|
|
virtual VOP* vget() = 0;
|
|
|
|
|
2020-09-03 10:52:31 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
template <class ROP>
|
|
|
|
class HighLevelOpRoot : public HighLevelOpBase<ROP>
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
typedef HighLevelOpBase<ROP> B;
|
2020-09-20 13:37:44 +02:00
|
|
|
typedef typename B::VOP VOP;
|
|
|
|
|
2020-09-09 10:12:20 +02:00
|
|
|
template <class... Inds>
|
|
|
|
typename B::template RetT<Inds...> xcreate(const std::shared_ptr<Inds>&... inds);
|
2020-09-03 10:52:31 +02:00
|
|
|
|
|
|
|
ROP mOp;
|
|
|
|
public:
|
|
|
|
|
|
|
|
HighLevelOpRoot(const ROP& op);
|
|
|
|
|
|
|
|
virtual bool root() const override final;
|
|
|
|
|
2020-09-10 13:27:24 +02:00
|
|
|
#define reg_ind1(I1) virtual typename B::template RetT<I1> create \
|
|
|
|
(const std::shared_ptr<I1>& ind1) \
|
|
|
|
override final { return xcreate(ind1); }
|
|
|
|
#define reg_ind2(I1,I2) virtual typename B::template RetT<I1,I2> create \
|
|
|
|
(const std::shared_ptr<I1>& ind1, const std::shared_ptr<I2>& ind2) \
|
|
|
|
override final { return xcreate(ind1,ind2); }
|
|
|
|
#define reg_ind3(I1,I2,I3) virtual typename B::template RetT<I1,I2,I3> create \
|
|
|
|
(const std::shared_ptr<I1>& ind1, const std::shared_ptr<I2>& ind2, const std::shared_ptr<I3>& ind3) \
|
|
|
|
override final { return xcreate(ind1,ind2,ind3); }
|
|
|
|
|
2021-06-11 18:57:00 +02:00
|
|
|
//#include "hl_reg_ind.h"
|
|
|
|
reg_ind1(ClassicRange::IndexType);
|
|
|
|
reg_ind2(ClassicRange::IndexType,ClassicRange::IndexType);
|
|
|
|
reg_ind3(ClassicRange::IndexType,ClassicRange::IndexType,ClassicRange::IndexType);
|
2020-09-03 10:52:31 +02:00
|
|
|
|
2020-09-16 00:09:55 +02:00
|
|
|
virtual ROP* get() override final;
|
2020-09-20 13:37:44 +02:00
|
|
|
virtual VOP* vget() override final;
|
2020-09-03 10:52:31 +02:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2020-09-16 20:19:21 +02:00
|
|
|
extern template class HighLevelOpBase<OpCD>;
|
|
|
|
extern template class HighLevelOpBase<OpD>;
|
|
|
|
extern template class HighLevelOpRoot<OpCD>;
|
|
|
|
extern template class HighLevelOpRoot<OpD>;
|
2020-09-20 13:37:44 +02:00
|
|
|
|
|
|
|
template <class ROP>
|
|
|
|
class HighLevelOpValue : public HighLevelOpBase<ROP>
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
typedef HighLevelOpBase<ROP> B;
|
|
|
|
typedef typename B::VOP VOP;
|
|
|
|
|
|
|
|
template <class... Inds>
|
|
|
|
typename B::template RetT<Inds...> xcreate(const std::shared_ptr<Inds>&... inds);
|
|
|
|
|
|
|
|
VOP mOp;
|
|
|
|
public:
|
|
|
|
|
|
|
|
HighLevelOpValue(const VOP& vop);
|
|
|
|
|
|
|
|
virtual bool root() const override final;
|
|
|
|
|
2021-06-11 18:57:00 +02:00
|
|
|
//#include "hl_reg_ind.h"
|
|
|
|
reg_ind1(ClassicRange::IndexType);
|
|
|
|
reg_ind2(ClassicRange::IndexType,ClassicRange::IndexType);
|
|
|
|
reg_ind3(ClassicRange::IndexType,ClassicRange::IndexType,ClassicRange::IndexType);
|
2020-09-20 13:37:44 +02:00
|
|
|
|
|
|
|
virtual ROP* get() override final;
|
|
|
|
virtual VOP* vget() override final;
|
|
|
|
|
|
|
|
};
|
2020-09-16 20:19:21 +02:00
|
|
|
|
2020-09-03 10:52:31 +02:00
|
|
|
template <class OpF, class... Ops>
|
|
|
|
auto mkFOp(const Ops&... ops)
|
|
|
|
{
|
|
|
|
return Operation<double,OpF,Ops...>(ops...);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template <class ROP, class OpF, size_t N>
|
|
|
|
class HighLevelOp : public HighLevelOpBase<ROP>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef HighLevelOpBase<ROP> B;
|
2020-09-20 13:37:44 +02:00
|
|
|
typedef typename B::VOP VOP;
|
2020-09-03 10:52:31 +02:00
|
|
|
|
2020-09-09 10:12:20 +02:00
|
|
|
private:
|
|
|
|
std::array<std::shared_ptr<HighLevelOpBase<ROP>>,N> mIn;
|
|
|
|
|
|
|
|
template <class... Inds>
|
|
|
|
auto xcreate(const std::shared_ptr<Inds>&... inds)
|
|
|
|
-> typename B::template RetT<Inds...>;
|
|
|
|
|
|
|
|
public:
|
2020-09-03 10:52:31 +02:00
|
|
|
HighLevelOp(std::array<std::shared_ptr<HighLevelOpBase<ROP>>,N> in);
|
|
|
|
|
|
|
|
virtual bool root() const override final;
|
|
|
|
|
2020-09-16 00:09:55 +02:00
|
|
|
virtual ROP* get() override final;
|
2020-09-20 13:37:44 +02:00
|
|
|
virtual VOP* vget() override final;
|
2020-09-03 10:52:31 +02:00
|
|
|
|
2021-06-11 18:57:00 +02:00
|
|
|
//#include "hl_reg_ind.h"
|
|
|
|
reg_ind1(ClassicRange::IndexType);
|
|
|
|
reg_ind2(ClassicRange::IndexType,ClassicRange::IndexType);
|
|
|
|
reg_ind3(ClassicRange::IndexType,ClassicRange::IndexType,ClassicRange::IndexType);
|
2020-09-10 13:27:24 +02:00
|
|
|
|
|
|
|
#undef reg_ind1
|
|
|
|
#undef reg_ind2
|
|
|
|
#undef reg_ind3
|
2020-09-03 10:52:31 +02:00
|
|
|
};
|
|
|
|
|
2020-09-16 20:19:21 +02:00
|
|
|
extern template class HighLevelOp<OpCD,plusx<double,double>,2>;
|
|
|
|
extern template class HighLevelOp<OpCD,minusx<double,double>,2>;
|
|
|
|
extern template class HighLevelOp<OpCD,multipliesx<double,double>,2>;
|
|
|
|
extern template class HighLevelOp<OpCD,dividesx<double,double>,2>;
|
|
|
|
extern template class HighLevelOp<OpD,plusx<double,double>,2>;
|
|
|
|
extern template class HighLevelOp<OpD,minusx<double,double>,2>;
|
|
|
|
extern template class HighLevelOp<OpD,multipliesx<double,double>,2>;
|
|
|
|
extern template class HighLevelOp<OpD,dividesx<double,double>,2>;
|
|
|
|
|
|
|
|
#define regFunc1(fff) \
|
|
|
|
extern template class HighLevelOp<OpCD,x_##fff<double>,1>; \
|
|
|
|
extern template class HighLevelOp<OpD,x_##fff<double>,1>;
|
|
|
|
#include "extensions/math.h"
|
|
|
|
#undef regFunc1
|
|
|
|
|
2020-09-03 10:52:31 +02:00
|
|
|
template <class ROP>
|
|
|
|
class HighLevelOpHolder
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
std::shared_ptr<HighLevelOpBase<ROP>> mOp;
|
|
|
|
|
|
|
|
public:
|
|
|
|
HighLevelOpHolder() = default;
|
|
|
|
HighLevelOpHolder(const HighLevelOpHolder& in) = default;
|
|
|
|
HighLevelOpHolder(HighLevelOpHolder&& in) = default;
|
|
|
|
HighLevelOpHolder& operator=(const HighLevelOpHolder& in) = default;
|
|
|
|
HighLevelOpHolder& operator=(HighLevelOpHolder&& in) = default;
|
|
|
|
|
|
|
|
HighLevelOpHolder(const std::shared_ptr<HighLevelOpBase<ROP>>& op);
|
|
|
|
|
|
|
|
bool root() const;
|
2020-09-09 10:12:20 +02:00
|
|
|
|
|
|
|
template <class... Inds>
|
|
|
|
auto create(const std::shared_ptr<Inds>&... inds) const
|
|
|
|
-> decltype(mOp->create(inds...));
|
2020-09-03 10:52:31 +02:00
|
|
|
|
2020-09-16 00:09:55 +02:00
|
|
|
auto get() -> decltype(mOp->get());
|
2020-09-03 10:52:31 +02:00
|
|
|
|
|
|
|
std::shared_ptr<HighLevelOpBase<ROP>> op() const;
|
|
|
|
HighLevelOpHolder operator*(const HighLevelOpHolder& in) const;
|
|
|
|
HighLevelOpHolder operator+(const HighLevelOpHolder& in) const;
|
|
|
|
HighLevelOpHolder operator-(const HighLevelOpHolder& in) const;
|
|
|
|
HighLevelOpHolder operator/(const HighLevelOpHolder& in) const;
|
|
|
|
|
2020-09-14 16:30:42 +02:00
|
|
|
|
2020-09-11 13:12:37 +02:00
|
|
|
template <class... Indices>
|
|
|
|
HighLevelOpHolder& xassign(const HighLevelOpHolder& in,
|
|
|
|
const std::shared_ptr<DynamicIndex>& di,
|
|
|
|
const std::shared_ptr<Indices>&... is);
|
|
|
|
|
2020-09-16 20:19:21 +02:00
|
|
|
template <class... Indices>
|
|
|
|
HighLevelOpHolder& xplus(const HighLevelOpHolder& in,
|
|
|
|
const std::shared_ptr<DynamicIndex>& di,
|
|
|
|
const std::shared_ptr<Indices>&... is);
|
|
|
|
|
2020-09-03 10:52:31 +02:00
|
|
|
template <class MIndex, class... Indices>
|
|
|
|
HighLevelOpHolder& assign(const HighLevelOpHolder& in,
|
|
|
|
const std::shared_ptr<MIndex>& mi,
|
|
|
|
const std::shared_ptr<Indices>&... inds);
|
|
|
|
|
|
|
|
template <class MIndex, class... Indices>
|
|
|
|
HighLevelOpHolder& plus(const HighLevelOpHolder& in,
|
|
|
|
const std::shared_ptr<MIndex>& mi,
|
|
|
|
const std::shared_ptr<Indices>&... inds);
|
|
|
|
};
|
|
|
|
|
2020-09-16 20:19:21 +02:00
|
|
|
extern template class HighLevelOpHolder<OpCD>;
|
|
|
|
extern template class HighLevelOpHolder<OpD>;
|
|
|
|
|
2020-09-14 16:30:42 +02:00
|
|
|
template <class F, class ROP, class... ROPs>
|
|
|
|
HighLevelOpHolder<ROP> mkSFunc(const HighLevelOpHolder<ROP>& a, const HighLevelOpHolder<ROPs>&... as);
|
|
|
|
|
2020-09-03 10:52:31 +02:00
|
|
|
|
|
|
|
template <class ROP>
|
|
|
|
HighLevelOpHolder<ROP> mkHLO(const ROP& op);
|
|
|
|
|
2020-09-20 13:37:44 +02:00
|
|
|
template <class ROP>
|
|
|
|
HighLevelOpHolder<ROP> mkHLOV(double val);
|
|
|
|
|
|
|
|
extern template HighLevelOpHolder<OpCD> mkHLO(const OpCD& op);
|
|
|
|
extern template HighLevelOpHolder<OpD> mkHLO(const OpD& op);
|
|
|
|
extern template HighLevelOpHolder<OpCD> mkHLOV(double val);
|
|
|
|
extern template HighLevelOpHolder<OpD> mkHLOV(double val);
|
|
|
|
|
2020-09-03 12:15:51 +02:00
|
|
|
#define regFunc1(fff) template <class ROP> \
|
|
|
|
HighLevelOpHolder<ROP> hl_##fff (const HighLevelOpHolder<ROP>& in);
|
|
|
|
#include "extensions/math.h"
|
|
|
|
#undef regFunc1
|
2020-09-03 10:52:31 +02:00
|
|
|
|
2020-09-16 20:19:21 +02:00
|
|
|
#define regFunc1(fff) template <class ROP> \
|
|
|
|
HighLevelOpHolder<ROP> hl_##fff (const HighLevelOpHolder<ROP>& in); \
|
|
|
|
extern template HighLevelOpHolder<OpCD> hl_##fff (const HighLevelOpHolder<OpCD>& in); \
|
|
|
|
extern template HighLevelOpHolder<OpD> hl_##fff (const HighLevelOpHolder<OpD>& in);
|
|
|
|
#include "extensions/math.h"
|
|
|
|
#undef regFunc1
|
|
|
|
|
2020-09-10 22:50:26 +02:00
|
|
|
|
2020-09-03 10:52:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|