36 #ifndef _ANALYTIC_EXPRESSION_EVALUATOR_HPP
37 #define _ANALYTIC_EXPRESSION_EVALUATOR_HPP
43 #include <boost/version.hpp>
44 #include <boost/random/mersenne_twister.hpp>
45 #include <boost/random/variate_generator.hpp>
46 #include <boost/random/normal_distribution.hpp>
49 #if( BOOST_VERSION / 100 % 1000 >= 36 )
50 #include <boost/spirit/include/classic_core.hpp>
51 #include <boost/spirit/include/classic_ast.hpp>
52 #include <boost/spirit/include/classic_symbols.hpp>
53 #include <boost/spirit/include/classic_assign_actor.hpp>
54 #include <boost/spirit/include/classic_push_back_actor.hpp>
56 namespace boost_spirit = boost::spirit::classic;
58 #include <boost/spirit/core.hpp>
59 #include <boost/spirit/tree/ast.hpp>
60 #include <boost/spirit/symbols/symbols.hpp>
61 #include <boost/spirit/actor/assign_actor.hpp>
62 #include <boost/spirit/actor/push_back_actor.hpp>
64 namespace boost_spirit = boost::spirit;
70 #if defined(__INTEL_COMPILER)
78 namespace LibUtilities
117 typedef boost_spirit::tree_parse_info<
118 std::string::const_iterator,
119 boost_spirit::node_val_data_factory<NekDouble>
121 typedef boost_spirit::tree_match<
122 std::string::const_iterator,
123 boost_spirit::node_val_data_factory<NekDouble>
213 const int AnalyticExpression_id,
224 const int AnalyticExpression_id,
225 std::vector<NekDouble> point);
229 const int expression_id,
230 const Array<OneD, const NekDouble>&,
231 const Array<OneD, const NekDouble>&,
232 const Array<OneD, const NekDouble>&,
233 const Array<OneD, const NekDouble>&,
234 Array<OneD, NekDouble>& result);
239 const int expression_id,
240 const std::vector<Array<OneD, const NekDouble> > points,
241 Array<OneD, NekDouble>& result);
309 for (std::vector<std::string>::const_iterator it = vars.begin(); it != vars.end(); it++)
335 template <
typename ScannerT>
344 boost_spirit::rule<ScannerT, boost_spirit::parser_context<>, boost_spirit::parser_tag<constantID> >
constant;
345 boost_spirit::rule<ScannerT, boost_spirit::parser_context<>, boost_spirit::parser_tag<numberID> >
number;
346 boost_spirit::rule<ScannerT, boost_spirit::parser_context<>, boost_spirit::parser_tag<variableID> >
variable;
347 boost_spirit::rule<ScannerT, boost_spirit::parser_context<>, boost_spirit::parser_tag<parameterID> >
parameter;
348 boost_spirit::rule<ScannerT, boost_spirit::parser_context<>, boost_spirit::parser_tag<functionID> >
function;
349 boost_spirit::rule<ScannerT, boost_spirit::parser_context<>, boost_spirit::parser_tag<factorID> >
factor;
350 boost_spirit::rule<ScannerT, boost_spirit::parser_context<>, boost_spirit::parser_tag<operatorID> >
exponential;
351 boost_spirit::rule<ScannerT, boost_spirit::parser_context<>, boost_spirit::parser_tag<operatorID> >
mult_div;
352 boost_spirit::rule<ScannerT, boost_spirit::parser_context<>, boost_spirit::parser_tag<operatorID> >
add_sub;
353 boost_spirit::rule<ScannerT, boost_spirit::parser_context<>, boost_spirit::parser_tag<operatorID> >
lt_gt;
354 boost_spirit::rule<ScannerT, boost_spirit::parser_context<>, boost_spirit::parser_tag<operatorID> >
equality;
355 boost_spirit::rule<ScannerT, boost_spirit::parser_context<>, boost_spirit::parser_tag<operatorID> >
logical_and;
356 boost_spirit::rule<ScannerT, boost_spirit::parser_context<>, boost_spirit::parser_tag<operatorID> >
logical_or;
357 boost_spirit::rule<ScannerT, boost_spirit::parser_context<>, boost_spirit::parser_tag<operatorID> >
expression;
358 boost_spirit::rule<ScannerT, boost_spirit::parser_context<>, boost_spirit::parser_tag<operatorID> >
op;
360 boost_spirit::rule<ScannerT, boost_spirit::parser_context<>, boost_spirit::parser_tag<operatorID> >
const&
448 typedef std::vector<NekDouble>&
vr;
449 typedef const std::vector<NekDouble>&
cvr;
450 typedef const int ci;
454 template<
typename StepType>
499 CopyState(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
505 StoreConst(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
511 StoreVar(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
517 StorePrm(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
523 EvalSum(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
529 EvalSub(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
535 EvalMul(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
541 EvalDiv(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
547 EvalPow(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
553 EvalNeg(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
559 EvalLogicalEqual(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
565 EvalLogicalLeq(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
571 EvalLogicalLess(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
577 EvalLogicalGeq(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
583 EvalLogicalGreater(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
589 EvalAbs(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
595 EvalSign(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
596 virtual void run_many(
ci n) {
for(
int i=0;i<n;i++) state[storeIdx*n+i] = ((state[argIdx1*n+i] > 0.0) - (
state[
argIdx1*n+i] < 0.0)); }
601 EvalAsin(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
607 EvalAcos(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
613 EvalAtan(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
619 EvalCeil(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
625 EvalCos(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
631 EvalCosh(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
637 EvalExp(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
643 EvalFabs(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
649 EvalFloor(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
655 EvalLog(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
661 EvalLog10(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
667 EvalSin(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
673 EvalSinh(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
679 EvalSqrt(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
685 EvalTan(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
691 EvalTanh(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
697 EvalAWGN(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
701 boost::variate_generator<RandomGeneratorType&, boost::normal_distribution<> >
707 boost::variate_generator<RandomGeneratorType&, boost::normal_distribution<> >
717 #endif // _ANALYTIC_EXPRESSION_EVALUATOR_HPP