C++ Mathematical Expression Toolkit (ExprTk) release
Loading...
Searching...
No Matches
exprtk_mpfr_fiddle.cpp
Go to the documentation of this file.
1#include <cmath>
2#include <cstddef>
3#include <cstdio>
4#include <cstdlib>
5#include <deque>
6#include <fstream>
7#include <iostream>
8#include <numeric>
9#include <string>
10#include <vector>
11
12
13#include <mpreal.h>
15#include "exprtk.hpp"
16
17
18typedef mpfr::mpreal numeric_type;
19typedef std::pair<std::string,numeric_type> test_t;
20
21template <typename T>
22inline bool not_equal_impl(const T& t1,
23 const T& t2,
24 const T& epsilon = 0.000000000001/*std::numeric_limits<T>::epsilon()*/)
25{
26 if (t1 != t1) return true;
27 if (t2 != t2) return true;
28 T diff = mpfr::abs(t1 - t2);
29 T eps_norm = (mpfr::max(T(1),mpfr::max(mpfr::abs(t1),mpfr::abs(t2))) * epsilon);
30 return diff > eps_norm;
31}
32
33template <typename T>
34inline bool not_equal(const T& t0, const T& t1,
35 const T& epsilon = T(0.000000000001))
36{
37 return not_equal_impl(t0,t1,epsilon);
38}
39
40template <typename T>
41inline bool test_expression(const std::string& expression_string, const T& expected_result)
42{
43 exprtk::symbol_table<T> symbol_table;
44 symbol_table.add_constants();
45
58
59 symbol_table.add_function("poly01", poly01);
60 symbol_table.add_function("poly02", poly02);
61 symbol_table.add_function("poly03", poly03);
62 symbol_table.add_function("poly04", poly04);
63 symbol_table.add_function("poly05", poly05);
64 symbol_table.add_function("poly06", poly06);
65 symbol_table.add_function("poly07", poly07);
66 symbol_table.add_function("poly08", poly08);
67 symbol_table.add_function("poly09", poly09);
68 symbol_table.add_function("poly10", poly10);
69 symbol_table.add_function("poly11", poly11);
70 symbol_table.add_function("poly12", poly12);
71
72 exprtk::expression<T> expression;
73 expression.register_symbol_table(symbol_table);
74
75 {
76 exprtk::parser<T> parser;
77
78 if (!parser.compile(expression_string,expression))
79 {
80 printf("test_expression() - Error: %s Expression: %s\n",
81 parser.error().c_str(),
82 expression_string.c_str());
83
84 return false;
85 }
86 }
87
89 {
90 printf("test_expression() - Error: Expression did not compile to a constant! Expression: %s\n",
91 expression_string.c_str());
92
93 return false;
94 }
95
96 const T result = expression.value();
97
98 if (not_equal(result,expected_result))
99 {
100 printf("test_expression() - Computation Error: Expression: [%s]\tExpected: %19.15f\tResult: %19.15f\n",
101 expression_string.c_str(),
102 expected_result.toDouble(),
103 result.toDouble());
104
105 return false;
106 }
107
108 return true;
109}
110
111template <typename T>
113{
114 test_xy(const std::string& e, const T& v0, const T& v1, const T& r)
115 : expr(e),
116 x(v0),
117 y(v1),
118 result(r)
119 {}
120
121 std::string expr;
122 T x;
123 T y;
125};
126
127template <typename T>
129{
130 test_xyzw(const std::string& e, const T& v0, const T& v1, const T& v2, const T& v3, const T& r)
131 : expr(e),
132 x(v0),
133 y(v1),
134 z(v2),
135 w(v3),
136 result(r)
137 {}
138
139 std::string expr;
140 T x;
141 T y;
142 T z;
143 T w;
145};
146
147template <typename T>
148inline bool run_test01()
149{
150 {
151 static const test_xy<T> test_list[] =
152 {
153 test_xy<T>("x + y", T("2.2"), T("3.3"), T("5.5")),
154 test_xy<T>("x - y", T("3.3"), T("2.2"), T("1.1")),
155 test_xy<T>("x * y", T("3.3"), T("2.2"), T("7.26")),
156 test_xy<T>("x / y", T("3.3"), T("2.2"), T("1.5")),
157 test_xy<T>("(x + y) * (x + y)", T("2.2"), T("3.3"), T("30.25")),
158 test_xy<T>("(x + y) / (x + y)", T("2.2"), T("3.3"), T("1.0")),
159 test_xy<T>("x + y > x and x + y > y", T("2.2"), T("3.3"), T("1.0")),
160 test_xy<T>("1 + (x + y)", T("2.2"), T("3.3"), T("6.5")),
161 test_xy<T>("(x + y) - 1", T("2.2"), T("3.3"), T("4.5")),
162 test_xy<T>("1 + (x + y) * 2", T("2.2"), T("3.3"), T("12.0")),
163 test_xy<T>("2 * (x + y) - 1", T("2.2"), T("3.3"), T("10.0")),
164 test_xy<T>("y + (x + 1)", T("2.2"), T("3.3"), T("6.5")),
165 test_xy<T>("(x + 1) + y", T("2.2"), T("3.3"), T("6.5")),
166 test_xy<T>("2 * x", T("2.2"), T("0.0"), T("4.4")),
167 test_xy<T>("x * 2", T("2.2"), T("0.0"), T("4.4")),
168 test_xy<T>("1.1 + x", T("2.2"), T("0.0"), T("3.3")),
169 test_xy<T>("x + 1.1", T("2.2"), T("0.0"), T("3.3")),
170 test_xy<T>("x - -1 ", T("1.0"), T("0.0"), T("2")),
171 test_xy<T>("x --1 ", T("1.0"), T("0.0"), T("2")),
172 test_xy<T>("x-- 1 ", T("1.0"), T("0.0"), T("2")),
173 test_xy<T>("x--1 ", T("1.0"), T("0.0"), T("2")),
174 test_xy<T>("x -- -1", T("1.0"), T("0.0"), T("0")),
175 test_xy<T>("x + -1 ", T("1.0"), T("0.0"), T("0")),
176 test_xy<T>("x +-1 ", T("1.0"), T("0.0"), T("0")),
177 test_xy<T>("x+- 1 ", T("1.0"), T("0.0"), T("0")),
178 test_xy<T>("x+-1 ", T("1.0"), T("0.0"), T("0")),
179 test_xy<T>("x +- -1", T("1.0"), T("0.0"), T("2")),
180 test_xy<T>("x + +1 ", T("1.0"), T("0.0"), T("2")),
181 test_xy<T>("x ++1 ", T("1.0"), T("0.0"), T("2")),
182 test_xy<T>("1 - -x ", T("1.0"), T("0.0"), T("2")),
183 test_xy<T>("1 --x ", T("1.0"), T("0.0"), T("2")),
184 test_xy<T>("1-- x ", T("1.0"), T("0.0"), T("2")),
185 test_xy<T>("1--x ", T("1.0"), T("0.0"), T("2")),
186 test_xy<T>("1 -- -x", T("1.0"), T("0.0"), T("0")),
187 test_xy<T>("1 + -x ", T("1.0"), T("0.0"), T("0")),
188 test_xy<T>("1 +-x ", T("1.0"), T("0.0"), T("0")),
189 test_xy<T>("1+- x ", T("1.0"), T("0.0"), T("0")),
190 test_xy<T>("1+-x ", T("1.0"), T("0.0"), T("0")),
191 test_xy<T>("1 +- -x", T("1.0"), T("0.0"), T("2")),
192 test_xy<T>("1 + +x ", T("1.0"), T("0.0"), T("2")),
193 test_xy<T>("1 ++x ", T("1.0"), T("0.0"), T("2")),
194 test_xy<T>("(x - -1 + 1)", T("1.0"), T("0.0"), T("3")),
195 test_xy<T>("(x --1 + 1)", T("1.0"), T("0.0"), T("3")),
196 test_xy<T>("(x-- 1 + 1)", T("1.0"), T("0.0"), T("3")),
197 test_xy<T>("(x--1 + 1)", T("1.0"), T("0.0"), T("3")),
198 test_xy<T>("(x -- -1 + 1)", T("1.0"), T("0.0"), T("1")),
199 test_xy<T>("(x + -1 + 1)", T("1.0"), T("0.0"), T("1")),
200 test_xy<T>("(x +-1 + 1)", T("1.0"), T("0.0"), T("1")),
201 test_xy<T>("(x+- 1 + 1)", T("1.0"), T("0.0"), T("1")),
202 test_xy<T>("(x+-1 + 1)", T("1.0"), T("0.0"), T("1")),
203 test_xy<T>("(x +- -1 + 1)", T("1.0"), T("0.0"), T("3")),
204 test_xy<T>("(x + +1 + 1)", T("1.0"), T("0.0"), T("3")),
205 test_xy<T>("(x ++1 + 1)", T("1.0"), T("0.0"), T("3")),
206 test_xy<T>("(1 - -x + 1)", T("1.0"), T("0.0"), T("3")),
207 test_xy<T>("(1 --x + 1)", T("1.0"), T("0.0"), T("3")),
208 test_xy<T>("(1-- x + 1)", T("1.0"), T("0.0"), T("3")),
209 test_xy<T>("(1--x + 1)", T("1.0"), T("0.0"), T("3")),
210 test_xy<T>("(1 -- -x + 1)", T("1.0"), T("0.0"), T("1")),
211 test_xy<T>("(1 + -x + 1)", T("1.0"), T("0.0"), T("1")),
212 test_xy<T>("(1 +-x + 1)", T("1.0"), T("0.0"), T("1")),
213 test_xy<T>("(1+- x + 1)", T("1.0"), T("0.0"), T("1")),
214 test_xy<T>("(1+-x + 1)", T("1.0"), T("0.0"), T("1")),
215 test_xy<T>("(1 +- -x + 1)", T("1.0"), T("0.0"), T("3")),
216 test_xy<T>("(1 + +x + 1)", T("1.0"), T("0.0"), T("3")),
217 test_xy<T>("(1 ++x + 1)", T("1.0"), T("0.0"), T("3")),
218 test_xy<T>("(x - -1 - 1)", T("1.0"), T("0.0"), T("1")),
219 test_xy<T>("(x --1 - 1)", T("1.0"), T("0.0"), T("1")),
220 test_xy<T>("(x-- 1 - 1)", T("1.0"), T("0.0"), T("1")),
221 test_xy<T>("(x--1 - 1)", T("1.0"), T("0.0"), T("1")),
222 test_xy<T>("(x -- -1 - 1)", T("1.0"), T("0.0"), T("-1")),
223 test_xy<T>("(x + -1 - 1)", T("1.0"), T("0.0"), T("-1")),
224 test_xy<T>("(x +-1 - 1)", T("1.0"), T("0.0"), T("-1")),
225 test_xy<T>("(x+- 1 - 1)", T("1.0"), T("0.0"), T("-1")),
226 test_xy<T>("(x+-1 - 1)", T("1.0"), T("0.0"), T("-1")),
227 test_xy<T>("(x +- -1 - 1)", T("1.0"), T("0.0"), T("1")),
228 test_xy<T>("(x + +1 - 1)", T("1.0"), T("0.0"), T("1")),
229 test_xy<T>("(x ++1 - 1)", T("1.0"), T("0.0"), T("1")),
230 test_xy<T>("(1 - -x - 1)", T("1.0"), T("0.0"), T("1")),
231 test_xy<T>("(1 --x - 1)", T("1.0"), T("0.0"), T("1")),
232 test_xy<T>("(1-- x - 1)", T("1.0"), T("0.0"), T("1")),
233 test_xy<T>("(1--x - 1)", T("1.0"), T("0.0"), T("1")),
234 test_xy<T>("(1 -- -x - 1)", T("1.0"), T("0.0"), T("-1")),
235 test_xy<T>("(1 + -x - 1)", T("1.0"), T("0.0"), T("-1")),
236 test_xy<T>("(1 +-x - 1)", T("1.0"), T("0.0"), T("-1")),
237 test_xy<T>("(1+- x - 1)", T("1.0"), T("0.0"), T("-1")),
238 test_xy<T>("(1+-x - 1)", T("1.0"), T("0.0"), T("-1")),
239 test_xy<T>("(1 +- -x - 1)", T("1.0"), T("0.0"), T("1")),
240 test_xy<T>("(1 + +x - 1)", T("1.0"), T("0.0"), T("1")),
241 test_xy<T>("(1 ++x - 1)", T("1.0"), T("0.0"), T("1")),
242 test_xy<T>("x * 1 == x", T("2.0"), T("3.0"), T("1.0")),
243 test_xy<T>("1 * x == x", T("2.0"), T("3.0"), T("1.0")),
244 test_xy<T>("y * 1 == y", T("2.0"), T("3.0"), T("1.0")),
245 test_xy<T>("1 * y == y", T("2.0"), T("3.0"), T("1.0")),
246 test_xy<T>("x * 0 == 0", T("2.0"), T("3.0"), T("1.0")),
247 test_xy<T>("0 * x == 0", T("2.0"), T("3.0"), T("1.0")),
248 test_xy<T>("y * 0 == 0", T("2.0"), T("3.0"), T("1.0")),
249 test_xy<T>("0 * y == 0", T("2.0"), T("3.0"), T("1.0")),
250 test_xy<T>("x + 1 == 1 + x", T("2.0"), T("3.0"), T("1.0")),
251 test_xy<T>("y + 1 == 1 + y", T("2.0"), T("3.0"), T("1.0")),
252 test_xy<T>("x + y == y + x", T("2.0"), T("3.0"), T("1.0")),
253 test_xy<T>("x * y == y * x", T("2.0"), T("3.0"), T("1.0")),
254 test_xy<T>("x < y", T("2.0"), T("3.0"), T("1.0")),
255 test_xy<T>("y > x", T("2.0"), T("3.0"), T("1.0")),
256 test_xy<T>("x <= y", T("2.0"), T("3.0"), T("1.0")),
257 test_xy<T>("y >= x", T("2.0"), T("3.0"), T("1.0")),
258 test_xy<T>("x + y > y", T("2.0"), T("3.0"), T("1.0")),
259 test_xy<T>("x + y > x", T("2.0"), T("3.0"), T("1.0")),
260 test_xy<T>("x * y > y", T("2.0"), T("3.0"), T("1.0")),
261 test_xy<T>("x * y > x", T("2.0"), T("3.0"), T("1.0")),
262 test_xy<T>("(x + y) > y", T("2.0"), T("3.0"), T("1.0")),
263 test_xy<T>("(x + y) > x", T("2.0"), T("3.0"), T("1.0")),
264 test_xy<T>("(x * y) > y", T("2.0"), T("3.0"), T("1.0")),
265 test_xy<T>("(x * y) > x", T("2.0"), T("3.0"), T("1.0")),
266 test_xy<T>("(2x + 3y) == (2*x + 3*y)", T("2.0"), T("3.0"), T("1.0")),
267 test_xy<T>("2(x + y) == (2*x + 2*y)", T("2.0"), T("3.0"), T("1.0")),
268 test_xy<T>(" (x + y)3 == (3*x + 3*y)", T("2.0"), T("3.0"), T("1.0")),
269 test_xy<T>("2x + 3y == 2*x + 3*y", T("2.0"), T("3.0"), T("1.0")),
270 test_xy<T>("2(x + y) == 2*x + 2*y", T("2.0"), T("3.0"), T("1.0")),
271 test_xy<T>(" (x + y)3 == 3*x + 3*y", T("2.0"), T("3.0"), T("1.0")),
272 test_xy<T>(" (x)y == (x*y)", T("2.0"), T("3.0"), T("1.0")),
273 test_xy<T>(" x(y) == (x*y)", T("2.0"), T("3.0"), T("1.0")),
274 test_xy<T>(" (x) y == (x*y)", T("2.0"), T("3.0"), T("1.0")),
275 test_xy<T>(" x (y) == (x*y)", T("2.0"), T("3.0"), T("1.0")),
276 test_xy<T>(" ((x) y) == (x*y)", T("2.0"), T("3.0"), T("1.0")),
277 test_xy<T>(" (x (y)) == (x*y)", T("2.0"), T("3.0"), T("1.0")),
278 test_xy<T>(" (x)3 == (x*3)", T("2.0"), T("3.0"), T("1.0")),
279 test_xy<T>(" x(3) == (x*3)", T("2.0"), T("3.0"), T("1.0")),
280 test_xy<T>(" (x) 3 == (x*3)", T("2.0"), T("3.0"), T("1.0")),
281 test_xy<T>(" x (3) == (x*3)", T("2.0"), T("3.0"), T("1.0")),
282 test_xy<T>(" ((x) 3) == (x*3)", T("2.0"), T("3.0"), T("1.0")),
283 test_xy<T>(" (x (3)) == (x*3)", T("2.0"), T("3.0"), T("1.0")),
284 test_xy<T>(" (2)y == (2*y)", T("2.0"), T("3.0"), T("1.0")),
285 test_xy<T>(" 2(y) == (2*y)", T("2.0"), T("3.0"), T("1.0")),
286 test_xy<T>(" (2) y == (2*y)", T("2.0"), T("3.0"), T("1.0")),
287 test_xy<T>(" 2 (y) == (2*y)", T("2.0"), T("3.0"), T("1.0")),
288 test_xy<T>(" ((2) y) == (2*y)", T("2.0"), T("3.0"), T("1.0")),
289 test_xy<T>(" (2 (y)) == (2*y)", T("2.0"), T("3.0"), T("1.0")),
290 test_xy<T>("var a := 2; (a)(3) == 6", T("2.0"), T("3.0"), T("1.0")),
291 test_xy<T>("var a := 2; (A){3} == 6", T("2.0"), T("3.0"), T("1.0")),
292 test_xy<T>("var a := 2; (a)[3] == 6", T("2.0"), T("3.0"), T("1.0")),
293 test_xy<T>("var a := 2; {a}(3) == 6", T("2.0"), T("3.0"), T("1.0")),
294 test_xy<T>("var a := 2; {a}{3} == 6", T("2.0"), T("3.0"), T("1.0")),
295 test_xy<T>("var a := 2; {a}[3] == 6", T("2.0"), T("3.0"), T("1.0")),
296 test_xy<T>("var a := 2; var b := 3; (a)(b) == 6", T("2.0"), T("3.0"), T("1.0")),
297 test_xy<T>("var a := 2; var b := 3; (a){B} == 6", T("2.0"), T("3.0"), T("1.0")),
298 test_xy<T>("var a := 2; var b := 3; (a)[b] == 6", T("2.0"), T("3.0"), T("1.0")),
299 test_xy<T>("var a := 2; var b := 3; {a}(b) == 6", T("2.0"), T("3.0"), T("1.0")),
300 test_xy<T>("var a := 2; var b := 3; {a}{b} == 6", T("2.0"), T("3.0"), T("1.0")),
301 test_xy<T>("var a := 2; var b := 3; {a}[b] == 6", T("2.0"), T("3.0"), T("1.0")),
302 test_xy<T>("var a := 2; (a)(a+1) == 6", T("2.0"), T("3.0"), T("1.0")),
303 test_xy<T>("var a := 2; (a){a+1} == 6", T("2.0"), T("3.0"), T("1.0")),
304 test_xy<T>("var a := 2; (a)[a+1] == 6", T("2.0"), T("3.0"), T("1.0")),
305 test_xy<T>("var a := 2; {a}(a+1) == 6", T("2.0"), T("3.0"), T("1.0")),
306 test_xy<T>("var a := 2; {a}{a+1} == 6", T("2.0"), T("3.0"), T("1.0")),
307 test_xy<T>("var a := 2; {a}[a+1] == 6", T("2.0"), T("3.0"), T("1.0")),
308 test_xy<T>("var a := 2; var b := 3; (b-1)(b) == 6", T("2.0"), T("3.0"), T("1.0")),
309 test_xy<T>("var a := 2; var b := 3; (b-1){b} == 6", T("2.0"), T("3.0"), T("1.0")),
310 test_xy<T>("var a := 2; var b := 3; (b-1)[b] == 6", T("2.0"), T("3.0"), T("1.0")),
311 test_xy<T>("var a := 2; var b := 3; {b-1}(b) == 6", T("2.0"), T("3.0"), T("1.0")),
312 test_xy<T>("var a := 2; var b := 3; {b-1}{b} == 6", T("2.0"), T("3.0"), T("1.0")),
313 test_xy<T>("var a := 2; var b := 3; {b-1}[b] == 6", T("2.0"), T("3.0"), T("1.0")),
315 "abs(x^2.2^1.1 - 17.15193942371376191362472354210675542022)", T("3.3"), T("0.0"), T("0.0")),
317 "equal(x^2.2^1.1,17.15193942371376191362472354210675542022)", T("3.3"), T("0.0"), T("1.0")),
319 "equal(3.3^x^1.1,17.15193942371376191362472354210675542022)", T("2.2"), T("0.0"), T("1.0")),
321 "equal(3.3^2.2^x,17.15193942371376191362472354210675542022)", T("1.1"), T("0.0"), T("1.0")),
322 test_xy<T>("equal(x^2.2^y,17.15193942371376191362472354210675542022)", T("3.3"), T("1.1"), T("1.0")),
323 test_xy<T>("equal(x^y^1.1,17.15193942371376191362472354210675542022)", T("3.3"), T("2.2"), T("1.0")),
324 test_xy<T>("equal(3.3^x^y,17.15193942371376191362472354210675542022)", T("2.2"), T("1.1"), T("1.0")),
325 test_xy<T>("equal(x+y^3/7,x+(y*y*y)/7)", T("2.0"), T("3.0"), T("1.0")),
326 test_xy<T>("equal(1-x^3+y^2*7,1-(x*x*x)+(y*y)*7)", T("2.0"), T("3.0"), T("1.0")),
327 test_xy<T>("equal( x^0,1)", T("12.34"), T("0.0"), T("1.0")),
328 test_xy<T>("equal( x^1,x)", T("12.34"), T("0.0"), T("1.0")),
329 test_xy<T>("equal( x^2,x*x)", T("12.34"), T("0.0"), T("1.0")),
330 test_xy<T>("equal( x^3,x*x*x)", T("12.34"), T("0.0"), T("1.0")),
331 test_xy<T>("equal( x^4,x*x*x*x)", T("12.34"), T("0.0"), T("1.0")),
332 test_xy<T>("equal( x^5,x*x*x*x*x)", T("12.34"), T("0.0"), T("1.0")),
333 test_xy<T>("equal( x^6,x*x*x*x*x*x)", T("12.34"), T("0.0"), T("1.0")),
334 test_xy<T>("equal( x^7,x*x*x*x*x*x*x)", T("12.34"), T("0.0"), T("1.0")),
335 test_xy<T>("equal( x^8,x*x*x*x*x*x*x*x)", T("12.34"), T("0.0"), T("1.0")),
336 test_xy<T>("equal( x^9,x*x*x*x*x*x*x*x*x)", T("12.34"), T("0.0"), T("1.0")),
337 test_xy<T>("equal(x^10,x*x*x*x*x*x*x*x*x*x)", T("12.34"), T("0.0"), T("1.0")),
338 test_xy<T>("equal(x^11,x*x*x*x*x*x*x*x*x*x*x)", T("12.34"), T("0.0"), T("1.0")),
339 test_xy<T>("equal(x^12,x*x*x*x*x*x*x*x*x*x*x*x)", T("12.34"), T("0.0"), T("1.0")),
340 test_xy<T>("equal(x^13,x*x*x*x*x*x*x*x*x*x*x*x*x)", T("12.34"), T("0.0"), T("1.0")),
341 test_xy<T>("equal(x^14,x*x*x*x*x*x*x*x*x*x*x*x*x*x)", T("12.34"), T("0.0"), T("1.0")),
342 test_xy<T>("equal(x^15,x*x*x*x*x*x*x*x*x*x*x*x*x*x*x)", T("12.34"), T("0.0"), T("1.0")),
343 test_xy<T>("equal(x^16,x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x)", T("12.34"), T("0.0"), T("1.0")),
344 test_xy<T>("equal(x^17,x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x)", T("12.34"), T("0.0"), T("1.0")),
345 test_xy<T>("equal(x^18,x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x)", T("12.34"), T("0.0"), T("1.0")),
346 test_xy<T>("equal(x^19,x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x)", T("12.34"), T("0.0"), T("1.0")),
347 test_xy<T>("equal(x^20,x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x)", T("12.34"), T("0.0"), T("1.0")),
348 test_xy<T>("equal(x^21,x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x)", T("12.34"), T("0.0"), T("1.0")),
350 "equal(x^22,x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x)", T("12.34"), T("0.0"), T("1.0")),
352 "equal(x^23,x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x)", T("12.34"), T("0.0"), T("1.0")),
354 "equal(x^24,x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x)", T("12.34"), T("0.0"), T("1.0")),
356 "equal(x^25,x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x)", T("12.34"), T("0.0"), T("1.0")),
357 test_xy<T>("equal( y^0,1)", T("0.0"), T("12.34"), T("1.0")),
358 test_xy<T>("equal( y^1,y)", T("0.0"), T("12.34"), T("1.0")),
359 test_xy<T>("equal( y^2,y*y)", T("0.0"), T("12.34"), T("1.0")),
360 test_xy<T>("equal( y^3,y*y*y)", T("0.0"), T("12.34"), T("1.0")),
361 test_xy<T>("equal( y^4,y*y*y*y)", T("0.0"), T("12.34"), T("1.0")),
362 test_xy<T>("equal( y^5,y*y*y*y*y)", T("0.0"), T("12.34"), T("1.0")),
363 test_xy<T>("equal( y^6,y*y*y*y*y*y)", T("0.0"), T("12.34"), T("1.0")),
364 test_xy<T>("equal( y^7,y*y*y*y*y*y*y)", T("0.0"), T("12.34"), T("1.0")),
365 test_xy<T>("equal( y^8,y*y*y*y*y*y*y*y)", T("0.0"), T("12.34"), T("1.0")),
366 test_xy<T>("equal( y^9,y*y*y*y*y*y*y*y*y)", T("0.0"), T("12.34"), T("1.0")),
367 test_xy<T>("equal(y^10,y*y*y*y*y*y*y*y*y*y)", T("0.0"), T("12.34"), T("1.0")),
368 test_xy<T>("equal(y^11,y*y*y*y*y*y*y*y*y*y*y)", T("0.0"), T("12.34"), T("1.0")),
369 test_xy<T>("equal(y^12,y*y*y*y*y*y*y*y*y*y*y*y)", T("0.0"), T("12.34"), T("1.0")),
370 test_xy<T>("equal(y^13,y*y*y*y*y*y*y*y*y*y*y*y*y)", T("0.0"), T("12.34"), T("1.0")),
371 test_xy<T>("equal(y^14,y*y*y*y*y*y*y*y*y*y*y*y*y*y)", T("0.0"), T("12.34"), T("1.0")),
372 test_xy<T>("equal(y^15,y*y*y*y*y*y*y*y*y*y*y*y*y*y*y)", T("0.0"), T("12.34"), T("1.0")),
373 test_xy<T>("equal(y^16,y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y)", T("0.0"), T("12.34"), T("1.0")),
374 test_xy<T>("equal(y^17,y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y)", T("0.0"), T("12.34"), T("1.0")),
375 test_xy<T>("equal(y^18,y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y)", T("0.0"), T("12.34"), T("1.0")),
376 test_xy<T>("equal(y^19,y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y)", T("0.0"), T("12.34"), T("1.0")),
377 test_xy<T>("equal(y^20,y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y)", T("0.0"), T("12.34"), T("1.0")),
378 test_xy<T>("equal(y^21,y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y)", T("0.0"), T("12.34"), T("1.0")),
380 "equal(y^22,y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y)", T("0.0"), T("12.34"), T("1.0")),
382 "equal(y^23,y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y)", T("0.0"), T("12.34"), T("1.0")),
384 "equal(y^24,y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y)", T("0.0"), T("12.34"), T("1.0")),
386 "equal(y^25,y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y)", T("0.0"), T("12.34"), T("1.0")),
387 test_xy<T>("equal( x^-0,1/1)", T("12.34"), T("0.0"), T("1.0")),
388 test_xy<T>("equal( x^-1,1/(x))", T("12.34"), T("0.0"), T("1.0")),
389 test_xy<T>("equal( x^-2,1/(x*x))", T("12.34"), T("0.0"), T("1.0")),
390 test_xy<T>("equal( x^-3,1/(x*x*x))", T("12.34"), T("0.0"), T("1.0")),
391 test_xy<T>("equal( x^-4,1/(x*x*x*x))", T("12.34"), T("0.0"), T("1.0")),
392 test_xy<T>("equal( x^-5,1/(x*x*x*x*x))", T("12.34"), T("0.0"), T("1.0")),
393 test_xy<T>("equal( x^-6,1/(x*x*x*x*x*x))", T("12.34"), T("0.0"), T("1.0")),
394 test_xy<T>("equal( x^-7,1/(x*x*x*x*x*x*x))", T("12.34"), T("0.0"), T("1.0")),
395 test_xy<T>("equal( x^-8,1/(x*x*x*x*x*x*x*x))", T("12.34"), T("0.0"), T("1.0")),
396 test_xy<T>("equal( x^-9,1/(x*x*x*x*x*x*x*x*x))", T("12.34"), T("0.0"), T("1.0")),
397 test_xy<T>("equal(x^-10,1/(x*x*x*x*x*x*x*x*x*x))", T("12.34"), T("0.0"), T("1.0")),
398 test_xy<T>("equal(x^-11,1/(x*x*x*x*x*x*x*x*x*x*x))", T("12.34"), T("0.0"), T("1.0")),
399 test_xy<T>("equal(x^-12,1/(x*x*x*x*x*x*x*x*x*x*x*x))", T("12.34"), T("0.0"), T("1.0")),
400 test_xy<T>("equal(x^-13,1/(x*x*x*x*x*x*x*x*x*x*x*x*x))", T("12.34"), T("0.0"), T("1.0")),
401 test_xy<T>("equal(x^-14,1/(x*x*x*x*x*x*x*x*x*x*x*x*x*x))", T("12.34"), T("0.0"), T("1.0")),
402 test_xy<T>("equal(x^-15,1/(x*x*x*x*x*x*x*x*x*x*x*x*x*x*x))", T("12.34"), T("0.0"), T("1.0")),
403 test_xy<T>("equal(x^-16,1/(x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x))", T("12.34"), T("0.0"), T("1.0")),
404 test_xy<T>("equal(x^-17,1/(x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x))", T("12.34"), T("0.0"), T("1.0")),
405 test_xy<T>("equal(x^-18,1/(x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x))", T("12.34"), T("0.0"), T("1.0")),
406 test_xy<T>("equal(x^-19,1/(x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x))", T("12.34"), T("0.0"), T("1.0")),
408 "equal(x^-20,1/(x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x))", T("12.34"), T("0.0"), T("1.0")),
410 "equal(x^-21,1/(x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x))", T("12.34"), T("0.0"), T("1.0")),
412 "equal(x^-22,1/(x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x))", T("12.34"), T("0.0"), T("1.0")),
414 "equal(x^-23,1/(x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x))", T("12.34"), T("0.0"), T("1.0")),
415 test_xy<T>("equal(x^-24,1/(x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x))",
416 T("12.34"),
417 T("0.0"),
418 T("1.0")),
419 test_xy<T>("equal(x^-25,1/(x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x))",
420 T("12.34"),
421 T("0.0"),
422 T("1.0")),
423 test_xy<T>("equal( y^-0,1/1)", T("0.0"), T("12.34"), T("1.0")),
424 test_xy<T>("equal( y^-1,1/(y))", T("0.0"), T("12.34"), T("1.0")),
425 test_xy<T>("equal( y^-2,1/(y*y))", T("0.0"), T("12.34"), T("1.0")),
426 test_xy<T>("equal( y^-3,1/(y*y*y))", T("0.0"), T("12.34"), T("1.0")),
427 test_xy<T>("equal( y^-4,1/(y*y*y*y))", T("0.0"), T("12.34"), T("1.0")),
428 test_xy<T>("equal( y^-5,1/(y*y*y*y*y))", T("0.0"), T("12.34"), T("1.0")),
429 test_xy<T>("equal( y^-6,1/(y*y*y*y*y*y))", T("0.0"), T("12.34"), T("1.0")),
430 test_xy<T>("equal( y^-7,1/(y*y*y*y*y*y*y))", T("0.0"), T("12.34"), T("1.0")),
431 test_xy<T>("equal( y^-8,1/(y*y*y*y*y*y*y*y))", T("0.0"), T("12.34"), T("1.0")),
432 test_xy<T>("equal( y^-9,1/(y*y*y*y*y*y*y*y*y))", T("0.0"), T("12.34"), T("1.0")),
433 test_xy<T>("equal(y^-10,1/(y*y*y*y*y*y*y*y*y*y))", T("0.0"), T("12.34"), T("1.0")),
434 test_xy<T>("equal(y^-11,1/(y*y*y*y*y*y*y*y*y*y*y))", T("0.0"), T("12.34"), T("1.0")),
435 test_xy<T>("equal(y^-12,1/(y*y*y*y*y*y*y*y*y*y*y*y))", T("0.0"), T("12.34"), T("1.0")),
436 test_xy<T>("equal(y^-13,1/(y*y*y*y*y*y*y*y*y*y*y*y*y))", T("0.0"), T("12.34"), T("1.0")),
437 test_xy<T>("equal(y^-14,1/(y*y*y*y*y*y*y*y*y*y*y*y*y*y))", T("0.0"), T("12.34"), T("1.0")),
438 test_xy<T>("equal(y^-15,1/(y*y*y*y*y*y*y*y*y*y*y*y*y*y*y))", T("0.0"), T("12.34"), T("1.0")),
439 test_xy<T>("equal(y^-16,1/(y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y))", T("0.0"), T("12.34"), T("1.0")),
440 test_xy<T>("equal(y^-17,1/(y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y))", T("0.0"), T("12.34"), T("1.0")),
441 test_xy<T>("equal(y^-18,1/(y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y))", T("0.0"), T("12.34"), T("1.0")),
442 test_xy<T>("equal(y^-19,1/(y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y))", T("0.0"), T("12.34"), T("1.0")),
444 "equal(y^-20,1/(y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y))", T("0.0"), T("12.34"), T("1.0")),
446 "equal(y^-21,1/(y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y))", T("0.0"), T("12.34"), T("1.0")),
448 "equal(y^-22,1/(y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y))", T("0.0"), T("12.34"), T("1.0")),
450 "equal(y^-23,1/(y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y))", T("0.0"), T("12.34"), T("1.0")),
451 test_xy<T>("equal(y^-24,1/(y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y))",
452 T("0.0"),
453 T("12.34"),
454 T("1.0")),
455 test_xy<T>("equal(y^-25,1/(y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y*y))",
456 T("0.0"),
457 T("12.34"),
458 T("1.0")),
459 test_xy<T>("(2 + x) + 7", T("3.0"), T("0.0"), T((2.0 + 3.0) + 7.0)),
460 test_xy<T>("(2 + x) - 7", T("3.0"), T("0.0"), T((2.0 + 3.0) - 7.0)),
461 test_xy<T>("(2 - x) + 7", T("3.0"), T("0.0"), T((2.0 - 3.0) + 7.0)),
462 test_xy<T>("(2 - x) - 7", T("3.0"), T("0.0"), T((2.0 - 3.0) - 7.0)),
463 test_xy<T>("(2 * x) * 7", T("3.0"), T("0.0"), T((2.0 * 3.0) * 7.0)),
464 test_xy<T>("(2 * x) / 7", T("3.0"), T("0.0"), T((2.0 * 3.0) / 7.0)),
465 test_xy<T>("(2 / x) * 7", T("3.0"), T("0.0"), T((2.0 / 3.0) * 7.0)),
466 test_xy<T>("(2 / x) / 7", T("3.0"), T("0.0"), T((2.0 / 3.0) / 7.0)),
467 test_xy<T>("2 + (x + 7)", T("3.0"), T("0.0"), T(2.0 + (3.0 + 7.0))),
468 test_xy<T>("2 + (x - 7)", T("3.0"), T("0.0"), T(2.0 + (3.0 - 7.0))),
469 test_xy<T>("2 - (x + 7)", T("3.0"), T("0.0"), T(2.0 - (3.0 + 7.0))),
470 test_xy<T>("2 - (x - 7)", T("3.0"), T("0.0"), T(2.0 - (3.0 - 7.0))),
471 test_xy<T>("2 * (x * 7)", T("3.0"), T("0.0"), T(2.0 * (3.0 * 7.0))),
472 test_xy<T>("2 * (x / 7)", T("3.0"), T("0.0"), T(2.0 * (3.0 / 7.0))),
473 test_xy<T>("2 / (x * 7)", T("3.0"), T("0.0"), T(2.0 / (3.0 * 7.0))),
474 test_xy<T>("2 / (x / 7)", T("3.0"), T("0.0"), T(2.0 / (3.0 / 7.0))),
475 test_xy<T>("2 + (7 + x)", T("3.0"), T("0.0"), T(2.0 + (7.0 + 3.0))),
476 test_xy<T>("2 + (7 - x)", T("3.0"), T("0.0"), T(2.0 + (7.0 - 3.0))),
477 test_xy<T>("2 - (7 + x)", T("3.0"), T("0.0"), T(2.0 - (7.0 + 3.0))),
478 test_xy<T>("2 - (7 - x)", T("3.0"), T("0.0"), T(2.0 - (7.0 - 3.0))),
479 test_xy<T>("2 * (7 * x)", T("3.0"), T("0.0"), T(2.0 * (7.0 * 3.0))),
480 test_xy<T>("2 * (7 / x)", T("3.0"), T("0.0"), T(2.0 * (7.0 / 3.0))),
481 test_xy<T>("2 / (7 * x)", T("3.0"), T("0.0"), T(2.0 / (7.0 * 3.0))),
482 test_xy<T>("2 / (7 / x)", T("3.0"), T("0.0"), T(2.0 / (7.0 / 3.0))),
483 test_xy<T>("(x + 2) + 7", T("3.0"), T("0.0"), T((3.0 + 2.0) + 7.0)),
484 test_xy<T>("(x + 2) - 7", T("3.0"), T("0.0"), T((3.0 + 2.0) - 7.0)),
485 test_xy<T>("(x - 2) + 7", T("3.0"), T("0.0"), T((3.0 - 2.0) + 7.0)),
486 test_xy<T>("(x - 2) - 7", T("3.0"), T("0.0"), T((3.0 - 2.0) - 7.0)),
487 test_xy<T>("(x * 2) * 7", T("3.0"), T("0.0"), T((3.0 * 2.0) * 7.0)),
488 test_xy<T>("(x * 2) / 7", T("3.0"), T("0.0"), T((3.0 * 2.0) / 7.0)),
489 test_xy<T>("(x / 2) * 7", T("3.0"), T("0.0"), T((3.0 / 2.0) * 7.0)),
490 test_xy<T>("(x / 2) / 7", T("3.0"), T("0.0"), T((3.0 / 2.0) / 7.0)),
491 test_xy<T>("((2 + x) + (3 + y))", T("7.0"), T("9.0"), T(((2.0 + 7.0) + (3.0 + 9.0)))),
492 test_xy<T>("((2 + x) - (3 + y))", T("7.0"), T("9.0"), T(((2.0 + 7.0) - (3.0 + 9.0)))),
493 test_xy<T>("((2 - x) - (3 - y))", T("7.0"), T("9.0"), T(((2.0 - 7.0) - (3.0 - 9.0)))),
494 test_xy<T>("((2 * x) * (3 * y))", T("7.0"), T("9.0"), T(((2.0 * 7.0) * (3.0 * 9.0)))),
495 test_xy<T>("((x + 2) + (y + 3))", T("7.0"), T("9.0"), T(((7.0 + 2.0) + (9.0 + 3.0)))),
496 test_xy<T>("((x + 2) - (y + 3))", T("7.0"), T("9.0"), T(((7.0 + 2.0) - (9.0 + 3.0)))),
497 test_xy<T>("((x - 2) - (y - 3))", T("7.0"), T("9.0"), T(((7.0 - 2.0) - (9.0 - 3.0)))),
498 test_xy<T>("((2 * x) * (3 * y))", T("7.0"), T("9.0"), T(((2.0 * 7.0) * (3.0 * 9.0)))),
499 test_xy<T>("((2 + x) + (y + 3))", T("7.0"), T("9.0"), T(((2.0 + 7.0) + (9.0 + 3.0)))),
500 test_xy<T>("((2 + x) - (y + 3))", T("7.0"), T("9.0"), T(((2.0 + 7.0) - (9.0 + 3.0)))),
501 test_xy<T>("((2 - x) - (y - 3))", T("7.0"), T("9.0"), T(((2.0 - 7.0) - (9.0 - 3.0)))),
502 test_xy<T>("((2 * x) * (3 * y))", T("7.0"), T("9.0"), T(((2.0 * 7.0) * (3.0 * 9.0)))),
503 test_xy<T>("((x + 2) + (3 + y))", T("7.0"), T("9.0"), T(((7.0 + 2.0) + (3.0 + 9.0)))),
504 test_xy<T>("((x + 2) - (3 + y))", T("7.0"), T("9.0"), T(((7.0 + 2.0) - (3.0 + 9.0)))),
505 test_xy<T>("((x - 2) - (3 - y))", T("7.0"), T("9.0"), T(((7.0 - 2.0) - (3.0 - 9.0)))),
506 test_xy<T>("((2 * x) * (3 * y))", T("7.0"), T("9.0"), T(((2.0 * 7.0) * (3.0 * 9.0)))),
507 test_xy<T>("((2 * x) / (3 * y))", T("7.0"), T("9.0"), T(((2.0 * 7.0) / (3.0 * 9.0)))),
508 test_xy<T>("((2 / x) * (3 / y))", T("7.0"), T("9.0"), T(((2.0 / 7.0) * (3.0 / 9.0)))),
509 test_xy<T>("((2 * x) / (3 / y))", T("7.0"), T("9.0"), T(((2.0 * 7.0) / (3.0 / 9.0)))),
510 test_xy<T>("((2 / x) / (3 * y))", T("7.0"), T("9.0"), T(((2.0 / 7.0) / (3.0 * 9.0)))),
511 test_xy<T>("((x * 2) / (y * 3))", T("7.0"), T("9.0"), T(((7.0 * 2.0) / (9.0 * 3.0)))),
512 test_xy<T>("((x / 2) * (y / 3))", T("7.0"), T("9.0"), T(((7.0 / 2.0) * (9.0 / 3.0)))),
513 test_xy<T>("((x * 2) / (y / 3))", T("7.0"), T("9.0"), T(((7.0 * 2.0) / (9.0 / 3.0)))),
514 test_xy<T>("((x / 2) / (y * 3))", T("7.0"), T("9.0"), T(((7.0 / 2.0) / (9.0 * 3.0)))),
515 test_xy<T>("((2 * x) / (y * 3))", T("7.0"), T("9.0"), T(((2.0 * 7.0) / (9.0 * 3.0)))),
516 test_xy<T>("((2 / x) * (y / 3))", T("7.0"), T("9.0"), T(((2.0 / 7.0) * (9.0 / 3.0)))),
517 test_xy<T>("((2 * x) / (y / 3))", T("7.0"), T("9.0"), T(((2.0 * 7.0) / (9.0 / 3.0)))),
518 test_xy<T>("((2 / x) / (y * 3))", T("7.0"), T("9.0"), T(((2.0 / 7.0) / (9.0 * 3.0)))),
519 test_xy<T>("((x * 2) / (3 * y))", T("7.0"), T("9.0"), T(((7.0 * 2.0) / (3.0 * 9.0)))),
520 test_xy<T>("((x / 2) * (3 / y))", T("7.0"), T("9.0"), T(((7.0 / 2.0) * (3.0 / 9.0)))),
521 test_xy<T>("((x * 2) / (3 / y))", T("7.0"), T("9.0"), T(((7.0 * 2.0) / (3.0 / 9.0)))),
522 test_xy<T>("((x / 2) / (3 * y))", T("7.0"), T("9.0"), T(((7.0 / 2.0) / (3.0 * 9.0)))),
524 "([(min(x,8) + y) + 3] - 4)", T("7.0"), T("9.0"), T((((std::min(7.0, 8.0) + 9.0) + 3.0) - 4.0))),
526 "([(min(x,8) + y) + 3] + 4)", T("7.0"), T("9.0"), T((((std::min(7.0, 8.0) + 9.0) + 3.0) + 4.0))),
528 "([(min(x,8) + y) + 3] * 4)", T("7.0"), T("9.0"), T((((std::min(7.0, 8.0) + 9.0) + 3.0) * 4.0))),
530 "([(min(x,8) + y) + 3] / 4)", T("7.0"), T("9.0"), T((((std::min(7.0, 8.0) + 9.0) + 3.0) / 4.0))),
532 "([(min(x,8) + y) - 3] - 4)", T("7.0"), T("9.0"), T((((std::min(7.0, 8.0) + 9.0) - 3.0) - 4.0))),
534 "([(min(x,8) + y) - 3] + 4)", T("7.0"), T("9.0"), T((((std::min(7.0, 8.0) + 9.0) - 3.0) + 4.0))),
536 "([(min(x,8) + y) - 3] * 4)", T("7.0"), T("9.0"), T((((std::min(7.0, 8.0) + 9.0) - 3.0) * 4.0))),
538 "([(min(x,8) + y) - 3] / 4)", T("7.0"), T("9.0"), T((((std::min(7.0, 8.0) + 9.0) - 3.0) / 4.0))),
540 "([(min(x,8) + y) * 3] - 4)", T("7.0"), T("9.0"), T((((std::min(7.0, 8.0) + 9.0) * 3.0) - 4.0))),
542 "([(min(x,8) + y) * 3] + 4)", T("7.0"), T("9.0"), T((((std::min(7.0, 8.0) + 9.0) * 3.0) + 4.0))),
544 "([(min(x,8) + y) * 3] * 4)", T("7.0"), T("9.0"), T((((std::min(7.0, 8.0) + 9.0) * 3.0) * 4.0))),
546 "([(min(x,8) + y) * 3] / 4)", T("7.0"), T("9.0"), T((((std::min(7.0, 8.0) + 9.0) * 3.0) / 4.0))),
548 "([(min(x,8) + y) / 3] - 4)", T("7.0"), T("9.0"), T((((std::min(7.0, 8.0) + 9.0) / 3.0) - 4.0))),
550 "([(min(x,8) + y) / 3] + 4)", T("7.0"), T("9.0"), T((((std::min(7.0, 8.0) + 9.0) / 3.0) + 4.0))),
552 "([(min(x,8) + y) / 3] * 4)", T("7.0"), T("9.0"), T((((std::min(7.0, 8.0) + 9.0) / 3.0) * 4.0))),
554 "([(min(x,8) + y) / 3] / 4)", T("7.0"), T("9.0"), T((((std::min(7.0, 8.0) + 9.0) / 3.0) / 4.0))),
556 "(4 - [3 + (min(x,8) + y)])", T("7.0"), T("9.0"), T((4.0 - (3.0 + (std::min(7.0, 8.0) + 9.0))))),
558 "(4 + [3 + (min(x,8) + y)])", T("7.0"), T("9.0"), T((4.0 + (3.0 + (std::min(7.0, 8.0) + 9.0))))),
560 "(4 * [3 + (min(x,8) + y)])", T("7.0"), T("9.0"), T((4.0 * (3.0 + (std::min(7.0, 8.0) + 9.0))))),
562 "(4 / [3 + (min(x,8) + y)])", T("7.0"), T("9.0"), T((4.0 / (3.0 + (std::min(7.0, 8.0) + 9.0))))),
564 "(4 - [3 - (min(x,8) + y)])", T("7.0"), T("9.0"), T((4.0 - (3.0 - (std::min(7.0, 8.0) + 9.0))))),
566 "(4 + [3 - (min(x,8) + y)])", T("7.0"), T("9.0"), T((4.0 + (3.0 - (std::min(7.0, 8.0) + 9.0))))),
568 "(4 * [3 - (min(x,8) + y)])", T("7.0"), T("9.0"), T((4.0 * (3.0 - (std::min(7.0, 8.0) + 9.0))))),
570 "(4 / [3 - (min(x,8) + y)])", T("7.0"), T("9.0"), T((4.0 / (3.0 - (std::min(7.0, 8.0) + 9.0))))),
572 "(4 - [3 * (min(x,8) + y)])", T("7.0"), T("9.0"), T((4.0 - (3.0 * (std::min(7.0, 8.0) + 9.0))))),
574 "(4 + [3 * (min(x,8) + y)])", T("7.0"), T("9.0"), T((4.0 + (3.0 * (std::min(7.0, 8.0) + 9.0))))),
576 "(4 * [3 * (min(x,8) + y)])", T("7.0"), T("9.0"), T((4.0 * (3.0 * (std::min(7.0, 8.0) + 9.0))))),
578 "(4 / [3 * (min(x,8) + y)])", T("7.0"), T("9.0"), T((4.0 / (3.0 * (std::min(7.0, 8.0) + 9.0))))),
580 "(4 - [3 / (min(x,8) + y)])", T("7.0"), T("9.0"), T((4.0 - (3.0 / (std::min(7.0, 8.0) + 9.0))))),
582 "(4 + [3 / (min(x,8) + y)])", T("7.0"), T("9.0"), T((4.0 + (3.0 / (std::min(7.0, 8.0) + 9.0))))),
584 "(4 * [3 / (min(x,8) + y)])", T("7.0"), T("9.0"), T((4.0 * (3.0 / (std::min(7.0, 8.0) + 9.0))))),
586 "(4 / [3 / (min(x,8) + y)])", T("7.0"), T("9.0"), T((4.0 / (3.0 / (std::min(7.0, 8.0) + 9.0))))),
587 test_xy<T>("((2 * x) + (2 * y))", T("7.0"), T("9.0"), T(((2.0 * 7.0) + (2.0 * 9.0)))),
588 test_xy<T>("((2 * x) - (2 * y))", T("7.0"), T("9.0"), T(((2.0 * 7.0) - (2.0 * 9.0)))),
589 test_xy<T>("((2 * x) + (y * 2))", T("7.0"), T("9.0"), T(((2.0 * 7.0) + (9.0 * 2.0)))),
590 test_xy<T>("((x * 2) - (y * 2))", T("7.0"), T("9.0"), T(((7.0 * 2.0) - (9.0 * 2.0)))),
591 test_xy<T>("0 * (abs (x) + acos (y) + asin (x) + atan (y))", T("1.0"), T("1.0"), T("0.0")),
592 test_xy<T>("0 * (ceil (x) + cos (y) + cosh (x) + exp (y))", T("1.0"), T("1.0"), T("0.0")),
593 test_xy<T>("0 * (floor(x) + log (y) + log10(x) + round(y))", T("1.0"), T("1.0"), T("0.0")),
594 test_xy<T>("0 * (sin (x) + sinh (y) + sqrt (x) + tan (y))", T("1.0"), T("1.0"), T("0.0")),
595 test_xy<T>("0 * (sec (x) + csc (y) + tanh (x) + cot (y))", T("1.0"), T("1.0"), T("0.0")),
596 test_xy<T>("0 * (erf (x) + erfc (y) + sgn (y) + frac (y))", T("1.0"), T("1.0"), T("0.0")),
597 test_xy<T>("0 * (log1p(x) + expm1(y) + acosh(x) + asinh(y))", T("1.0"), T("1.0"), T("0.0")),
599 "0 * (deg2grad(x) + grad2deg(y) + rad2deg(x) + deg2rad(y))", T("1.0"), T("1.0"), T("0.0")),
600 test_xy<T>("switch { case (x <= y) : (y - x); default: 1.12345; }", T("1.0"), T("2.0"), T("1.0")),
601 test_xy<T>("switch { case (x > y) : 0; case (x <= y) : (y - x); default: 1.12345; }",
602 T("1.0"),
603 T("2.0"),
604 T("1.0")),
606 "switch { case (x <= y) : switch { case (x <= y) : (y - x); default: 1.12345; }; default: 1.12345; }",
607 T("1.0"),
608 T("2.0"),
609 T("1.0")),
610 test_xy<T>("switch { case [x <= y] : [y - x]; default: 1.12345; }", T("1.0"), T("2.0"), T("1.0")),
611 test_xy<T>("switch { case [x > y] : 0; case [x <= y] : [y - x]; default: 1.12345; }",
612 T("1.0"),
613 T("2.0"),
614 T("1.0")),
616 "switch { case [x <= y] : switch { case [x <= y] : {y - x}; default: 1.12345; }; default: 1.12345; }",
617 T("1.0"),
618 T("2.0"),
619 T("1.0")),
620 test_xy<T>("switch { case {x <= y} : x; default: 1.12345; }", T("1.0"), T("2.0"), T("1.0")),
621 test_xy<T>("switch { case {x > y} : 0; case {x <= y} : {y - x}; default: 1.12345; }",
622 T("1.0"),
623 T("2.0"),
624 T("1.0")),
626 "switch { case {x <= y} : switch { case {x <= y} : x; default: 1.12345; }; default: 1.12345; }",
627 T("1.0"),
628 T("2.0"),
629 T("1.0")),
630 test_xy<T>("switch { case [(x <= y)] : {y - x}; default: 1.12345; }", T("1.0"), T("2.0"), T("1.0")),
631 test_xy<T>("switch { case ([x > y]) : [0]; case ([x <= y]) : [y - x]; default: 1.12345; }",
632 T("1.0"),
633 T("2.0"),
634 T("1.0")),
636 "switch { case {(x <= y)} : switch { case ({x <= y}) : x; default: 1.12345; }; default: 1.12345; }",
637 T("1.0"),
638 T("2.0"),
639 T("1.0")),
640 test_xy<T>("[*]{ case x < y : x + y; case y < x : y - x; }", T("2.0"), T("3.0"), T("5.0")),
641 test_xy<T>("[*]{ case x > y : x + y; case y > x : y - x; }", T("2.0"), T("3.0"), T("1.0")),
642 test_xy<T>("[*]{ case x > y : x - y; case y < x : y + x; }", T("2.0"), T("3.0"), T("0.0")),
643 test_xy<T>("0 ? x : y", T("1.0"), T("2.0"), T(" 2.0")),
644 test_xy<T>("1 ? x : y", T("1.0"), T("2.0"), T(" 1.0")),
645 test_xy<T>("x ? x : y", T("1.0"), T("2.0"), T(" 1.0")),
646 test_xy<T>("x ? x : y", T("0.0"), T("2.0"), T(" 2.0")),
647 test_xy<T>("(x + y < 4) ? 1 : 2", T("1.0"), T("2.0"), T(" 1.0")),
648 test_xy<T>("(x + y > 4) ? 1 : 2", T("1.0"), T("2.0"), T(" 2.0")),
649 test_xy<T>("x < y ? x + y : x - y", T("1.0"), T("2.0"), T(" 3.0")),
650 test_xy<T>("x > y ? x + y : x - y", T("1.0"), T("2.0"), T("-1.0")),
651 test_xy<T>("(x + x < y ? 7 : 9) == 7", T("1.0"), T("3.0"), T(" 1.0")),
652 test_xy<T>("(x + x < y + y ? 7 : 9) == 7", T("1.0"), T("3.0"), T(" 1.0")),
653 test_xy<T>("(x > y + y ? 7 : 9) == 9", T("1.0"), T("3.0"), T(" 1.0")),
654 test_xy<T>("(x + x > y ? 7 : 9) == 9", T("1.0"), T("3.0"), T(" 1.0")),
655 test_xy<T>("(x + x > y + 3 ? 7 : 9) == 9", T("1.0"), T("3.0"), T(" 1.0")),
656 test_xy<T>("(x < (y + y) ? 7 : 9) == 7", T("1.0"), T("3.0"), T(" 1.0")),
657 test_xy<T>("((x + x) < y ? 7 : 9) == 7", T("1.0"), T("3.0"), T(" 1.0")),
658 test_xy<T>("((x + x) < (y + y) ? 7 : 9) == 7", T("1.0"), T("3.0"), T(" 1.0")),
659 test_xy<T>("(x += 2 ) == 3 ", T("1"), T("3"), T("1")),
660 test_xy<T>("(x += 2y) == 7 ", T("1"), T("3"), T("1")),
661 test_xy<T>("(x -= 2 ) == -1 ", T("1"), T("3"), T("1")),
662 test_xy<T>("(x -= 2y) == -5 ", T("1"), T("3"), T("1")),
663 test_xy<T>("(x *= 2 ) == 2 ", T("1"), T("3"), T("1")),
664 test_xy<T>("(x *= 2y) == 6 ", T("1"), T("3"), T("1")),
665 test_xy<T>("(x /= 2 ) == (1/2)", T("1"), T("3"), T("1")),
666 test_xy<T>("(x /= 2y) == (1/6)", T("1"), T("3"), T("1")),
667 test_xy<T>("for(var i := 0; (i < 10);) { i += 1; }; x;", T("1"), T("20"), T(" 1")),
668 test_xy<T>("for(var i := 0; (i < 10) and (i != y); i+=2) { x += i; }; x;", T("1"), T("20"), T("21")),
670 "for(var i := 0; (i < 10) and (i != y);) { x += i; i+=2; }; x;", T("1"), T("20"), T("21")),
671 test_xy<T>("for(var i := 0; (i < y); i += 1) { if (i <= (y / 2)) x += i; else break; }; x;",
672 T("0"),
673 T("10"),
674 T("15")),
675 test_xy<T>("for(var i := 0; (i < y); i += 1) { if (i <= (y / 2)) continue; else x += i; }; x;",
676 T("0"),
677 T("10"),
678 T("30")),
679 test_xy<T>("var a := 2; (0 * a) == 0", T("0"), T("0"), T("1")),
680 test_xy<T>("var a := 2; (0 / a) == 0", T("0"), T("0"), T("1")),
681 test_xy<T>("var a := 2; (a * 0) == 0", T("0"), T("0"), T("1")),
682 test_xy<T>("var a := 2; (a / 1) == a", T("0"), T("0"), T("1")),
683 test_xy<T>("var a := 2; (0 + a) == a", T("0"), T("0"), T("1")),
684 test_xy<T>("var a := 2; (a + 0) == a", T("0"), T("0"), T("1")),
685 test_xy<T>("var a := 2; (1 * a) == a", T("0"), T("0"), T("1")),
686 test_xy<T>("var a.b := 3; (2 * a.b ) == 6", T("0"), T("0"), T("1")),
687 test_xy<T>("var aa.bb := 3; (2 * aa.bb ) == 6", T("0"), T("0"), T("1")),
688 test_xy<T>("var aaa.bbb := 3; (2 * aAa.BbB) == 6", T("0"), T("0"), T("1")),
689 test_xy<T>("var a1.b2 := 3; (2 * a1.b2 ) == 6", T("0"), T("0"), T("1"))
690 };
691
692 static const std::size_t test_list_size = sizeof(test_list) / sizeof(test_xy<T>);
693
694 const std::size_t rounds = 60;
695
696 for (std::size_t r = 0; r < rounds; ++r)
697 {
698 bool loop_result = true;
699
700 for (std::size_t i = 0; i < test_list_size; ++i)
701 {
702 test_xy<T>& test = const_cast<test_xy<T>&>(test_list[i]);
703
704 T x = test.x;
705 T y = test.y;
706
707 exprtk::symbol_table<T> symbol_table;
708 symbol_table.add_variable("x",x);
709 symbol_table.add_variable("y",y);
710
711 exprtk::expression<T> expression;
712 expression.register_symbol_table(symbol_table);
713
714 {
715 exprtk::parser<T> parser;
716
717 if (!parser.compile(test.expr,expression))
718 {
719 printf("run_test01() - Error: %s Expression: %s\n",
720 parser.error().c_str(),
721 test.expr.c_str());
722
723 loop_result = false;
724
725 continue;
726 }
727 }
728
729 const T result = expression.value();
730
731 if (not_equal(result,test.result))
732 {
733 printf("run_test01() - Computation Error: Expression: [%s]\tExpected: %25.20f\tResult: %25.20f\n",
734 test.expr.c_str(),
735 test.result.toDouble(),
736 result.toDouble());
737
738 printf("run_test01() - x: %s\ty: %s\n",
739 test.x.toString().c_str(),
740 test.y.toString().c_str());
741
742 loop_result = false;
743 }
744 }
745
746 if (!loop_result)
747 {
748 return false;
749 }
750 }
751 }
752
753 return true;
754}
755
756template <typename T>
757struct type_name { static inline std::string value() { return "MPFR"; } };
758
759int main()
760{
761 mpfr::mpreal::set_default_prec(128);
762
763 #define perform_test(Type,Number) \
764 { \
765 exprtk::timer timer; \
766 timer.start(); \
767 if (!run_test##Number<Type>()) \
768 { \
769 printf("run_test"#Number" (%s) *** FAILED! ***\n", \
770 type_name<Type>::value().c_str()); \
771 result = EXIT_FAILURE; \
772 } \
773 else \
774 { \
775 timer.stop(); \
776 printf("run_test"#Number" (%s) - Result: SUCCESS Time: %8.4fsec\n", \
777 type_name<Type>::value().c_str(), \
778 timer.time()); \
779 } \
780 } \
781
782 int result = 0;
783
785
786 #undef perform_test
787
788 return result;
789}
bool register_symbol_table(symbol_table< T > &st)
Definition exprtk.hpp:22071
bool compile(const std::string &expression_string, expression< T > &expr)
Definition exprtk.hpp:24826
std::string error() const
Definition exprtk.hpp:25114
bool add_function(const std::string &function_name, function_t &function)
Definition exprtk.hpp:21156
bool add_variable(const std::string &variable_name, T &t, const bool is_constant=false)
Definition exprtk.hpp:21115
static const std::size_t rounds
mpfr::mpreal numeric_type
std::pair< std::string, numeric_type > test_t
bool not_equal(const T &t0, const T &t1, const T &epsilon=T(0.000000000001))
#define perform_test(Type, Number)
bool run_test01()
bool not_equal_impl(const T &t1, const T &t2, const T &epsilon=0.000000000001)
int main()
bool test_expression(const std::string &expression_string, const T &expected_result)
std::string expr
test_xy(const std::string &e, const T &v0, const T &v1, const T &r)
test_xyzw(const std::string &e, const T &v0, const T &v1, const T &v2, const T &v3, const T &r)
static std::string value()