28{
32
34 {
35 "(y + x)",
36 "2 * (y + x)",
37 "(2 * y + 2 * x)",
38 "(y + x / y) * (x - y / x)",
39 "x / ((x + y) * (x - y)) / y",
40 "1 - ((x * y) + (y / x)) - 3",
41 "sin(2 * x) + cos(pi / y)",
42 "1 - sin(2 * x) + cos(pi / y)",
43 "sqrt(1 - sin(2 * x) + cos(pi / y) / 3)",
44 "(x^2 / sin(2 * pi / y)) -x / 2",
45 "x + (cos(y - sin(2 / x * pi)) - sin(x - cos(2 * y / pi))) - y",
46 "clamp(-1.0, sin(2 * pi * x) + cos(y / 2 * pi), +1.0)",
47 "iclamp(-1.0, sin(2 * pi * x) + cos(y / 2 * pi), +1.0)",
48 "max(3.33, min(sqrt(1 - sin(2 * x) + cos(pi / y) / 3), 1.11))",
49 "if(avg(x,y) <= x + y, x - y, x * y) + 2 * pi / x",
50 "1.1x^1 + 2.2y^2 - 3.3x^3 + 4.4y^4 - 5.5x^5 + 6.6y^6 - 7.7x^27 + 8.8y^55",
51 "(yy + xx)",
52 "2 * (yy + xx)",
53 "(2 * yy + 2 * xx)",
54 "(yy + xx / yy) * (xx - yy / xx)",
55 "xx / ((xx + yy) * (xx - yy)) / yy",
56 "1 - ((xx * yy) + (yy / xx)) - 3",
57 "sin(2 * xx) + cos(pi / yy)",
58 "1 - sin(2 * xx) + cos(pi / yy)",
59 "sqrt(1 - sin(2 * xx) + cos(pi / yy) / 3)",
60 "(xx^2 / sin(2 * pi / yy)) -xx / 2",
61 "xx + (cos(yy - sin(2 / xx * pi)) - sin(xx - cos(2 * yy / pi))) - yy",
62 "clamp(-1.0, sin(2 * pi * xx) + cos(yy / 2 * pi), +1.0)",
63 "max(3.33, min(sqrt(1 - sin(2 * xx) + cos(pi / yy) / 3), 1.11))",
64 "if(avg(xx,yy) <= xx + yy, xx - yy, xx * yy) + 2 * pi / xx",
65 "1.1xx^1 + 2.2yy^2 - 3.3xx^3 + 4.4yy^4 - 5.5xx^5 + 6.6yy^6 - 7.7xx^27 + 8.8yy^55",
66 "(1.1*(2.2*(3.3*(4.4*(5.5*(6.6*(7.7*(8.8*(9.9+x)))))))))",
67 "(((((((((x+9.9)*8.8)*7.7)*6.6)*5.5)*4.4)*3.3)*2.2)*1.1)",
68 "(x + y) * z", "x + (y * z)", "(x + y) * 7", "x + (y * 7)",
69 "(x + 7) * y", "x + (7 * y)", "(7 + x) * y", "7 + (x * y)",
70 "(2 + x) * 3", "2 + (x * 3)", "(2 + 3) * x", "2 + (3 * x)",
71 "(x + 2) * 3", "x + (2 * 3)",
72 "(x + y) * (z / w)", "(x + y) * (z / 7)", "(x + y) * (7 / z)", "(x + 7) * (y / z)",
73 "(7 + x) * (y / z)", "(2 + x) * (y / z)", "(x + 2) * (y / 3)", "(2 + x) * (y / 3)",
74 "(x + 2) * (3 / y)", "x + (y * (z / w))", "x + (y * (z / 7))", "x + (y * (7 / z))",
75 "x + (7 * (y / z))", "7 + (x * (y / z))", "2 + (x * (3 / y))", "x + (2 * (y / 4))",
76 "2 + (x * (y / 3))", "x + (2 * (3 / y))",
77 "x + ((y * z) / w)", "x + ((y * z) / 7)", "x + ((y * 7) / z)", "x + ((7 * y) / z)",
78 "7 + ((y * z) / w)", "2 + ((x * 3) / y)", "x + ((2 * y) / 3)", "2 + ((x * y) / 3)",
79 "x + ((2 * 3) / y)", "(((x + y) * z) / w)",
80 "(((x + y) * z) / 7)", "(((x + y) * 7) / z)", "(((x + 7) * y) / z)", "(((7 + x) * y) / z)",
81 "(((2 + x) * 3) / y)", "(((x + 2) * y) / 3)", "(((2 + x) * y) / 3)", "(((x + 2) * 3) / y)",
82 "((x + (y * z)) / w)", "((x + (y * z)) / 7)", "((x + (y * 7)) / y)", "((x + (7 * y)) / z)",
83 "((7 + (x * y)) / z)", "((2 + (x * 3)) / y)", "((x + (2 * y)) / 3)", "((2 + (x * y)) / 3)",
84 "((x + (2 * 3)) / y)",
85 "(xx + yy) * zz", "xx + (yy * zz)",
86 "(xx + yy) * 7", "xx + (yy * 7)",
87 "(xx + 7) * yy", "xx + (7 * yy)",
88 "(7 + xx) * yy", "7 + (xx * yy)",
89 "(2 + x) * 3", "2 + (x * 3)",
90 "(2 + 3) * x", "2 + (3 * x)",
91 "(x + 2) * 3", "x + (2 * 3)",
92 "(xx + yy) * (zz / ww)", "(xx + yy) * (zz / 7)",
93 "(xx + yy) * (7 / zz)", "(xx + 7) * (yy / zz)",
94 "(7 + xx) * (yy / zz)", "(2 + xx) * (yy / zz)",
95 "(xx + 2) * (yy / 3)", "(2 + xx) * (yy / 3)",
96 "(xx + 2) * (3 / yy)", "xx + (yy * (zz / ww))",
97 "xx + (yy * (zz / 7))", "xx + (yy * (7 / zz))",
98 "xx + (7 * (yy / zz))", "7 + (xx * (yy / zz))",
99 "2 + (xx * (3 / yy))", "xx + (2 * (yy / 4))",
100 "2 + (xx * (yy / 3))", "xx + (2 * (3 / yy))",
101 "xx + ((yy * zz) / ww)", "xx + ((yy * zz) / 7)",
102 "xx + ((yy * 7) / zz)", "xx + ((7 * yy) / zz)",
103 "7 + ((yy * zz) / ww)", "2 + ((xx * 3) / yy)",
104 "xx + ((2 * yy) / 3)", "2 + ((xx * yy) / 3)",
105 "xx + ((2 * 3) / yy)", "(((xx + yy) * zz) / ww)",
106 "(((xx + yy) * zz) / 7)", "(((xx + yy) * 7) / zz)",
107 "(((xx + 7) * yy) / zz)", "(((7 + xx) * yy) / zz)",
108 "(((2 + xx) * 3) / yy)", "(((xx + 2) * yy) / 3)",
109 "(((2 + xx) * yy) / 3)", "(((xx + 2) * 3) / yy)",
110 "((xx + (yy * zz)) / ww)", "((xx + (yy * zz)) / 7)",
111 "((xx + (yy * 7)) / yy)", "((xx + (7 * yy)) / zz)",
112 "((7 + (xx * yy)) / zz)", "((2 + (xx * 3)) / yy)",
113 "((xx + (2 * yy)) / 3)", "((2 + (xx * yy)) / 3)",
114 "((xx + (2 * 3)) / yy)"
115 };
116
118
119 T x = T(0);
120 T y = T(0);
121 T z = T(0);
122 T w = T(0);
123 T xx = T(0);
124 T yy = T(0);
125 T zz = T(0);
126 T ww = T(0);
127
128 symbol_table_t symbol_table;
129 symbol_table.add_constants();
130 symbol_table.add_variable( "x", x);
131 symbol_table.add_variable( "y", y);
132 symbol_table.add_variable( "z", z);
133 symbol_table.add_variable( "w", w);
134 symbol_table.add_variable("xx",xx);
135 symbol_table.add_variable("yy",yy);
136 symbol_table.add_variable("zz",zz);
137 symbol_table.add_variable("ww",ww);
138
139 typedef typename std::deque<expression_t> expr_list_t;
140 expr_list_t expr_list;
141
142 const std::size_t
rounds = 50;
143
144 {
145 for (std::size_t r = 0; r <
rounds; ++r)
146 {
147 expr_list.clear();
148 parser_t parser;
149
151 {
152 expression_t expression;
153 expression.register_symbol_table(symbol_table);
154
156 {
157 return false;
158 }
159
160 expr_list.push_back(expression);
161 }
162 }
163 }
164
165 struct execute
166 {
167 static inline T
process(T& x, T& y, expression_t& expression)
168 {
169 static const T lower_bound = T(-20);
170 static const T upper_bound = T(+20);
171 static const T
delta = T(0.1);
172
173 T total = T(0);
174
175 for (x = lower_bound; x <= upper_bound; x +=
delta)
176 {
177 for (y = lower_bound; y <= upper_bound; y +=
delta)
178 {
179 total += expression.value();
180 }
181 }
182
183 return total;
184 }
185 };
186
187 for (std::size_t i = 0; i < expr_list.size(); ++i)
188 {
189 execute::process( x, y, expr_list[i]);
190 execute::process(xx, yy, expr_list[i]);
191 }
192
193 {
195
196 for (std::size_t i = 0; i < 10000; ++i)
197 {
198 const T v = T(123.456 + i);
199
201 return false;
202
203 #define else_stmt(N) \
204 else if (details::is_true(details::numeric::nequal(details::numeric::fast_exp<T,N>::result(v),details::numeric::pow(v,T(N))))) \
205 return false; \
206
222 }
223 }
224
225 return true;
226}
static const std::size_t rounds
static const double delta
const std::size_t expression_list_size
static const std::string expression_list[]
T process(const operator_type operation, const T arg)