22#ifndef OPENSWMM_MATHEXPR_HPP
23#define OPENSWMM_MATHEXPR_HPP
118 const char*
const* name_table,
int n_vars);
139 const std::function<
double(
const std::string&)>& var_lookup);
Definition MathExpr.cpp:19
int compute_max_stack_depth(const Expression &expr)
Compute the maximum stack depth needed to evaluate an expression.
Definition MathExpr.cpp:313
double evaluate_fast(const Expression &expr, const double *vars) noexcept
Fast evaluate using pre-bound variable indices and stack-free evaluation.
Definition MathExpr.cpp:339
int parse(const std::string &expr_str, Expression &result)
Parse an infix expression string into a postfix Expression.
Definition MathExpr.cpp:132
TokenType
Definition MathExpr.hpp:36
@ FUNC_ATAN
Definition MathExpr.hpp:57
@ POW
Definition MathExpr.hpp:43
@ FUNC_SIN
Definition MathExpr.hpp:52
@ SUB
Definition MathExpr.hpp:40
@ DIV
Definition MathExpr.hpp:42
@ MUL
Definition MathExpr.hpp:41
@ FUNC_SINH
sinh(x)
Definition MathExpr.hpp:64
@ NUMBER
Definition MathExpr.hpp:37
@ FUNC_COTH
coth(x) = 1/tanh(x)
Definition MathExpr.hpp:67
@ FUNC_TAN
Definition MathExpr.hpp:54
@ LPAREN
Definition MathExpr.hpp:45
@ FUNC_SQRT
Definition MathExpr.hpp:49
@ COMMA
Definition MathExpr.hpp:61
@ FUNC_LOG10
log10(x)
Definition MathExpr.hpp:68
@ NEG
Definition MathExpr.hpp:44
@ FUNC_MIN
Definition MathExpr.hpp:59
@ FUNC_TANH
tanh(x)
Definition MathExpr.hpp:66
@ FUNC_SGN
Definition MathExpr.hpp:48
@ FUNC_ASIN
Definition MathExpr.hpp:55
@ FUNC_MAX
Definition MathExpr.hpp:60
@ FUNC_LOG
Definition MathExpr.hpp:50
@ FUNC_ACOT
acot(x) = atan(1/x)
Definition MathExpr.hpp:69
@ FUNC_STEP
Definition MathExpr.hpp:58
@ ADD
Definition MathExpr.hpp:39
@ FUNC_EXP
Definition MathExpr.hpp:51
@ FUNC_COS
Definition MathExpr.hpp:53
@ VARIABLE
Definition MathExpr.hpp:38
@ FUNC_COT
cot(x) = 1/tan(x)
Definition MathExpr.hpp:63
@ FUNC_ACOS
Definition MathExpr.hpp:56
@ FUNC_ABS
Definition MathExpr.hpp:47
@ RPAREN
Definition MathExpr.hpp:46
@ FUNC_COSH
cosh(x)
Definition MathExpr.hpp:65
int bind_variables(Expression &expr, const char *const *name_table, int n_vars)
Bind variable names in a compiled expression to integer indices.
Definition MathExpr.cpp:284
double evaluate(const Expression &expr, const std::function< double(const std::string &)> &var_lookup)
Evaluate a compiled expression with named variable lookup.
Definition MathExpr.cpp:187
Definition NodeCoupling.cpp:15
Definition MathExpr.hpp:83
std::vector< Token > postfix
Postfix (RPN) token sequence.
Definition MathExpr.hpp:84
bool valid
Definition MathExpr.hpp:85
Definition MathExpr.hpp:72
TokenType type
Definition MathExpr.hpp:73
std::string var_name
For VARIABLE tokens (name for lookup)
Definition MathExpr.hpp:76
int var_idx
For VARIABLE tokens (index into variable table)
Definition MathExpr.hpp:75
double value
For NUMBER tokens.
Definition MathExpr.hpp:74