![]() |
OpenSWMM Engine
6.0.0-alpha.1
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.1)
|
Mathematical expression parser and evaluator. More...
#include <string>#include <vector>#include <functional>Go to the source code of this file.
Classes | |
| struct | openswmm::mathexpr::Token |
| struct | openswmm::mathexpr::Expression |
Namespaces | |
| namespace | openswmm |
| namespace | openswmm::mathexpr |
Enumerations | |
| enum class | openswmm::mathexpr::TokenType : int { openswmm::mathexpr::NUMBER = 0 , openswmm::mathexpr::VARIABLE = 1 , openswmm::mathexpr::ADD = 2 , openswmm::mathexpr::SUB = 3 , openswmm::mathexpr::MUL = 4 , openswmm::mathexpr::DIV = 5 , openswmm::mathexpr::POW = 6 , openswmm::mathexpr::NEG = 7 , openswmm::mathexpr::LPAREN = 8 , openswmm::mathexpr::RPAREN = 9 , openswmm::mathexpr::FUNC_ABS = 10 , openswmm::mathexpr::FUNC_SGN = 11 , openswmm::mathexpr::FUNC_SQRT = 12 , openswmm::mathexpr::FUNC_LOG = 13 , openswmm::mathexpr::FUNC_EXP = 14 , openswmm::mathexpr::FUNC_SIN = 15 , openswmm::mathexpr::FUNC_COS = 16 , openswmm::mathexpr::FUNC_TAN = 17 , openswmm::mathexpr::FUNC_ASIN = 18 , openswmm::mathexpr::FUNC_ACOS = 19 , openswmm::mathexpr::FUNC_ATAN = 20 , openswmm::mathexpr::FUNC_STEP = 21 , openswmm::mathexpr::FUNC_MIN = 22 , openswmm::mathexpr::FUNC_MAX = 23 , openswmm::mathexpr::COMMA = 24 } |
Functions | |
| int | openswmm::mathexpr::parse (const std::string &expr_str, Expression &result) |
| Parse an infix expression string into a postfix Expression. | |
| double | openswmm::mathexpr::evaluate (const Expression &expr, const std::function< double(const std::string &)> &var_lookup) |
| Evaluate a compiled expression with named variable lookup. | |
| double | openswmm::mathexpr::evaluate (const Expression &expr, const double *vars, int n_vars) |
| Evaluate with a flat variable array (by index). | |
Mathematical expression parser and evaluator.
Parses infix expressions (e.g., "C * exp(-0.1 * DT)") into postfix (RPN) token lists using the Shunting-yard algorithm. Evaluation uses a simple stack machine.
Used by: