26#ifndef IPPL_EXPRESSIONS_H
27#define IPPL_EXPRESSIONS_H
32#define PETE_USER_REDUCTION_CODE \
34 reduce_masked(ret, global_ret, acc_op, 0 < n ); \
87#define PETE_DefineScalarMinMax(Sca) \
89Min(const Sca& a, const Sca& b) \
91 return (a<b ? a : b); \
94Max(const Sca& a, const Sca& b) \
96 return (b<a ? a : b); \
121#define PETE_DefineIPPLScalar(Sca) \
122PETE_DefineBinaryWithScalars(Min, FnMin, Sca) \
123PETE_DefineBinaryWithScalars(Max, FnMax, Sca) \
124PETE_DefineBinaryWithScalars(dot, FnDot, Sca) \
125PETE_DefineBinaryWithScalars(dotdot, FnDotDot, Sca) \
126PETE_DefineBinaryWithScalars(outerProduct, FnOuterProduct, Sca) \
127PETE_DefineBinaryWithScalars(cross, FnDot, Sca) \
128PETE_DefineBinaryWithScalars(lt, OpLT, Sca) \
129PETE_DefineBinaryWithScalars(le, OpLE, Sca) \
130PETE_DefineBinaryWithScalars(gt, OpGT, Sca) \
131PETE_DefineBinaryWithScalars(ge, OpGE, Sca) \
132PETE_DefineBinaryWithScalars(eq, OpEQ, Sca) \
133PETE_DefineBinaryWithScalars(ne, OpNE, Sca)
145#undef PETE_DefineIPPLScalar
150#define PETE_DefineBinaryWithVSTScalars(Fun,Op,Sca) \
151template<class T1, unsigned Dim, class T2> \
152inline PETE_TBTree<Op, PETE_Scalar< Sca<T1, Dim> >, \
153 typename T2::PETE_Expr_t> \
154Fun(const Sca<T1, Dim> &l, const PETE_Expr<T2>& r) \
156 typedef PETE_TBTree<Op, PETE_Scalar< Sca<T1, Dim> >, \
157 typename T2::PETE_Expr_t> ret; \
158 return ret(PETE_Scalar< Sca<T1, Dim> >(l), \
159 r.PETE_unwrap().MakeExpression()); \
161template<class T1, class T2, unsigned Dim> \
162inline PETE_TBTree<Op, typename T1::PETE_Expr_t, \
163 PETE_Scalar< Sca<T2, Dim> > > \
164Fun(const PETE_Expr<T1>& l, const Sca<T2, Dim> &r) \
166 typedef PETE_TBTree<Op, typename T1::PETE_Expr_t, \
167 PETE_Scalar< Sca<T2, Dim> > > ret; \
168 return ret(l.PETE_unwrap().MakeExpression(), \
169 PETE_Scalar< Sca<T2, Dim> >(r)); \
172#define PETE_DefineTrinaryWithVSTScalars(Fun, Op, Sca) \
173template<class Cond_t, class True_t, class T, unsigned Dim> \
174inline PETE_TTTree<Op, typename Cond_t::PETE_Expr_t, \
175 typename True_t::PETE_Expr_t, PETE_Scalar< Sca<T, Dim> > > \
176Fun(const PETE_Expr<Cond_t>& c, const PETE_Expr<True_t>& t, \
177 const Sca<T, Dim> &f) \
179 typedef PETE_TTTree<Op, typename Cond_t::PETE_Expr_t, \
180 typename True_t::PETE_Expr_t, PETE_Scalar< Sca<T, Dim> > > ret; \
181 return ret(c.PETE_unwrap().MakeExpression(), \
182 t.PETE_unwrap().MakeExpression(), PETE_Scalar< Sca<T, Dim> >(f)); \
184template<class Cond_t, class T, unsigned Dim, class False_t> \
185inline PETE_TTTree<Op, typename Cond_t::PETE_Expr_t, \
186 PETE_Scalar< Sca<T, Dim> >, typename False_t::PETE_Expr_t > \
187Fun(const PETE_Expr<Cond_t>& c, const Sca<T, Dim> &t, \
188 const PETE_Expr<False_t>& f) \
190 typedef PETE_TTTree<Op, typename Cond_t::PETE_Expr_t, PETE_Scalar< Sca<T, Dim> >, \
191 typename False_t::PETE_Expr_t > ret; \
192 return ret(c.PETE_unwrap().MakeExpression(), \
193 PETE_Scalar< Sca<T, Dim> >(t), f.PETE_unwrap().MakeExpression()); \
195template<class Cond_t, class T, unsigned Dim> \
196inline PETE_TTTree<Op, typename Cond_t::PETE_Expr_t, \
197 PETE_Scalar< Sca<T, Dim> >, PETE_Scalar< Sca<T, Dim> > > \
198Fun(const PETE_Expr<Cond_t>& c, const Sca<T, Dim> &t, const Sca<T, Dim> &f) \
200 typedef PETE_TTTree<Op, typename Cond_t::PETE_Expr_t, \
201 PETE_Scalar< Sca<T, Dim> >, PETE_Scalar< Sca<T, Dim> > > ret; \
202 return ret(c.PETE_unwrap().MakeExpression(), \
203 PETE_Scalar< Sca<T, Dim> >(t), PETE_Scalar< Sca<T, Dim> >(f)); \
208#define PETE_DefineVSTScalar(Sca) \
209PETE_DefineBinaryWithVSTScalars(operator+, OpAdd, Sca) \
210PETE_DefineBinaryWithVSTScalars(operator-, OpSubtract, Sca) \
211PETE_DefineBinaryWithVSTScalars(operator*, OpMultipply, Sca) \
212PETE_DefineBinaryWithVSTScalars(operator/, OpDivide, Sca) \
213PETE_DefineBinaryWithVSTScalars(operator%, OpMod, Sca) \
214PETE_DefineBinaryWithVSTScalars(operator<, OpLT, Sca) \
215PETE_DefineBinaryWithVSTScalars(operator<=, OpLE, Sca) \
216PETE_DefineBinaryWithVSTScalars(operator>, OpGT, Sca) \
217PETE_DefineBinaryWithVSTScalars(operator>=, OpGE, Sca) \
218PETE_DefineBinaryWithVSTScalars(operator==, OpEQ, Sca) \
219PETE_DefineBinaryWithVSTScalars(operator!=, OpNE, Sca) \
220PETE_DefineBinaryWithVSTScalars(operator&&, OpAnd, Sca) \
221PETE_DefineBinaryWithVSTScalars(operator||, OpOr, Sca) \
222PETE_DefineBinaryWithVSTScalars(operator&, OpBitwiseAnd, Sca) \
223PETE_DefineBinaryWithVSTScalars(operator|, OpBitwiseOr, Sca) \
224PETE_DefineBinaryWithVSTScalars(operator^, OpBitwiseXor, Sca) \
225PETE_DefineBinaryWithVSTScalars(copysign, FnCopysign, Sca) \
226PETE_DefineBinaryWithVSTScalars(ldexp, FnLdexp, Sca) \
227PETE_DefineBinaryWithVSTScalars(pow, FnPow, Sca) \
228PETE_DefineBinaryWithVSTScalars(fmod, FnFmod, Sca) \
229PETE_DefineBinaryWithVSTScalars(atan2, FnArcTan2, Sca) \
230PETE_DefineTrinaryWithVSTScalars(where, OpWhere, Sca) \
231PETE_DefineBinaryWithVSTScalars(Min, FnMin, Sca) \
232PETE_DefineBinaryWithVSTScalars(Max, FnMax, Sca) \
233PETE_DefineBinaryWithVSTScalars(dot, FnDot, Sca) \
234PETE_DefineBinaryWithVSTScalars(dotdot, FnDotDot, Sca) \
235PETE_DefineBinaryWithVSTScalars(outerProduct, FnOuterProduct, Sca) \
236PETE_DefineBinaryWithVSTScalars(cross, FnCross, Sca) \
237PETE_DefineBinaryWithVSTScalars(lt, OpLT, Sca) \
238PETE_DefineBinaryWithVSTScalars(le, OpLE, Sca) \
239PETE_DefineBinaryWithVSTScalars(gt, OpGT, Sca) \
240PETE_DefineBinaryWithVSTScalars(ge, OpGE, Sca) \
241PETE_DefineBinaryWithVSTScalars(eq, OpEQ, Sca) \
242PETE_DefineBinaryWithVSTScalars(ne, OpNE, Sca)
248#undef PETE_DefineVSTScalar
270inline typename T::PETE_Expr_t::PETE_Return_t
273 typename T::PETE_Expr_t::PETE_Return_t val ;
282inline typename T::PETE_Expr_t::PETE_Return_t
285 typename T::PETE_Expr_t::PETE_Return_t val ;
304 MinMaxHolder(
const MinMaxHolder<T>& rhs) :
a(rhs.
a), b(rhs.b) { }
305 const MinMaxHolder<T>& operator=(
const MinMaxHolder<T>& rhs) {
310 const MinMaxHolder<T>& operator=(
const T& rhs) {
316 const MinMaxHolder<T>&
operator*=(
const MinMaxHolder<T>& rhs) {
317 a = (
a < rhs.a ?
a : rhs.a);
318 b = (rhs.b < b ? b : rhs.b);
339template<
class T1,
class T2>
343 typedef typename T1::PETE_Expr_t::PETE_Return_t val_t;
344 MinMaxHolder<val_t> ret;
349 minval =
static_cast<T2
>(ret.a);
350 maxval =
static_cast<T2
>(ret.b);
361template<
class T,
class OP>
407template<
class T1,
class T2>
419template<
class T1,
class T2,
class Op>
440template<
class T,
unsigned int D>
464 for (
unsigned int d=0; d < D; ++d) {
465 a[d] = (
a[d] < rhs.
a[d] ?
a[d] : rhs.
a[d]);
466 b[d] = (rhs.
b[d] <
b[d] ?
b[d] : rhs.
b[d]);
472 for (
unsigned int d=0; d < D; ++d) {
473 a[d] = (
a[d] <
c[d] ?
a[d] :
c[d]);
474 b[d] = (
c[d] <
b[d] ?
b[d] :
c[d]);
480 for (
unsigned int d=0; d < D; ++d) {
481 a[d] = (
a[d] <
c[d] ?
a[d] :
c[d]);
482 b[d] = (
c[d] <
b[d] ?
b[d] :
c[d]);
498template<
class T1,
class T2,
unsigned int D>
518template<
class T,
class TP>
FLieGenerator< T, N > imag(const FLieGenerator< std::complex< T >, N > &)
Take imaginary part of a complex generator.
void putMessage(Message &m, const T &t)
void getMessage(Message &m, T &t)
T::PETE_Expr_t::PETE_Return_t max(const PETE_Expr< T > &expr, NDIndex< D > &loc)
T::PETE_Expr_t::PETE_Return_t min(const PETE_Expr< T > &expr, NDIndex< D > &loc)
T::PETE_Return_t Reduction(const PETE_Expr< T > &const_expr, CompOp comp_op, AccOp acc_op, NDIndex< D > &loc)
PETE_TBTree< FnDot, PETE_Scalar< Vektor< T1, Dim > >, typename T2::PETE_Expr_t > dot(const Vektor< T1, Dim > &l, const PETE_Expr< T2 > &r)
PETE_TBTree< OpGE, PETE_Scalar< Vektor< T1, Dim > >, typename T2::PETE_Expr_t > ge(const Vektor< T1, Dim > &l, const PETE_Expr< T2 > &r)
PETEUnaryReturn< T, OpParens< TP > >::type PETE_apply(OpParens< TP > op, const T &a)
FnMax FnDotDot FnCross PETE_DefineBinarySynonym(lt, OpLT) PETE_DefineBinarySynonym(gt
PETE_DefineAssign((a=Min(a, b)),(a=Min(a, b.value)), OpMinAssign) PETE_DefineAssign((a
PETE_TBTree< OpGT, PETE_Scalar< Vektor< T1, Dim > >, typename T2::PETE_Expr_t > gt(const Vektor< T1, Dim > &l, const PETE_Expr< T2 > &r)
PETE_TBTree< OpEQ, PETE_Scalar< Vektor< T1, Dim > >, typename T2::PETE_Expr_t > eq(const Vektor< T1, Dim > &l, const PETE_Expr< T2 > &r)
PETE_TUTree< FnAbs, typename T::PETE_Expr_t > abs(const PETE_Expr< T > &l)
short short short short short short int int int int int int long long long long long long float float float float float float double double double double double double OpEQ
#define PETE_DefineScalarMinMax(Sca)
#define PETE_DefineVSTScalar(Sca)
FnArg FnReal FnSign transpose(a))
PETE_TBTree< OpLT, PETE_Scalar< Vektor< T1, Dim > >, typename T2::PETE_Expr_t > lt(const Vektor< T1, Dim > &l, const PETE_Expr< T2 > &r)
short Max(const short &a, const short &b)
bool any(const PETE_Expr< T1 > &expr, T2 val)
FnMax FnDotDot cross(a, b))
PETE_TBTree< OpNE, PETE_Scalar< Vektor< T1, Dim > >, typename T2::PETE_Expr_t > ne(const Vektor< T1, Dim > &l, const PETE_Expr< T2 > &r)
short short short short short short int int int int int int long long long long long long float float float float float float double double double double double double PETE_DefineScalar(std::complex< double >) PETE_DefineBinaryWithScalars(eq
PETE_DefineUnary(Abs,(0< a ? a :-a), FnAbs) inline double PETE_apply(FnAbs
short Min(const short &a, const short &b)
#define PETE_DefineIPPLScalar(Sca)
void bounds(const PETE_Expr< T1 > &expr, Vektor< T2, D > &minval, Vektor< T2, D > &maxval)
PETE_DefineBinaryWithScalars(Min, FnMin, short) PETE_DefineBinaryWithScalars(Max
PETE_TBTree< OpLE, PETE_Scalar< Vektor< T1, Dim > >, typename T2::PETE_Expr_t > le(const Vektor< T1, Dim > &l, const PETE_Expr< T2 > &r)
void minmax(const PETE_Expr< T1 > &expr, T2 &minval, T2 &maxval)
PETE_DefineBinary(Min,(Min(a, b)), FnMin) PETE_DefineBinary(Max
FnArg FnReal FnSign FnTranspose cofactors(a))
PETE_TBTree< FnOuterProduct, PETE_Scalar< Vektor< T1, Dim > >, typename T2::PETE_Expr_t > outerProduct(const Vektor< T1, Dim > &l, const PETE_Expr< T2 > &r)
T det(const AntiSymTenzor< T, 3 > &)
MMatrix< m_complex > complex(MMatrix< double > real)
m_complex conj(const m_complex &c)
MMatrix< double > & operator*=(MMatrix< double > &m1, MMatrix< double > m2)
constexpr double c
The velocity of light in m/s.
BOOST_UBLAS_INLINE V trace(ublas::matrix< V > &e)
Computes the trace of a square matrix.
boost::function< boost::tuple< double, bool >(arguments_t)> type
Message & put(const T &val)
Message & get(const T &cval)
AnyHolder(const T &t, OP op)
const AnyHolder< T, OP > & operator*=(const AnyHolder< T, OP > &rhs)
const AnyHolder< T, OP > & operator=(const T &rhs)
Message & putMessage(Message &m)
const AnyHolder< T, OP > & operator=(const AnyHolder< T, OP > &rhs)
const AnyHolder< T, OP > & operator*=(const T &rhs)
Message & getMessage(Message &m)
AnyHolder(const AnyHolder< T, OP > &rhs)
const BoundsHolder< T, D > & operator=(const T &rhs)
const BoundsHolder< T, D > & operator*=(const BoundsHolder< T, D > &rhs)
const BoundsHolder< T, D > & operator=(const BoundsHolder< T, D > &rhs)
Message & getMessage(Message &m)
const BoundsHolder< T, D > & operator*=(const Vektor< T, D > &rhs)
const BoundsHolder< T, D > & operator*=(const T &rhs)
Message & putMessage(Message &m)
BoundsHolder(const BoundsHolder< T, D > &rhs)
const BoundsHolder< T, D > & operator=(const Vektor< T, D > &rhs)
WrappedExpr & PETE_unwrap()