38#ifndef __SIM_MATHEXPR_HH__
39#define __SIM_MATHEXPR_HH__
98 typedef double (*
binOp)(double, double);
109 std::array<OpSearch, uNeg + 1>
ops;
116 const char opStr[] = {
'+',
'-',
'*',
'/',
'^',
'-'};
123 return std::to_string(
value);
125 return std::string(1, opStr[
op]);
142 std::string
toStr(
Node *
n, std::string prefix)
const;
std::string toStr() const
double eval(EvalCallback fn) const
Evaluates the expression.
Node * parse(std::string expr)
Parse and create nodes from string.
std::array< OpSearch, uNeg+1 > ops
Operator list.
MathExpr(std::string expr)
std::vector< std::string > getVariables() const
Return all variables in the this expression.
std::string toStr() const
Prints an ASCII representation of the expression tree.
std::function< double(std::string)> EvalCallback
double(* binOp)(double, double)
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.