16#ifndef Parser_included
17#define Parser_included
19#include <UnaryFunction.h>
20#include <TRUST_Deriv.h>
21#include <TRUST_List.h>
28#include <TRUSTArray.h>
32enum class FUNCTION { SIN=1, ASIN, COS, ACOS, TAN, ATAN, LN, EXP, SQRT, ENT, ERF, RND, COSH, SINH, TANH, ATANH, NOT, ABS, SGN };
53 Parser(std::string&,
int n =1);
83 inline void setVar(
int i,
double val)
85 assert(i>-1 && i<
ivar);
131 return evalOp(node, x, y);
140 Process::exit(
"method eval : Unknown type for this node !!!");
144 KOKKOS_INLINE_FUNCTION
double evalOp(
const PNodePod& node,
double x,
double y);
173 std::transform(s.begin(), s.end(), s.begin(), ::toupper);
182 int unary_function = -node.
value-1;
186 switch (unary_function)
188 case static_cast<int>(FUNCTION::SIN):
190 case static_cast<int>(FUNCTION::ASIN):
192 case static_cast<int>(FUNCTION::COS):
194 case static_cast<int>(FUNCTION::ACOS):
196 case static_cast<int>(FUNCTION::TAN):
198 case static_cast<int>(FUNCTION::ATAN):
200 case static_cast<int>(FUNCTION::LN):
204 case static_cast<int>(FUNCTION::EXP):
206 case static_cast<int>(FUNCTION::SQRT):
210 case static_cast<int>(FUNCTION::ENT):
212 case static_cast<int>(FUNCTION::ERF):
216 Process::exit(
"erf(x) fonction not implemented on Windows version.");
219 case static_cast<int>(FUNCTION::RND):
227 case static_cast<int>(FUNCTION::COSH):
229 case static_cast<int>(FUNCTION::SINH):
231 case static_cast<int>(FUNCTION::TANH):
233 case static_cast<int>(FUNCTION::ATANH):
235 case static_cast<int>(FUNCTION::NOT):
236 if (x == 0)
return 1;
238 case static_cast<int>(FUNCTION::ABS):
240 case static_cast<int>(FUNCTION::SGN):
241 return (x > 0) - (x < 0);
256KOKKOS_INLINE_FUNCTION
270 Process::Kokkos_exit(
"Error in the Parser: x/y calculated with y equals 0. You are using a formulae with a division per 0.");
274 if (y != (
int)(y) && x<0)
279 Cerr <<
"Error in the Parser: x^y calculated with negative value for x (x = " << x <<
") and y real y (y = " << y <<
" )" << finl;
293 return ((
int)(x))%((int)(y));
310 Cerr <<
"Method evalOp : Unknown op " << (int)node.
value <<
"!!!" << finl;
Definit une constante dans le jeu de donnees.
Un tableau de chaine de caracteres (VECT(Nom)).
void addVar(const char *)
virtual void setNbVar(int nvar)
std::vector< PNodePod > PNodes
double eval(const PNodePod &node)
KOKKOS_INLINE_FUNCTION double evalFunc(const PNodePod &node, double x)
int searchVar(const std::string &s)
void setImpulsion(double tinit, double periode)
void setVar(const char *sv, double val)
std::string & getString()
void parserState1(StringTokenizer *, PSTACK(PNode) *, STACK(int) *)
void parserState0(StringTokenizer *, PSTACK(PNode) *, STACK(int) *)
void setVar(int i, double val)
int searchFunc(const std::string &v)
void setString(const std::string &s)
int test_op_binaire(int type)
std::map< std::string, int > map_function_
void setVar(const std::string &v, double val)
static int precedence(int)
virtual void parseString()
int searchCst(const std::string &v)
KOKKOS_INLINE_FUNCTION double evalOp(const PNodePod &node, double x, double y)
void addCst(const Constante &cst)
void parserState2(StringTokenizer *, PSTACK(PNode) *, STACK(int) *)
static KOKKOS_INLINE_FUNCTION void Kokkos_exit(const char *)
Routine de sortie de TRUST dans une region Kokkos.
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.