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);
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_COTH
coth(x) = 1/tanh(x)
@ FUNC_ACOT
acot(x) = atan(1/x)
@ FUNC_COT
cot(x) = 1/tan(x)
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