forked from ChrisVeigl/BrainBay
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ob_evaluator.h
92 lines (61 loc) · 2.95 KB
/
ob_evaluator.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/* -----------------------------------------------------------------------------
BrainBay - Evaluator - Object
Provides an interface to the GNU LibMatheval- Library for Expression Evaluation
Authors: Jeremy Wilkerson, Chris Veigl, Aleksandar B. Samardz (libmatheval)
Link to GNU-Libmatheval: http://www.gnu.org/software/libmatheval
Description:
String representation of function is allowed to consist of decimal constants,
variables, elementary functions, unary and binary operations.
Variable name is any combination of alphanumericals and _ characters beginning
with a non-digit that is not elementary function name.
Supported elementary functions are
(names that should be used are given in parenthesis):
exponential (exp), logarithmic (log), square root (sqrt), sine (sin), cosine (cos),
tangent (tan), cotangent (cot), secant (sec), cosecant (csc),
inverse sine (asin), inverse cosine (acos), inverse tangent (atan),
inverse cotangent (acot), inverse secant (asec), inverse cosecant (acsc),
hyperbolic sine (sinh), cosine (cosh), hyperbolic tangent (tanh),
hyperbolic cotangent (coth), hyperbolic secant (sech), hyperbolic cosecant (csch),
hyperbolic inverse sine (asinh), hyperbolic inverse cosine (acosh),
hyperbolic inverse tangent (atanh), hyperbolic inverse cotangent (acoth),
hyperbolic inverse secant (asech), hyperbolic inverse cosecant (acsch),
absolute value (abs), Heaviside step function (step) with value 1 defined
for x = 0 and Dirac delta function with infinity (delta) and
not-a-number (nandelta) values defined for x = 0.
Supported unary operation is unary minus ('-').
Supported binary operations are:
addition ('+'), subtraction ('+'), multiplication ('*'),
division multiplication ('/') and exponentiation ('^').
Usual mathematical rules regarding operation precedence apply.
Parenthesis ('(' and ')') could be used to change priority order.
Blanks and tab characters are allowed in string representing function;
newline characters must not appear in this string.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; See the
GNU General Public License for more details.
----------------------------------------------------------------------------- */
#include "brainBay.h"
#define MAXEXPRLENGTH 256
#define NUMINPUTS 6
class EVALOBJ : public BASE_CL
{
protected:
float inputA, inputB, inputC, inputD, inputE, inputF;
private:
void *evaluator;
int setexp;
public:
EVALOBJ(int num);
char *expression;
void update_inports(void);
void make_dialog(void);
void load(HANDLE hFile);
void save(HANDLE hFile);
void incoming_data(int port, float value);
void work(void);
~EVALOBJ();
friend LRESULT CALLBACK EvalDlgHandler(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
private:
void setExpression(char *expr);
};