OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
mathexpr.h
Go to the documentation of this file.
1
10
11/******************************************************************************
12** MODULE: MATHEXPR.H
13** PROJECT: SWMM5
14** DESCRIPTION: header file for the math expression parser in mathexpr.c.
15** AUTHORS: L. Rossman, US EPA - NRMRL
16** F. Shang, University of Cincinnati
17** VERSION: 5.1.001
18** LAST UPDATE: 03/20/14
19******************************************************************************/
20
21#ifndef MATHEXPR_H
22#define MATHEXPR_H
23
24// Node in a tokenized math expression list
25struct ExprNode {
26 int opcode; // operator code
27 int ivar; // variable index
28 double fvalue; // numerical value
29 struct ExprNode* prev; // previous node
30 struct ExprNode* next; // next node
31};
32typedef struct ExprNode MathExpr;
33
34// Creates a tokenized math expression from a string
35MathExpr* mathexpr_create(char* s, int (*getVar)(char*));
36
37// Evaluates a tokenized math expression
38double mathexpr_eval(MathExpr* expr, double (*getVal)(int));
39
40// Deletes a tokenized math expression
41void mathexpr_delete(MathExpr* expr);
42
43#endif //MATHEXPR_H
struct ExprNode MathExpr
Definition mathexpr.h:32
void mathexpr_delete(MathExpr *expr)
Recursively release a complete postfix MathExpr list.
Definition mathexpr.c:882
double mathexpr_eval(MathExpr *expr, double(*getVal)(int))
Evaluate a legacy postfix expression using a local operand stack.
Definition mathexpr.c:637
MathExpr * mathexpr_create(char *s, int(*getVar)(char *))
Compile an infix formula into an owned postfix expression list.
Definition mathexpr.c:902
Definition mathexpr.h:25
int ivar
Definition mathexpr.h:27
struct ExprNode * prev
Definition mathexpr.h:29
int opcode
Definition mathexpr.h:26
double fvalue
Definition mathexpr.h:28
struct ExprNode * next
Definition mathexpr.h:30