OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
MathExpr.cpp File Reference

Shunting-yard parser + stack evaluator. More...

#include "MathExpr.hpp"
#include <cmath>
#include <stack>
#include <cctype>
#include <algorithm>
#include <unordered_map>
Include dependency graph for MathExpr.cpp:

Namespaces

namespace  openswmm
 
namespace  openswmm::mathexpr
 

Functions

const std::vector< std::string > & openswmm::mathexpr::function_names ()
 Return recognized built-in function names in stable token order.
 
int openswmm::mathexpr::parse (const std::string &expr_str, Expression &result)
 Tokenize an infix expression and construct its postfix representation.
 
double openswmm::mathexpr::evaluate (const Expression &expr, const std::function< double(const std::string &)> &var_lookup)
 Evaluate postfix tokens with a synchronous named-variable callback.
 
double openswmm::mathexpr::evaluate (const Expression &expr, const double *vars, int n_vars)
 Evaluate using variable indices stored in a compiled expression.
 
int openswmm::mathexpr::bind_variables (Expression &expr, const char *const *name_table, int n_vars)
 Bind each variable token to the first matching table entry.
 
int openswmm::mathexpr::compute_max_stack_depth (const Expression &expr)
 Compute the peak operand-stack occupancy implied by postfix tokens.
 
double openswmm::mathexpr::evaluate_fast (const Expression &expr, const double *vars) noexcept
 Evaluate the supported postfix subset with a fixed 32-value stack.
 

Detailed Description

Shunting-yard parser + stack evaluator.

Author
Caleb Buahin caleb.nosp@m..bua.nosp@m.hin@g.nosp@m.mail.nosp@m..com
License
Apache-2.0