75template<
class WrappedExpr>
83 return static_cast<WrappedExpr&
>(*this);
87 return static_cast<const WrappedExpr&
>(*this);
209template<
class T,
class C>
218template<
class T,
class C>
245template<
class Value_t,
class Child_t>
289template<
class Value_t,
class Left_t,
class Right_t>
291 public PETE_Expr< PETE_TBTree<Value_t, Left_t, Right_t> >
337template<
class Value_t,
class Left_t,
class M
iddle_t,
class Right_t >
339 :
public PETE_Expr< PETE_TTTree< Value_t, Left_t, Middle_t, Right_t > >
345 typename Middle_t::PETE_Return_t,
363 const Middle_t& m,
const Right_t& r)
379template<
class Op,
class T1,
class Functor,
class Combiner>
381typename Functor::PETE_Return_t
387template<
class Op,
class T1,
class T2,
class Functor,
class Combiner>
389typename Functor::PETE_Return_t
395template<
class Op,
class T1,
class T2,
class T3,
class Functor,
class Combiner>
397typename Functor::PETE_Return_t
408template<
class T,
class Op>
425 if ( (l>=0) && (r>=0) ) {
426 PInsist(l==r,
"Arguments not equal in AssertEquals()!!");
429 if ( r>=0 )
return ret = r;
436 if ( (l>=0) && (m>=0) && (r>=0) ) {
437 PInsist(m==l && m==r,
"Arguments not equal in AssertEquals()!!");
478template<
class Op,
class T1,
class Functor>
488template<
class Op,
class T1,
class T2,
class Functor>
492 typename T2::PETE_Return_t,Op>
::type
512template<
class T1,
class T2,
class Functor>
515 typedef typename T2::PETE_Return_t
T3;
528template<
class Op,
class T1,
class T2,
class Functor>
568template<
class Op,
class Sub>
575template<
class Op,
class Left,
class Right>
582template<
class Op,
class Left,
class M
iddle,
class Right>
589template<
class Left,
class Right>
598template<
int Safe,
class T1,
class T2,
class T3,
class Op,
class Functor>
603 typename T1::PETE_Return_t,
604 typename T2::PETE_Return_t,
605 typename T3::PETE_Return_t,
616template<
class T1,
class T2,
class T3,
class Functor>
622 typename T1::PETE_Return_t,
623 typename T2::PETE_Return_t,
624 typename T3::PETE_Return_t,
634template<
class T1,
class T2,
class T3,
class Functor,
class Op>
637 typename T2::PETE_Return_t,
638 typename T3::PETE_Return_t,Op>
::type
643 ,T1,T2,T3,Op,Functor>::apply(node,f);
652#if !defined(PETE_USER_REDUCTION_CODE)
654#define PETE_USER_REDUCTION_CODE
658template<
class R,
class T,
class InitOp,
class AccOp>
661 InitOp init_op, AccOp acc_op )
665 typename T::PETE_Expr_t expr(const_expr.
PETE_unwrap().MakeExpression());
680 for (
int i = 1; i <
n; ++i)
704#define PETE_DefineUnary(Fun,Expr,Op) \
706inline typename PETEUnaryReturn<T, Op>::type \
707PETE_apply(Op, const T& a) \
712inline PETE_TUTree<Op, typename T::PETE_Expr_t> \
713Fun(const PETE_Expr<T>& l) \
715 return PETE_TUTree<Op, typename T::PETE_Expr_t> \
716 (l.PETE_unwrap().MakeExpression()); \
748template<class T1, class T2>
755template<
class T1,
class Expr>
770#define PETE_DefineBinary(Fun,Expr,Op) \
771template<class T1, class T2> \
772inline typename PETEBinaryReturn<T1, T2, Op>::type \
773PETE_apply(Op, const T1& a, const T2& b) \
777template<class T1, class T2> \
778inline PETE_TBTree<Op, typename T1::PETE_Expr_t, typename T2::PETE_Expr_t> \
779Fun(const PETE_Expr<T1>& l, const PETE_Expr<T2>& r) \
781 typedef PETE_TBTree<Op,typename T1::PETE_Expr_t, \
782 typename T2::PETE_Expr_t> ret; \
783 return ret(l.PETE_unwrap().MakeExpression(), \
784 r.PETE_unwrap().MakeExpression()); \
787#define PETE_DefineBinarySynonym(Fun,Op) \
788template<class T1, class T2> \
789inline PETE_TBTree<Op, typename T1::PETE_Expr_t, typename T2::PETE_Expr_t> \
790Fun(const PETE_Expr<T1>& l, const PETE_Expr<T2>& r) \
792 typedef PETE_TBTree<Op,typename T1::PETE_Expr_t,typename T2::PETE_Expr_t> \
794 return ret(l.PETE_unwrap().MakeExpression(), \
795 r.PETE_unwrap().MakeExpression()); \
823#define PETE_DefineBinaryWithScalars(Fun,Op,Sca) \
825inline PETE_TBTree<Op, PETE_Scalar<Sca>, typename T::PETE_Expr_t> \
826Fun(const Sca l, const PETE_Expr<T>& r) \
828 typedef PETE_TBTree<Op, PETE_Scalar<Sca>, typename T::PETE_Expr_t> ret; \
829 return ret(PETE_Scalar<Sca>(l), r.PETE_unwrap().MakeExpression()); \
832inline PETE_TBTree<Op, typename T::PETE_Expr_t, PETE_Scalar<Sca> > \
833Fun(const PETE_Expr<T>& l, const Sca r) \
835 typedef PETE_TBTree<Op, typename T::PETE_Expr_t, PETE_Scalar<Sca> > ret; \
836 return ret(l.PETE_unwrap().MakeExpression(), PETE_Scalar<Sca>(r)); \
846#define PETE_DefineTrinary(Fun,Expr,Op) \
847template<class T1, class T2, class T3> \
848inline typename PETETrinaryReturn<T1,T2,T3,Op>::type \
849PETE_apply(Op, const T1& a, const T2& b, const T3& c) \
853template<class Cond_t, class True_t, class False_t> \
854inline PETE_TTTree<Op, typename Cond_t::PETE_Expr_t, \
855 typename True_t::PETE_Expr_t, typename False_t::PETE_Expr_t> \
856Fun(const PETE_Expr<Cond_t>& c, const PETE_Expr<True_t>& t, \
857 const PETE_Expr<False_t>& f) \
859 typedef PETE_TTTree<Op, typename Cond_t::PETE_Expr_t, \
860 typename True_t::PETE_Expr_t, typename False_t::PETE_Expr_t> ret; \
861 return ret(c.PETE_unwrap().MakeExpression(), \
862 t.PETE_unwrap().MakeExpression(), \
863 f.PETE_unwrap().MakeExpression()); \
866template<
class T1,
class T2,
class T3>
873template<
class Cond_t,
class True_t,
class False_t>
875 typename True_t::PETE_Expr_t,
876 typename False_t::PETE_Expr_t>
881 typename True_t::PETE_Expr_t,
882 typename False_t::PETE_Expr_t> ret;
883 return ret(
c.PETE_unwrap().MakeExpression(),
889#define PETE_DefineTrinaryWithScalars(Fun, Op, Sca) \
890template<class Cond_t, class True_t> \
891inline PETE_TTTree<Op, typename Cond_t::PETE_Expr_t, \
892 typename True_t::PETE_Expr_t, PETE_Scalar<Sca> > \
893Fun(const PETE_Expr<Cond_t>& c, const PETE_Expr<True_t>& t,Sca f) \
895 typedef PETE_TTTree<Op, typename Cond_t::PETE_Expr_t, \
896 typename True_t::PETE_Expr_t, PETE_Scalar<Sca> > ret; \
897 return ret(c.PETE_unwrap().MakeExpression(), \
898 t.PETE_unwrap().MakeExpression(), PETE_Scalar<Sca>(f)); \
900template<class Cond_t, class False_t> \
901inline PETE_TTTree<Op, typename Cond_t::PETE_Expr_t, PETE_Scalar<Sca>, \
902 typename False_t::PETE_Expr_t > \
903Fun(const PETE_Expr<Cond_t>& c, Sca t, const PETE_Expr<False_t>& f) \
905 typedef PETE_TTTree<Op, typename Cond_t::PETE_Expr_t, PETE_Scalar<Sca>, \
906 typename False_t::PETE_Expr_t > ret; \
907 return ret(c.PETE_unwrap().MakeExpression(), \
908 PETE_Scalar<Sca>(t), f.PETE_unwrap().MakeExpression()); \
910template<class Cond_t> \
911inline PETE_TTTree<Op, typename Cond_t::PETE_Expr_t, PETE_Scalar<Sca>, \
913Fun(const PETE_Expr<Cond_t>& c, Sca t, Sca f) \
915 typedef PETE_TTTree<Op, typename Cond_t::PETE_Expr_t, PETE_Scalar<Sca>, \
916 PETE_Scalar<Sca> > ret; \
917 return ret(c.PETE_unwrap().MakeExpression(), \
918 PETE_Scalar<Sca>(t), PETE_Scalar<Sca>(f)); \
986#define PETE_DefineScalar(Sca) \
987PETE_DefineBinaryWithScalars(operator+, OpAdd, Sca) \
988PETE_DefineBinaryWithScalars(operator-, OpSubtract, Sca) \
989PETE_DefineBinaryWithScalars(operator*, OpMultipply, Sca) \
990PETE_DefineBinaryWithScalars(operator/, OpDivide, Sca) \
991PETE_DefineBinaryWithScalars(operator%, OpMod, Sca) \
992PETE_DefineBinaryWithScalars(operator<, OpLT, Sca) \
993PETE_DefineBinaryWithScalars(operator<=, OpLE, Sca) \
994PETE_DefineBinaryWithScalars(operator>, OpGT, Sca) \
995PETE_DefineBinaryWithScalars(operator>=, OpGE, Sca) \
996PETE_DefineBinaryWithScalars(operator==, OpEQ, Sca) \
997PETE_DefineBinaryWithScalars(operator!=, OpNE, Sca) \
998PETE_DefineBinaryWithScalars(operator&&, OpAnd, Sca) \
999PETE_DefineBinaryWithScalars(operator||, OpOr, Sca) \
1000PETE_DefineBinaryWithScalars(operator&, OpBitwiseAnd, Sca) \
1001PETE_DefineBinaryWithScalars(operator|, OpBitwiseOr, Sca) \
1002PETE_DefineBinaryWithScalars(operator^, OpBitwiseXor, Sca) \
1003PETE_DefineBinaryWithScalars(where, OpWhere, Sca) \
1004PETE_DefineBinaryWithScalars(copysign, FnCopysign, Sca) \
1005PETE_DefineBinaryWithScalars(ldexp, FnLdexp, Sca) \
1006PETE_DefineBinaryWithScalars(pow, FnPow, Sca) \
1007PETE_DefineBinaryWithScalars(fmod, FnFmod, Sca) \
1008PETE_DefineBinaryWithScalars(atan2, FnArcTan2, Sca) \
1009PETE_DefineTrinaryWithScalars(where, OpWhere, Sca)
1031#define PETE_DefineAssign(Expr,Cond,Op) \
1032template<class T1, class T2> \
1033struct PETE_StructApply<Op,T1,T2> \
1035 static void apply(T1& a,const T2& b) { Expr; } \
1038template<class T1, class T2> \
1039struct PETE_StructApply<Op,T1,ConditionalAssign<T2> > \
1041 static void apply(T1& a, const ConditionalAssign<T2>& b) \
1048template<class T1, class T2> \
1050PETE_apply(Op, T1 &a, const T2& b) \
1052 PETE_StructApply<Op,T1,T2>::apply(a,b); \
1099 static inline const type&
1110inline typename T::PETE_Expr_t::PETE_Return_t
1113 typename T::PETE_Expr_t::PETE_Return_t val ;
1120inline typename T::PETE_Expr_t::PETE_Return_t
1123 typename T::PETE_Expr_t::PETE_Return_t val ;
1135#define UNARY_FUNCTION(RET,FUNC,ARG) \
1136struct FnUnary_ ## FUNC { \
1137 enum { tag = PETE_UnaryPassThruTag }; \
1139PETE_DefineUnary(FUNC,FUNC(a),FnUnary_ ## FUNC) \
1141struct PETEUnaryReturn<ARG, FnUnary_ ## FUNC> { \
1145#define BINARY_FUNCTION(RET,FUNC,ARG1,ARG2) \
1146struct FnBinary_ ## FUNC { \
1147 enum { tag = PETE_BinaryPromoteTag }; \
1149PETE_DefineBinary(FUNC,(FUNC(a,b)),FnBinary_ ## FUNC) \
1151struct PETEBinaryReturn<ARG1,ARG2,FnBinary_ ## FUNC> { \
T::PETE_Expr_t::PETE_Return_t sum(const PETE_Expr< T > &expr)
void Reduction(R &ret, const PETE_Expr< T > &const_expr, InitOp init_op, AccOp acc_op)
T::PETE_Expr_t::PETE_Return_t prod(const PETE_Expr< T > &expr)
PETE_TUTree< FnLog10, typename T::PETE_Expr_t > log10(const PETE_Expr< T > &l)
PETE_TTTree< OpWhere, typename Cond_t::PETE_Expr_t, typename True_t::PETE_Expr_t, typename False_t::PETE_Expr_t > where(const PETE_Expr< Cond_t > &c, const PETE_Expr< True_t > &t, const PETE_Expr< False_t > &f)
PETE_TBTree< FnLdexp, typename T1::PETE_Expr_t, typename T2::PETE_Expr_t > ldexp(const PETE_Expr< T1 > &l, const PETE_Expr< T2 > &r)
T for_each(const PETE_Scalar< T > &p, EvalFunctor_0)
PETE_TUTree< FnHypSin, typename T::PETE_Expr_t > sinh(const PETE_Expr< T > &l)
#define PETE_USER_REDUCTION_CODE
#define PETE_DefineBinary(Fun, Expr, Op)
PETE_TUTree< FnLog, typename T::PETE_Expr_t > log(const PETE_Expr< T > &l)
PETE_TBTree< FnCopysign, typename T1::PETE_Expr_t, typename T2::PETE_Expr_t > copysign(const PETE_Expr< T1 > &l, const PETE_Expr< T2 > &r)
PETE_Combiner< bool, OpOr > PETE_OrCombiner
PETE_TUTree< FnCeil, typename T::PETE_Expr_t > ceil(const PETE_Expr< T > &l)
PETE_TUTree< FnHypCos, typename T::PETE_Expr_t > cosh(const PETE_Expr< T > &l)
PETE_TUTree< FnSin, typename T::PETE_Expr_t > sin(const PETE_Expr< T > &l)
#define PETE_DefineBinarySynonym(Fun, Op)
PETE_TUTree< OpCast< T1 >, typename Expr::PETE_Expr_t > pete_cast(const T1 &, const PETE_Expr< Expr > &l)
PETE_TUTree< FnExp, typename T::PETE_Expr_t > exp(const PETE_Expr< T > &l)
PETE_TUTree< FnArcCos, typename T::PETE_Expr_t > acos(const PETE_Expr< T > &l)
PETE_Combiner< int, OpAdd > PETE_SumCombiner
#define PETE_DefineScalar(Sca)
#define PETE_DefineUnary(Fun, Expr, Op)
PETE_TUTree< FnErf, typename T::PETE_Expr_t > erf(const PETE_Expr< T > &l)
PETE_TUTree< FnHypTan, typename T::PETE_Expr_t > tanh(const PETE_Expr< T > &l)
PETE_TUTree< FnSqrt, typename T::PETE_Expr_t > sqrt(const PETE_Expr< T > &l)
PETE_TBTree< FnArcTan2, typename T1::PETE_Expr_t, typename T2::PETE_Expr_t > atan2(const PETE_Expr< T1 > &l, const PETE_Expr< T2 > &r)
PETEUnaryReturn< T, OpUnaryMinus >::type PETE_apply(OpUnaryMinus, const T &a)
PETE_TUTree< FnFabs, typename T::PETE_Expr_t > fabs(const PETE_Expr< T > &l)
PETE_TUTree< OpIdentity, typename T::PETE_Expr_t > PETE_identity(const PETE_Expr< T > &l)
PETE_TUTree< FnTan, typename T::PETE_Expr_t > tan(const PETE_Expr< T > &l)
PETE_TBTree< FnFmod, typename T1::PETE_Expr_t, typename T2::PETE_Expr_t > fmod(const PETE_Expr< T1 > &l, const PETE_Expr< T2 > &r)
PETE_TUTree< FnArcSin, typename T::PETE_Expr_t > asin(const PETE_Expr< T > &l)
PETE_TBTree< FnPow, typename T1::PETE_Expr_t, typename T2::PETE_Expr_t > pow(const PETE_Expr< T1 > &l, const PETE_Expr< T2 > &r)
PETE_TUTree< FnCos, typename T::PETE_Expr_t > cos(const PETE_Expr< T > &l)
PETE_TUTree< FnArcTan, typename T::PETE_Expr_t > atan(const PETE_Expr< T > &l)
#define PETE_DefineAssign(Expr, Cond, Op)
PETE_TUTree< FnFloor, typename T::PETE_Expr_t > floor(const PETE_Expr< T > &l)
PETE_Combiner< bool, OpAnd > PETE_AndCombiner
double Sub(double a, double b)
constexpr double c
The velocity of light in m/s.
boost::function< boost::tuple< double, bool >(arguments_t)> type
WrappedExpr & PETE_unwrap()
const WrappedExpr & PETE_unwrap() const
PETE_Scalar< T > PETE_Expr_t
PETE_Expr_t MakeExpression() const
PETE_TUTree(const Child_t &c)
PETEUnaryReturn< typenameChild_t::PETE_Return_t, Value_t >::type PETE_Return_t
PETE_TUTree< Value_t, Child_t > PETE_Expr_t
const PETE_Expr_t & MakeExpression() const
PETE_TUTree(const Value_t &v, const Child_t &c)
PETEBinaryReturn< typenameLeft_t::PETE_Return_t, typenameRight_t::PETE_Return_t, Value_t >::type PETE_Return_t
const PETE_Expr_t & MakeExpression() const
PETE_TBTree(const Left_t &l, const Right_t &r)
PETE_TBTree(const Value_t &v, const Left_t &l, const Right_t &r)
PETE_TBTree< Value_t, Left_t, Right_t > PETE_Expr_t
PETE_TTTree< Value_t, Left_t, Middle_t, Right_t > PETE_Expr_t
PETETrinaryReturn< typenameLeft_t::PETE_Return_t, typenameMiddle_t::PETE_Return_t, typenameRight_t::PETE_Return_t, Value_t >::type PETE_Return_t
PETE_TTTree(const Value_t &v, const Left_t &l, const Middle_t &m, const Right_t &r)
PETE_TTTree(const Left_t &l, const Middle_t &m, const Right_t &r)
const PETE_Expr_t & MakeExpression() const
T operator()(T x, T y, T z)
int operator()(int l, int r)
int operator()(int l, int m, int r)
int operator()(int, int, int)
static Return_t apply(PETE_TBTree< Op, T1, T2 > &node, Functor f)
PETEBinaryReturn< typenameT1::PETE_Return_t, typenameT2::PETE_Return_t, Op >::type Return_t
ConditionalAssign(bool q, const T &v)
static Return_t apply(PETE_TBTree< OpWhere, T1, T2 > &node, Functor f)
ConditionalAssign< T3 > Return_t
static PETETrinaryReturn< typenameT1::PETE_Return_t, typenameT2::PETE_Return_t, typenameT3::PETE_Return_t, Op >::type apply(PETE_TTTree< Op, T1, T2, T3 > &node, Functor f)
static PETETrinaryReturn< typenameT1::PETE_Return_t, typenameT2::PETE_Return_t, typenameT3::PETE_Return_t, OpWhere >::type apply(PETE_TTTree< OpWhere, T1, T2, T3 > &node, Functor f)
static type apply(const T &t)
PETE_TUTree< OpIdentity, T > type
static const type & apply(const PETE_Expr< T > &t)
PETE_ComputeUnaryType< T, Op, Op::tag >::type type
PETE_ComputeBinaryType< T2, T3, Op, Op::tag >::type type