diff --git a/exprtk.hpp b/exprtk.hpp index 488bd79..c0bcb1f 100644 --- a/exprtk.hpp +++ b/exprtk.hpp @@ -14306,7 +14306,16 @@ namespace exprtk binary_functor_t f1 = reinterpret_cast(0); details::free_node(*(expr_gen.node_allocator_),branch[0]); expression_node_ptr result = error_node(); - if (synthesize_sf3ext_expression::template compile(expr_gen,id(expr_gen,o0,o1),v0,v1,v2,result)) + + // (v0 / v1) / v2 --> (vovov) v0 / (v1 * v2) + if ((details::e_div == o0) && (details::e_div == o1)) + { + const bool synthesis_result = + synthesize_sf3ext_expression:: + template compile(expr_gen,"t/(t*t)",v0,v1,v2,result); + return (synthesis_result) ? result : error_node(); + } + else if (synthesize_sf3ext_expression::template compile(expr_gen,id(expr_gen,o0,o1),v0,v1,v2,result)) return result; else if (!expr_gen.valid_operator(o0,f0)) return error_node(); @@ -14342,7 +14351,16 @@ namespace exprtk binary_functor_t f1 = reinterpret_cast(0); details::free_node(*(expr_gen.node_allocator_),branch[1]); expression_node_ptr result = error_node(); - if (synthesize_sf3ext_expression::template compile(expr_gen,id(expr_gen,o0,o1),v0,v1,v2,result)) + + // v0 / (v1 / v2) --> (vovov) (v0 * v2) / v1 + if ((details::e_div == o0) && (details::e_div == o1)) + { + const bool synthesis_result = + synthesize_sf3ext_expression:: + template compile(expr_gen,"(t*t)/t",v0,v2,v1,result); + return (synthesis_result) ? result : error_node(); + } + else if (synthesize_sf3ext_expression::template compile(expr_gen,id(expr_gen,o0,o1),v0,v1,v2,result)) return result; else if (!expr_gen.valid_operator(o0,f0)) return error_node(); @@ -14379,7 +14397,16 @@ namespace exprtk details::free_node(*(expr_gen.node_allocator_),branch[0]); details::free_node(*(expr_gen.node_allocator_),branch[1]); expression_node_ptr result = error_node(); - if (synthesize_sf3ext_expression::template compile(expr_gen,id(expr_gen,o0,o1),v0,v1,c,result)) + + // (v0 / v1) / c --> (vovoc) v0 / (v1 * c) + if ((details::e_div == o0) && (details::e_div == o1)) + { + const bool synthesis_result = + synthesize_sf3ext_expression:: + template compile(expr_gen,"t/(t*t)",v0,v1,c,result); + return (synthesis_result) ? result : error_node(); + } + else if (synthesize_sf3ext_expression::template compile(expr_gen,id(expr_gen,o0,o1),v0,v1,c,result)) return result; else if (!expr_gen.valid_operator(o0,f0)) return error_node(); @@ -14415,7 +14442,16 @@ namespace exprtk binary_functor_t f1 = reinterpret_cast(0); details::free_node(*(expr_gen.node_allocator_),branch[1]); expression_node_ptr result = error_node(); - if (synthesize_sf3ext_expression::template compile(expr_gen,id(expr_gen,o0,o1),v0,v1,c,result)) + + // v0 / (v1 / c) --> (vocov) (v0 * c) / v1 + if ((details::e_div == o0) && (details::e_div == o1)) + { + const bool synthesis_result = + synthesize_sf3ext_expression:: + template compile(expr_gen,"(t*t)/t",v0,c,v1,result); + return (synthesis_result) ? result : error_node(); + } + else if (synthesize_sf3ext_expression::template compile(expr_gen,id(expr_gen,o0,o1),v0,v1,c,result)) return result; else if (!expr_gen.valid_operator(o0,f0)) return error_node(); @@ -14451,7 +14487,16 @@ namespace exprtk binary_functor_t f1 = reinterpret_cast(0); details::free_node(*(expr_gen.node_allocator_),branch[0]); expression_node_ptr result = error_node(); - if (synthesize_sf3ext_expression::template compile(expr_gen,id(expr_gen,o0,o1),v0,c,v1,result)) + + // (v0 / c) / v1 --> (vovoc) v0 / (v1 * c) + if ((details::e_div == o0) && (details::e_div == o1)) + { + const bool synthesis_result = + synthesize_sf3ext_expression:: + template compile(expr_gen,"t/(t*t)",v0,v1,c,result); + return (synthesis_result) ? result : error_node(); + } + else if (synthesize_sf3ext_expression::template compile(expr_gen,id(expr_gen,o0,o1),v0,c,v1,result)) return result; else if (!expr_gen.valid_operator(o0,f0)) return error_node(); @@ -14487,7 +14532,16 @@ namespace exprtk binary_functor_t f1 = reinterpret_cast(0); details::free_node(*(expr_gen.node_allocator_),branch[1]); expression_node_ptr result = error_node(); - if (synthesize_sf3ext_expression::template compile(expr_gen,id(expr_gen,o0,o1),v0,c,v1,result)) + + // v0 / (c / v1) --> (vovoc) (v0 * v1) / c + if ((details::e_div == o0) && (details::e_div == o1)) + { + const bool synthesis_result = + synthesize_sf3ext_expression:: + template compile(expr_gen,"(t*t)/t",v0,v1,c,result); + return (synthesis_result) ? result : error_node(); + } + else if (synthesize_sf3ext_expression::template compile(expr_gen,id(expr_gen,o0,o1),v0,c,v1,result)) return result; else if (!expr_gen.valid_operator(o0,f0)) return error_node(); @@ -14523,7 +14577,16 @@ namespace exprtk binary_functor_t f1 = reinterpret_cast(0); details::free_node(*(expr_gen.node_allocator_),branch[0]); expression_node_ptr result = error_node(); - if (synthesize_sf3ext_expression::template compile(expr_gen,id(expr_gen,o0,o1),c,v0,v1,result)) + + // (c / v0) / v1 --> (covov) c / (v0 * v1) + if ((details::e_div == o0) && (details::e_div == o1)) + { + const bool synthesis_result = + synthesize_sf3ext_expression:: + template compile(expr_gen,"t/(t*t)",c,v0,v1,result); + return (synthesis_result) ? result : error_node(); + } + else if (synthesize_sf3ext_expression::template compile(expr_gen,id(expr_gen,o0,o1),c,v0,v1,result)) return result; else if (!expr_gen.valid_operator(o0,f0)) return error_node(); @@ -14560,7 +14623,16 @@ namespace exprtk details::free_node(*(expr_gen.node_allocator_),branch[0]); details::free_node(*(expr_gen.node_allocator_),branch[1]); expression_node_ptr result = error_node(); - if (synthesize_sf3ext_expression::template compile(expr_gen,id(expr_gen,o0,o1),c,v0,v1,result)) + + // c / (v0 / v1) --> (covov) (c * v1) / v0 + if ((details::e_div == o0) && (details::e_div == o1)) + { + const bool synthesis_result = + synthesize_sf3ext_expression:: + template compile(expr_gen,"(t*t)/t",c,v1,v0,result); + return (synthesis_result) ? result : error_node(); + } + else if (synthesize_sf3ext_expression::template compile(expr_gen,id(expr_gen,o0,o1),c,v0,v1,result)) return result; else if (!expr_gen.valid_operator(o0,f0)) return error_node(); @@ -15235,6 +15307,38 @@ namespace exprtk template compile(expr_gen,"(t*t)*t",(c0 * c1),v0,v1,result); return (synthesis_result) ? result : error_node(); } + // (c0 * v0) / (c1 * v1) --> (covov) (c0 / c1) * (v0 / v1) + else if ((details::e_mul == o0) && (details::e_div == o1) && (details::e_mul == o2)) + { + const bool synthesis_result = + synthesize_sf3ext_expression:: + template compile(expr_gen,"(t*t)/t",(c0 / c1),v0,v1,result); + return (synthesis_result) ? result : error_node(); + } + // (c0 / v0) * (c1 / v1) --> (covov) (c0 * c1) / (v0 * v1) + else if ((details::e_div == o0) && (details::e_mul == o1) && (details::e_div == o2)) + { + const bool synthesis_result = + synthesize_sf3ext_expression:: + template compile(expr_gen,"t/(t*t)",(c0 * c1),v0,v1,result); + return (synthesis_result) ? result : error_node(); + } + // (c0 * v0) / (c1 / v1) --> (covov) (c0 / c1) * (v0 * v1) + else if ((details::e_mul == o0) && (details::e_div == o1) && (details::e_div == o2)) + { + const bool synthesis_result = + synthesize_sf3ext_expression:: + template compile(expr_gen,"t*(t*t)",(c0 / c1),v0,v1,result); + return (synthesis_result) ? result : error_node(); + } + // (c0 / v0) / (c1 * v1) --> (covov) (c0 / c1) / (v0 * v1) + else if ((details::e_div == o0) && (details::e_div == o1) && (details::e_mul == o2)) + { + const bool synthesis_result = + synthesize_sf3ext_expression:: + template compile(expr_gen,"t/(t*t)",(c0 / c1),v0,v1,result); + return (synthesis_result) ? result : error_node(); + } else if (synthesize_sf4ext_expression::template compile(expr_gen,id(expr_gen,o0,o1,o2),c0,v0,c1,v1,result)) return result; else if (!expr_gen.valid_operator(o0,f0)) @@ -15307,7 +15411,7 @@ namespace exprtk template compile(expr_gen,"(t+t)-t",(c1 - c0),v0,v1,result); return (synthesis_result) ? result : error_node(); } - // (c0 * v0) * (c1 * v1) --> (covov) (c0 * c1) * v0 * v1 + // (v0 * c0) * (v1 * c1) --> (covov) (c0 * c1) * v0 * v1 else if ((details::e_mul == o0) && (details::e_mul == o1) && (details::e_mul == o2)) { const bool synthesis_result = @@ -15315,6 +15419,38 @@ namespace exprtk template compile(expr_gen,"(t*t)*t",(c0 * c1),v0,v1,result); return (synthesis_result) ? result : error_node(); } + // (v0 * c0) / (v1 * c1) --> (covov) (c0 / c1) * (v0 / v1) + else if ((details::e_mul == o0) && (details::e_div == o1) && (details::e_mul == o2)) + { + const bool synthesis_result = + synthesize_sf3ext_expression:: + template compile(expr_gen,"(t*t)/t",(c0 / c1),v0,v1,result); + return (synthesis_result) ? result : error_node(); + } + // (v0 / c0) * (v1 / c1) --> (covov) (1 / (c0 * c1)) * v0 * v1 + else if ((details::e_div == o0) && (details::e_mul == o1) && (details::e_div == o2)) + { + const bool synthesis_result = + synthesize_sf3ext_expression:: + template compile(expr_gen,"(t*t)*t",Type(1) / (c0 * c1),v0,v1,result); + return (synthesis_result) ? result : error_node(); + } + // (v0 * c0) / (v1 / c1) --> (covov) (c0 * c1) * (v0 / v1) + else if ((details::e_mul == o0) && (details::e_div == o1) && (details::e_mul == o2)) + { + const bool synthesis_result = + synthesize_sf3ext_expression:: + template compile(expr_gen,"t*(t/t)",(c0 * c1),v0,v1,result); + return (synthesis_result) ? result : error_node(); + } + // (v0 / c0) / (v1 * c1) --> (covov) (1 / (c0 * c1)) * v0 / v1 + else if ((details::e_div == o0) && (details::e_div == o1) && (details::e_mul == o2)) + { + const bool synthesis_result = + synthesize_sf3ext_expression:: + template compile(expr_gen,"t*(t/t)",Type(1) / (c0 * c1),v0,v1,result); + return (synthesis_result) ? result : error_node(); + } else if (synthesize_sf4ext_expression::template compile(expr_gen,id(expr_gen,o0,o1,o2),v0,c0,v1,c1,result)) return result; else if (!expr_gen.valid_operator(o0,f0)) @@ -15387,7 +15523,7 @@ namespace exprtk template compile(expr_gen,"t-(t+t)",(c0 + c1),v0,v1,result); return (synthesis_result) ? result : error_node(); } - // (c0 * v0) * (c1 * v1) --> (covov) (c0 * c1) * v0 * v1 + // (c0 * v0) * (v1 * c1) --> (covov) (c0 * c1) * v0 * v1 else if ((details::e_mul == o0) && (details::e_mul == o1) && (details::e_mul == o2)) { const bool synthesis_result = @@ -15395,6 +15531,38 @@ namespace exprtk template compile(expr_gen,"(t*t)*t",(c0 * c1),v0,v1,result); return (synthesis_result) ? result : error_node(); } + // (c0 * v0) / (v1 * c1) --> (covov) (c0 / c1) * (v0 / v1) + else if ((details::e_mul == o0) && (details::e_div == o1) && (details::e_mul == o2)) + { + const bool synthesis_result = + synthesize_sf3ext_expression:: + template compile(expr_gen,"(t*t)/t",(c0 / c1),v0,v1,result); + return (synthesis_result) ? result : error_node(); + } + // (c0 / v0) * (v1 / c1) --> (covov) (c0 / c1) * (v1 / v0) + else if ((details::e_div == o0) && (details::e_mul == o1) && (details::e_div == o2)) + { + const bool synthesis_result = + synthesize_sf3ext_expression:: + template compile(expr_gen,"t*(t/t)",(c0 / c1),v1,v0,result); + return (synthesis_result) ? result : error_node(); + } + // (c0 * v0) / (v1 / c1) --> (covov) (c0 * c1) * (v0 / v1) + else if ((details::e_mul == o0) && (details::e_div == o1) && (details::e_div == o2)) + { + const bool synthesis_result = + synthesize_sf3ext_expression:: + template compile(expr_gen,"(t*t)/t",(c0 * c1),v0,v1,result); + return (synthesis_result) ? result : error_node(); + } + // (c0 / v0) / (v1 * c1) --> (covov) (c0 / c1) / (v0 * v1) + else if ((details::e_div == o0) && (details::e_div == o1) && (details::e_mul == o2)) + { + const bool synthesis_result = + synthesize_sf3ext_expression:: + template compile(expr_gen,"t/(t*t)",(c0 / c1),v0,v1,result); + return (synthesis_result) ? result : error_node(); + } else if (synthesize_sf4ext_expression::template compile(expr_gen,id(expr_gen,o0,o1,o2),c0,v0,v1,c1,result)) return result; else if (!expr_gen.valid_operator(o0,f0)) @@ -15467,7 +15635,7 @@ namespace exprtk template compile(expr_gen,"(t+t)-t",v0,v1,(c1 + c0),result); return (synthesis_result) ? result : error_node(); } - // (c0 * v0) * (c1 * v1) --> (covov) (c0 * c1) * v0 * v1 + // (v0 * c0) * (c1 * v1) --> (covov) (c0 * c1) * v0 * v1 else if ((details::e_mul == o0) && (details::e_mul == o1) && (details::e_mul == o2)) { const bool synthesis_result = @@ -15475,6 +15643,38 @@ namespace exprtk template compile(expr_gen,"(t*t)*t",(c0 * c1),v0,v1,result); return (synthesis_result) ? result : error_node(); } + // (v0 * c0) / (c1 * v1) --> (covov) (c0 / c1) * (v0 * v1) + else if ((details::e_mul == o0) && (details::e_div == o1) && (details::e_mul == o2)) + { + const bool synthesis_result = + synthesize_sf3ext_expression:: + template compile(expr_gen,"(t*t)/t",(c0 / c1),v0,v1,result); + return (synthesis_result) ? result : error_node(); + } + // (v0 / c0) * (c1 / v1) --> (covov) (c1 / c0) * (v0 / v1) + else if ((details::e_div == o0) && (details::e_mul == o1) && (details::e_div == o2)) + { + const bool synthesis_result = + synthesize_sf3ext_expression:: + template compile(expr_gen,"(t*t)/t",(c1 / c0),v0,v1,result); + return (synthesis_result) ? result : error_node(); + } + // (v0 * c0) / (c1 / v1) --> (covov) (c0 / c1) * (v0 * v1) + else if ((details::e_mul == o0) && (details::e_mul == o1) && (details::e_mul == o2)) + { + const bool synthesis_result = + synthesize_sf3ext_expression:: + template compile(expr_gen,"(t*t)*t",(c0 / c1),v0,v1,result); + return (synthesis_result) ? result : error_node(); + } + // (v0 / c0) / (c1 * v1) --> (covov) (1 / (c0 * c1)) * (v0 / v1) + else if ((details::e_div == o0) && (details::e_div == o1) && (details::e_mul == o2)) + { + const bool synthesis_result = + synthesize_sf3ext_expression:: + template compile(expr_gen,"(t*t)/t",Type(1) / (c0 * c1),v0,v1,result); + return (synthesis_result) ? result : error_node(); + } else if (synthesize_sf4ext_expression::template compile(expr_gen,id(expr_gen,o0,o1,o2),v0,c0,c1,v1,result)) return result; else if (!expr_gen.valid_operator(o0,f0)) @@ -18005,7 +18205,7 @@ namespace exprtk const Type c1, const Type c0) { // p(x) = c_11x^11 + c_10x^10 + c_9x^9 + c_8x^8 + c_7x^7 + c_6x^6 + c_5x^5 + c_4x^4 + c_3x^3 + c_2x^2 + c_1x^1 + c_0x^0 - return ((((((((((( c11 * x + c10) * x + c9) * x + c8) * x + c7) * x + c6) * x + c5) * x + c4) * x + c3) * x + c2) * x + c1) * x + c0); + return (((((((((((c11 * x + c10) * x + c9) * x + c8) * x + c7) * x + c6) * x + c5) * x + c4) * x + c3) * x + c2) * x + c1) * x + c0); } }; diff --git a/exprtk_test.cpp b/exprtk_test.cpp index 38a6f42..3bd22af 100644 --- a/exprtk_test.cpp +++ b/exprtk_test.cpp @@ -1137,288 +1137,387 @@ struct test_xy T result; }; +template +struct test_xyz +{ + test_xyz(std::string e, const T& v0, const T& v1, const T& v2, const T& r) + : expr(e), + x(v0), + y(v1), + z(v2), + result(r) + {} + + std::string expr; + T x; + T y; + T z; + T result; +}; + template inline bool run_test01() { - static const test_xy test_list[] = - { - test_xy("x + y" ,T(2.2),T(3.3),T(5.5 )), - test_xy("x - y" ,T(3.3),T(2.2),T(1.1 )), - test_xy("x * y" ,T(3.3),T(2.2),T(7.26 )), - test_xy("x / y" ,T(3.3),T(2.2),T(1.5 )), - test_xy("(x + y) * (x + y)" ,T(2.2),T(3.3),T(30.25)), - test_xy("(x + y) / (x + y)" ,T(2.2),T(3.3),T(1.0 )), - test_xy("x + y > x and x + y > y" ,T(2.2),T(3.3),T(1.0)), - test_xy("1 + (x + y)" ,T(2.2),T(3.3),T(6.5 )), - test_xy("(x + y) - 1" ,T(2.2),T(3.3),T(4.5 )), - test_xy("1 + (x + y) * 2" ,T(2.2),T(3.3),T(12.0 )), - test_xy("2 * (x + y) - 1" ,T(2.2),T(3.3),T(10.0 )), - test_xy("y + (x + 1)" ,T(2.2),T(3.3),T(6.5 )), - test_xy("(x + 1) + y" ,T(2.2),T(3.3),T(6.5 )), - test_xy("2 * x" ,T(2.2),T(0.0),T(4.4)), - test_xy("x * 2" ,T(2.2),T(0.0),T(4.4)), - test_xy("1.1 + x",T(2.2),T(0.0),T(3.3)), - test_xy("x + 1.1",T(2.2),T(0.0),T(3.3)), - test_xy("x * 1 == x" ,T(2.0),T(3.0),T(1.0)), - test_xy("1 * x == x" ,T(2.0),T(3.0),T(1.0)), - test_xy("y * 1 == y" ,T(2.0),T(3.0),T(1.0)), - test_xy("1 * y == y" ,T(2.0),T(3.0),T(1.0)), - test_xy("x * 0 == 0" ,T(2.0),T(3.0),T(1.0)), - test_xy("0 * x == 0" ,T(2.0),T(3.0),T(1.0)), - test_xy("y * 0 == 0" ,T(2.0),T(3.0),T(1.0)), - test_xy("0 * y == 0" ,T(2.0),T(3.0),T(1.0)), - test_xy("x + 1 == 1 + x",T(2.0),T(3.0),T(1.0)), - test_xy("y + 1 == 1 + y",T(2.0),T(3.0),T(1.0)), - test_xy("x + y == y + x",T(2.0),T(3.0),T(1.0)), - test_xy("x * y == y * x",T(2.0),T(3.0),T(1.0)), - test_xy("x < y" ,T(2.0),T(3.0),T(1.0)), - test_xy("y > x" ,T(2.0),T(3.0),T(1.0)), - test_xy("x <= y" ,T(2.0),T(3.0),T(1.0)), - test_xy("y >= x" ,T(2.0),T(3.0),T(1.0)), - test_xy("x + y > y" ,T(2.0),T(3.0),T(1.0)), - test_xy("x + y > x" ,T(2.0),T(3.0),T(1.0)), - test_xy("x * y > y" ,T(2.0),T(3.0),T(1.0)), - test_xy("x * y > x" ,T(2.0),T(3.0),T(1.0)), - test_xy("(x + y) > y" ,T(2.0),T(3.0),T(1.0)), - test_xy("(x + y) > x" ,T(2.0),T(3.0),T(1.0)), - test_xy("(x * y) > y" ,T(2.0),T(3.0),T(1.0)), - test_xy("(x * y) > x" ,T(2.0),T(3.0),T(1.0)), - test_xy("(2x + 3y) == (2*x + 3*y)" ,T(2.0),T(3.0),T(1.0)), - test_xy("2(x + y) == (2*x + 2*y)" ,T(2.0),T(3.0),T(1.0)), - test_xy(" (x + y)3 == (3*x + 3*y)" ,T(2.0),T(3.0),T(1.0)), - test_xy("2x + 3y == 2*x + 3*y" ,T(2.0),T(3.0),T(1.0)), - test_xy("2(x + y) == 2*x + 2*y" ,T(2.0),T(3.0),T(1.0)), - test_xy(" (x + y)3 == 3*x + 3*y" ,T(2.0),T(3.0),T(1.0)), - test_xy("equal(x^2.2^1.1,17.15193942371376191362)" ,T(3.3),T(0.0),T(1.0)), - test_xy("equal(3.3^x^1.1,17.15193942371376191362)" ,T(2.2),T(0.0),T(1.0)), - test_xy("equal(3.3^2.2^x,17.15193942371376191362)" ,T(1.1),T(0.0),T(1.0)), - test_xy("equal(x^2.2^y,17.15193942371376191362)" ,T(3.3),T(1.1),T(1.0)), - test_xy("equal(x^y^1.1,17.15193942371376191362)" ,T(3.3),T(2.2),T(1.0)), - test_xy("equal(3.3^x^y,17.15193942371376191362)" ,T(2.2),T(1.1),T(1.0)), - test_xy("equal(x+y^3/7,x+(y*y*y)/7)",T(2.0),T(3.0),T(1.0)), - test_xy("equal(1-x^3+y^2*7,1-(x*x*x)+(y*y)*7)",T(2.0),T(3.0),T(1.0)), - test_xy("equal( x^0,1)",T(12.34),T(0.0),T(1.0)), - test_xy("equal( x^1,x)",T(12.34),T(0.0),T(1.0)), - test_xy("equal( x^2,x*x)",T(12.34),T(0.0),T(1.0)), - test_xy("equal( x^3,x*x*x)",T(12.34),T(0.0),T(1.0)), - test_xy("equal( x^4,x*x*x*x)",T(12.34),T(0.0),T(1.0)), - test_xy("equal( x^5,x*x*x*x*x)",T(12.34),T(0.0),T(1.0)), - test_xy("equal( x^6,x*x*x*x*x*x)",T(12.34),T(0.0),T(1.0)), - test_xy("equal( x^7,x*x*x*x*x*x*x)",T(12.34),T(0.0),T(1.0)), - test_xy("equal( x^8,x*x*x*x*x*x*x*x)",T(12.34),T(0.0),T(1.0)), - test_xy("equal( x^9,x*x*x*x*x*x*x*x*x)",T(12.34),T(0.0),T(1.0)), - test_xy("equal(x^10,x*x*x*x*x*x*x*x*x*x)",T(12.34),T(0.0),T(1.0)), - test_xy("equal(x^11,x*x*x*x*x*x*x*x*x*x*x)",T(12.34),T(0.0),T(1.0)), - test_xy("equal(x^12,x*x*x*x*x*x*x*x*x*x*x*x)",T(12.34),T(0.0),T(1.0)), - test_xy("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)), - test_xy("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)), - test_xy("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)), - test_xy("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)), - test_xy("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)), - test_xy("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)), - test_xy("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)), - test_xy("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)), - test_xy("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)), - test_xy("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)), - test_xy("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)), - test_xy("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)), - test_xy("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)), - test_xy("equal( y^0,1)",T(0.0),T(12.34),T(1.0)), - test_xy("equal( y^1,y)",T(0.0),T(12.34),T(1.0)), - test_xy("equal( y^2,y*y)",T(0.0),T(12.34),T(1.0)), - test_xy("equal( y^3,y*y*y)",T(0.0),T(12.34),T(1.0)), - test_xy("equal( y^4,y*y*y*y)",T(0.0),T(12.34),T(1.0)), - test_xy("equal( y^5,y*y*y*y*y)",T(0.0),T(12.34),T(1.0)), - test_xy("equal( y^6,y*y*y*y*y*y)",T(0.0),T(12.34),T(1.0)), - test_xy("equal( y^7,y*y*y*y*y*y*y)",T(0.0),T(12.34),T(1.0)), - test_xy("equal( y^8,y*y*y*y*y*y*y*y)",T(0.0),T(12.34),T(1.0)), - test_xy("equal( y^9,y*y*y*y*y*y*y*y*y)",T(0.0),T(12.34),T(1.0)), - test_xy("equal(y^10,y*y*y*y*y*y*y*y*y*y)",T(0.0),T(12.34),T(1.0)), - test_xy("equal(y^11,y*y*y*y*y*y*y*y*y*y*y)",T(0.0),T(12.34),T(1.0)), - test_xy("equal(y^12,y*y*y*y*y*y*y*y*y*y*y*y)",T(0.0),T(12.34),T(1.0)), - test_xy("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)), - test_xy("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)), - test_xy("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)), - test_xy("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)), - test_xy("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)), - test_xy("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)), - test_xy("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)), - test_xy("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)), - test_xy("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)), - test_xy("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)), - test_xy("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)), - test_xy("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)), - test_xy("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)), - test_xy("equal( x^-0,1/1)",T(12.34),T(0.0),T(1.0)), - test_xy("equal( x^-1,1/(x))",T(12.34),T(0.0),T(1.0)), - test_xy("equal( x^-2,1/(x*x))",T(12.34),T(0.0),T(1.0)), - test_xy("equal( x^-3,1/(x*x*x))",T(12.34),T(0.0),T(1.0)), - test_xy("equal( x^-4,1/(x*x*x*x))",T(12.34),T(0.0),T(1.0)), - test_xy("equal( x^-5,1/(x*x*x*x*x))",T(12.34),T(0.0),T(1.0)), - test_xy("equal( x^-6,1/(x*x*x*x*x*x))",T(12.34),T(0.0),T(1.0)), - test_xy("equal( x^-7,1/(x*x*x*x*x*x*x))",T(12.34),T(0.0),T(1.0)), - test_xy("equal( x^-8,1/(x*x*x*x*x*x*x*x))",T(12.34),T(0.0),T(1.0)), - test_xy("equal( x^-9,1/(x*x*x*x*x*x*x*x*x))",T(12.34),T(0.0),T(1.0)), - test_xy("equal(x^-10,1/(x*x*x*x*x*x*x*x*x*x))",T(12.34),T(0.0),T(1.0)), - test_xy("equal(x^-11,1/(x*x*x*x*x*x*x*x*x*x*x))",T(12.34),T(0.0),T(1.0)), - test_xy("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)), - test_xy("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)), - test_xy("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)), - test_xy("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)), - test_xy("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)), - test_xy("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)), - test_xy("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)), - test_xy("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)), - test_xy("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)), - test_xy("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)), - test_xy("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)), - test_xy("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)), - test_xy("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))",T(12.34),T(0.0),T(1.0)), - test_xy("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))",T(12.34),T(0.0),T(1.0)), - test_xy("equal( y^-0,1/1)",T(0.0),T(12.34),T(1.0)), - test_xy("equal( y^-1,1/(y))",T(0.0),T(12.34),T(1.0)), - test_xy("equal( y^-2,1/(y*y))",T(0.0),T(12.34),T(1.0)), - test_xy("equal( y^-3,1/(y*y*y))",T(0.0),T(12.34),T(1.0)), - test_xy("equal( y^-4,1/(y*y*y*y))",T(0.0),T(12.34),T(1.0)), - test_xy("equal( y^-5,1/(y*y*y*y*y))",T(0.0),T(12.34),T(1.0)), - test_xy("equal( y^-6,1/(y*y*y*y*y*y))",T(0.0),T(12.34),T(1.0)), - test_xy("equal( y^-7,1/(y*y*y*y*y*y*y))",T(0.0),T(12.34),T(1.0)), - test_xy("equal( y^-8,1/(y*y*y*y*y*y*y*y))",T(0.0),T(12.34),T(1.0)), - test_xy("equal( y^-9,1/(y*y*y*y*y*y*y*y*y))",T(0.0),T(12.34),T(1.0)), - test_xy("equal(y^-10,1/(y*y*y*y*y*y*y*y*y*y))",T(0.0),T(12.34),T(1.0)), - test_xy("equal(y^-11,1/(y*y*y*y*y*y*y*y*y*y*y))",T(0.0),T(12.34),T(1.0)), - test_xy("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)), - test_xy("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)), - test_xy("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)), - test_xy("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)), - test_xy("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)), - test_xy("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)), - test_xy("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)), - test_xy("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)), - test_xy("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)), - test_xy("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)), - test_xy("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)), - test_xy("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)), - test_xy("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))",T(0.0),T(12.34),T(1.0)), - test_xy("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))",T(0.0),T(12.34),T(1.0)), - test_xy("(2 + x) + 7",T(3.0),T(0.0),T((2.0 + 3.0) + 7.0)), - test_xy("(2 + x) - 7",T(3.0),T(0.0),T((2.0 + 3.0) - 7.0)), - test_xy("(2 - x) + 7",T(3.0),T(0.0),T((2.0 - 3.0) + 7.0)), - test_xy("(2 - x) - 7",T(3.0),T(0.0),T((2.0 - 3.0) - 7.0)), - test_xy("(2 * x) * 7",T(3.0),T(0.0),T((2.0 * 3.0) * 7.0)), - test_xy("(2 * x) / 7",T(3.0),T(0.0),T((2.0 * 3.0) / 7.0)), - test_xy("(2 / x) * 7",T(3.0),T(0.0),T((2.0 / 3.0) * 7.0)), - test_xy("(2 / x) / 7",T(3.0),T(0.0),T((2.0 / 3.0) / 7.0)), - test_xy("2 + (x + 7)",T(3.0),T(0.0),T(2.0 + (3.0 + 7.0))), - test_xy("2 + (x - 7)",T(3.0),T(0.0),T(2.0 + (3.0 - 7.0))), - test_xy("2 - (x + 7)",T(3.0),T(0.0),T(2.0 - (3.0 + 7.0))), - test_xy("2 - (x - 7)",T(3.0),T(0.0),T(2.0 - (3.0 - 7.0))), - test_xy("2 * (x * 7)",T(3.0),T(0.0),T(2.0 * (3.0 * 7.0))), - test_xy("2 * (x / 7)",T(3.0),T(0.0),T(2.0 * (3.0 / 7.0))), - test_xy("2 / (x * 7)",T(3.0),T(0.0),T(2.0 / (3.0 * 7.0))), - test_xy("2 / (x / 7)",T(3.0),T(0.0),T(2.0 / (3.0 / 7.0))), - test_xy("2 + (7 + x)",T(3.0),T(0.0),T(2.0 + (7.0 + 3.0))), - test_xy("2 + (7 - x)",T(3.0),T(0.0),T(2.0 + (7.0 - 3.0))), - test_xy("2 - (7 + x)",T(3.0),T(0.0),T(2.0 - (7.0 + 3.0))), - test_xy("2 - (7 - x)",T(3.0),T(0.0),T(2.0 - (7.0 - 3.0))), - test_xy("2 * (7 * x)",T(3.0),T(0.0),T(2.0 * (7.0 * 3.0))), - test_xy("2 * (7 / x)",T(3.0),T(0.0),T(2.0 * (7.0 / 3.0))), - test_xy("2 / (7 * x)",T(3.0),T(0.0),T(2.0 / (7.0 * 3.0))), - test_xy("2 / (7 / x)",T(3.0),T(0.0),T(2.0 / (7.0 / 3.0))), - test_xy("(x + 2) + 7",T(3.0),T(0.0),T((3.0 + 2.0) + 7.0)), - test_xy("(x + 2) - 7",T(3.0),T(0.0),T((3.0 + 2.0) - 7.0)), - test_xy("(x - 2) + 7",T(3.0),T(0.0),T((3.0 - 2.0) + 7.0)), - test_xy("(x - 2) - 7",T(3.0),T(0.0),T((3.0 - 2.0) - 7.0)), - test_xy("(x * 2) * 7",T(3.0),T(0.0),T((3.0 * 2.0) * 7.0)), - test_xy("(x * 2) / 7",T(3.0),T(0.0),T((3.0 * 2.0) / 7.0)), - test_xy("(x / 2) * 7",T(3.0),T(0.0),T((3.0 / 2.0) * 7.0)), - test_xy("(x / 2) / 7",T(3.0),T(0.0),T((3.0 / 2.0) / 7.0)), - test_xy("((2 + x) + (3 + y))",T(7.0),T(9.0),T(((2.0 + 7.0) + (3.0 + 9.0)))), - test_xy("((2 + x) - (3 + y))",T(7.0),T(9.0),T(((2.0 + 7.0) - (3.0 + 9.0)))), - test_xy("((2 - x) - (3 - y))",T(7.0),T(9.0),T(((2.0 - 7.0) - (3.0 - 9.0)))), - test_xy("((2 * x) * (3 * y))",T(7.0),T(9.0),T(((2.0 * 7.0) * (3.0 * 9.0)))), - test_xy("((x + 2) + (y + 3))",T(7.0),T(9.0),T(((7.0 + 2.0) + (9.0 + 3.0)))), - test_xy("((x + 2) - (y + 3))",T(7.0),T(9.0),T(((7.0 + 2.0) - (9.0 + 3.0)))), - test_xy("((x - 2) - (y - 3))",T(7.0),T(9.0),T(((7.0 - 2.0) - (9.0 - 3.0)))), - test_xy("((2 * x) * (3 * y))",T(7.0),T(9.0),T(((2.0 * 7.0) * (3.0 * 9.0)))), - test_xy("((2 + x) + (y + 3))",T(7.0),T(9.0),T(((2.0 + 7.0) + (9.0 + 3.0)))), - test_xy("((2 + x) - (y + 3))",T(7.0),T(9.0),T(((2.0 + 7.0) - (9.0 + 3.0)))), - test_xy("((2 - x) - (y - 3))",T(7.0),T(9.0),T(((2.0 - 7.0) - (9.0 - 3.0)))), - test_xy("((2 * x) * (3 * y))",T(7.0),T(9.0),T(((2.0 * 7.0) * (3.0 * 9.0)))), - test_xy("((x + 2) + (3 + y))",T(7.0),T(9.0),T(((7.0 + 2.0) + (3.0 + 9.0)))), - test_xy("((x + 2) - (3 + y))",T(7.0),T(9.0),T(((7.0 + 2.0) - (3.0 + 9.0)))), - test_xy("((x - 2) - (3 - y))",T(7.0),T(9.0),T(((7.0 - 2.0) - (3.0 - 9.0)))), - test_xy("((2 * x) * (3 * y))",T(7.0),T(9.0),T(((2.0 * 7.0) * (3.0 * 9.0)))), - test_xy("0 * (abs (x) + acos (y) + asin (x) + atan (y))",T(1.0),T(1.0),T(0.0)), - test_xy("0 * (ceil (x) + cos (y) + cosh (x) + exp (y))",T(1.0),T(1.0),T(0.0)), - test_xy("0 * (floor(x) + log (y) + log10(x) + round(y))",T(1.0),T(1.0),T(0.0)), - test_xy("0 * (sin (x) + sinh (y) + sqrt (x) + tan (y))",T(1.0),T(1.0),T(0.0)), - test_xy("0 * (sec (x) + csc (y) + tanh (x) + cot (y))",T(1.0),T(1.0),T(0.0)), - test_xy("0 * (erf (x) + erfc (y) + sgn (y) + frac (y))",T(1.0),T(1.0),T(0.0)), - test_xy("0 * (log1p(x) + expm1(y) + acosh(x) + asinh(y))",T(1.0),T(1.0),T(0.0)), - test_xy("0 * (deg2grad(x) + grad2deg(y) + rad2deg(x) + deg2rad(y))",T(1.0),T(1.0),T(0.0)), - test_xy("switch { case (x <= y) : (y - x); default: 1.12345; }",T(1.0),T(2.0),T(1.0)), - test_xy("switch { case (x > y) : 0; case (x <= y) : (y - x); default: 1.12345; }",T(1.0),T(2.0),T(1.0)), - test_xy("switch { case (x <= y) : switch { case (x <= y) : (y - x); default: 1.12345; }; default: 1.12345; }",T(1.0),T(2.0),T(1.0)), - test_xy("switch { case [x <= y] : [y - x]; default: 1.12345; }",T(1.0),T(2.0),T(1.0)), - test_xy("switch { case [x > y] : 0; case [x <= y] : [y - x]; default: 1.12345; }",T(1.0),T(2.0),T(1.0)), - test_xy("switch { case [x <= y] : switch { case [x <= y] : {y - x}; default: 1.12345; }; default: 1.12345; }",T(1.0),T(2.0),T(1.0)), - test_xy("switch { case {x <= y} : x; default: 1.12345; }",T(1.0),T(2.0),T(1.0)), - test_xy("switch { case {x > y} : 0; case {x <= y} : {y - x}; default: 1.12345; }",T(1.0),T(2.0),T(1.0)), - test_xy("switch { case {x <= y} : switch { case {x <= y} : x; default: 1.12345; }; default: 1.12345; }",T(1.0),T(2.0),T(1.0)), - test_xy("switch { case [(x <= y)] : {y - x}; default: 1.12345; }",T(1.0),T(2.0),T(1.0)), - test_xy("switch { case ([x > y]) : [0]; case ([x <= y]) : [y - x]; default: 1.12345; }",T(1.0),T(2.0),T(1.0)), - test_xy("switch { case {(x <= y)} : switch { case ({x <= y}) : x; default: 1.12345; }; default: 1.12345; }",T(1.0),T(2.0),T(1.0)), - test_xy("[*]{ case x < y : x + y; case y < x : y - x; }",T(2.0),T(3.0),T(5.0)), - test_xy("[*]{ case x > y : x + y; case y > x : y - x; }",T(2.0),T(3.0),T(1.0)), - test_xy("[*]{ case x > y : x - y; case y < x : y + x; }",T(2.0),T(3.0),T(0.0)) - }; - - static const std::size_t test_list_size = sizeof(test_list) / sizeof(test_xy); - - const std::size_t rounds = 60; - - for (std::size_t r = 0; r < rounds; ++r) { - bool loop_result = true; - for (std::size_t i = 0; i < test_list_size; ++i) + static const test_xy test_list[] = + { + test_xy("x + y" ,T(2.2),T(3.3),T(5.5 )), + test_xy("x - y" ,T(3.3),T(2.2),T(1.1 )), + test_xy("x * y" ,T(3.3),T(2.2),T(7.26 )), + test_xy("x / y" ,T(3.3),T(2.2),T(1.5 )), + test_xy("(x + y) * (x + y)" ,T(2.2),T(3.3),T(30.25)), + test_xy("(x + y) / (x + y)" ,T(2.2),T(3.3),T(1.0 )), + test_xy("x + y > x and x + y > y" ,T(2.2),T(3.3),T(1.0)), + test_xy("1 + (x + y)" ,T(2.2),T(3.3),T(6.5 )), + test_xy("(x + y) - 1" ,T(2.2),T(3.3),T(4.5 )), + test_xy("1 + (x + y) * 2" ,T(2.2),T(3.3),T(12.0 )), + test_xy("2 * (x + y) - 1" ,T(2.2),T(3.3),T(10.0 )), + test_xy("y + (x + 1)" ,T(2.2),T(3.3),T(6.5 )), + test_xy("(x + 1) + y" ,T(2.2),T(3.3),T(6.5 )), + test_xy("2 * x" ,T(2.2),T(0.0),T(4.4)), + test_xy("x * 2" ,T(2.2),T(0.0),T(4.4)), + test_xy("1.1 + x",T(2.2),T(0.0),T(3.3)), + test_xy("x + 1.1",T(2.2),T(0.0),T(3.3)), + test_xy("x * 1 == x" ,T(2.0),T(3.0),T(1.0)), + test_xy("1 * x == x" ,T(2.0),T(3.0),T(1.0)), + test_xy("y * 1 == y" ,T(2.0),T(3.0),T(1.0)), + test_xy("1 * y == y" ,T(2.0),T(3.0),T(1.0)), + test_xy("x * 0 == 0" ,T(2.0),T(3.0),T(1.0)), + test_xy("0 * x == 0" ,T(2.0),T(3.0),T(1.0)), + test_xy("y * 0 == 0" ,T(2.0),T(3.0),T(1.0)), + test_xy("0 * y == 0" ,T(2.0),T(3.0),T(1.0)), + test_xy("x + 1 == 1 + x",T(2.0),T(3.0),T(1.0)), + test_xy("y + 1 == 1 + y",T(2.0),T(3.0),T(1.0)), + test_xy("x + y == y + x",T(2.0),T(3.0),T(1.0)), + test_xy("x * y == y * x",T(2.0),T(3.0),T(1.0)), + test_xy("x < y" ,T(2.0),T(3.0),T(1.0)), + test_xy("y > x" ,T(2.0),T(3.0),T(1.0)), + test_xy("x <= y" ,T(2.0),T(3.0),T(1.0)), + test_xy("y >= x" ,T(2.0),T(3.0),T(1.0)), + test_xy("x + y > y" ,T(2.0),T(3.0),T(1.0)), + test_xy("x + y > x" ,T(2.0),T(3.0),T(1.0)), + test_xy("x * y > y" ,T(2.0),T(3.0),T(1.0)), + test_xy("x * y > x" ,T(2.0),T(3.0),T(1.0)), + test_xy("(x + y) > y" ,T(2.0),T(3.0),T(1.0)), + test_xy("(x + y) > x" ,T(2.0),T(3.0),T(1.0)), + test_xy("(x * y) > y" ,T(2.0),T(3.0),T(1.0)), + test_xy("(x * y) > x" ,T(2.0),T(3.0),T(1.0)), + test_xy("(2x + 3y) == (2*x + 3*y)" ,T(2.0),T(3.0),T(1.0)), + test_xy("2(x + y) == (2*x + 2*y)" ,T(2.0),T(3.0),T(1.0)), + test_xy(" (x + y)3 == (3*x + 3*y)" ,T(2.0),T(3.0),T(1.0)), + test_xy("2x + 3y == 2*x + 3*y" ,T(2.0),T(3.0),T(1.0)), + test_xy("2(x + y) == 2*x + 2*y" ,T(2.0),T(3.0),T(1.0)), + test_xy(" (x + y)3 == 3*x + 3*y" ,T(2.0),T(3.0),T(1.0)), + test_xy("equal(x^2.2^1.1,17.15193942371376191362)" ,T(3.3),T(0.0),T(1.0)), + test_xy("equal(3.3^x^1.1,17.15193942371376191362)" ,T(2.2),T(0.0),T(1.0)), + test_xy("equal(3.3^2.2^x,17.15193942371376191362)" ,T(1.1),T(0.0),T(1.0)), + test_xy("equal(x^2.2^y,17.15193942371376191362)" ,T(3.3),T(1.1),T(1.0)), + test_xy("equal(x^y^1.1,17.15193942371376191362)" ,T(3.3),T(2.2),T(1.0)), + test_xy("equal(3.3^x^y,17.15193942371376191362)" ,T(2.2),T(1.1),T(1.0)), + test_xy("equal(x+y^3/7,x+(y*y*y)/7)",T(2.0),T(3.0),T(1.0)), + test_xy("equal(1-x^3+y^2*7,1-(x*x*x)+(y*y)*7)",T(2.0),T(3.0),T(1.0)), + test_xy("equal( x^0,1)",T(12.34),T(0.0),T(1.0)), + test_xy("equal( x^1,x)",T(12.34),T(0.0),T(1.0)), + test_xy("equal( x^2,x*x)",T(12.34),T(0.0),T(1.0)), + test_xy("equal( x^3,x*x*x)",T(12.34),T(0.0),T(1.0)), + test_xy("equal( x^4,x*x*x*x)",T(12.34),T(0.0),T(1.0)), + test_xy("equal( x^5,x*x*x*x*x)",T(12.34),T(0.0),T(1.0)), + test_xy("equal( x^6,x*x*x*x*x*x)",T(12.34),T(0.0),T(1.0)), + test_xy("equal( x^7,x*x*x*x*x*x*x)",T(12.34),T(0.0),T(1.0)), + test_xy("equal( x^8,x*x*x*x*x*x*x*x)",T(12.34),T(0.0),T(1.0)), + test_xy("equal( x^9,x*x*x*x*x*x*x*x*x)",T(12.34),T(0.0),T(1.0)), + test_xy("equal(x^10,x*x*x*x*x*x*x*x*x*x)",T(12.34),T(0.0),T(1.0)), + test_xy("equal(x^11,x*x*x*x*x*x*x*x*x*x*x)",T(12.34),T(0.0),T(1.0)), + test_xy("equal(x^12,x*x*x*x*x*x*x*x*x*x*x*x)",T(12.34),T(0.0),T(1.0)), + test_xy("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)), + test_xy("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)), + test_xy("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)), + test_xy("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)), + test_xy("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)), + test_xy("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)), + test_xy("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)), + test_xy("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)), + test_xy("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)), + test_xy("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)), + test_xy("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)), + test_xy("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)), + test_xy("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)), + test_xy("equal( y^0,1)",T(0.0),T(12.34),T(1.0)), + test_xy("equal( y^1,y)",T(0.0),T(12.34),T(1.0)), + test_xy("equal( y^2,y*y)",T(0.0),T(12.34),T(1.0)), + test_xy("equal( y^3,y*y*y)",T(0.0),T(12.34),T(1.0)), + test_xy("equal( y^4,y*y*y*y)",T(0.0),T(12.34),T(1.0)), + test_xy("equal( y^5,y*y*y*y*y)",T(0.0),T(12.34),T(1.0)), + test_xy("equal( y^6,y*y*y*y*y*y)",T(0.0),T(12.34),T(1.0)), + test_xy("equal( y^7,y*y*y*y*y*y*y)",T(0.0),T(12.34),T(1.0)), + test_xy("equal( y^8,y*y*y*y*y*y*y*y)",T(0.0),T(12.34),T(1.0)), + test_xy("equal( y^9,y*y*y*y*y*y*y*y*y)",T(0.0),T(12.34),T(1.0)), + test_xy("equal(y^10,y*y*y*y*y*y*y*y*y*y)",T(0.0),T(12.34),T(1.0)), + test_xy("equal(y^11,y*y*y*y*y*y*y*y*y*y*y)",T(0.0),T(12.34),T(1.0)), + test_xy("equal(y^12,y*y*y*y*y*y*y*y*y*y*y*y)",T(0.0),T(12.34),T(1.0)), + test_xy("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)), + test_xy("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)), + test_xy("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)), + test_xy("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)), + test_xy("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)), + test_xy("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)), + test_xy("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)), + test_xy("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)), + test_xy("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)), + test_xy("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)), + test_xy("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)), + test_xy("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)), + test_xy("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)), + test_xy("equal( x^-0,1/1)",T(12.34),T(0.0),T(1.0)), + test_xy("equal( x^-1,1/(x))",T(12.34),T(0.0),T(1.0)), + test_xy("equal( x^-2,1/(x*x))",T(12.34),T(0.0),T(1.0)), + test_xy("equal( x^-3,1/(x*x*x))",T(12.34),T(0.0),T(1.0)), + test_xy("equal( x^-4,1/(x*x*x*x))",T(12.34),T(0.0),T(1.0)), + test_xy("equal( x^-5,1/(x*x*x*x*x))",T(12.34),T(0.0),T(1.0)), + test_xy("equal( x^-6,1/(x*x*x*x*x*x))",T(12.34),T(0.0),T(1.0)), + test_xy("equal( x^-7,1/(x*x*x*x*x*x*x))",T(12.34),T(0.0),T(1.0)), + test_xy("equal( x^-8,1/(x*x*x*x*x*x*x*x))",T(12.34),T(0.0),T(1.0)), + test_xy("equal( x^-9,1/(x*x*x*x*x*x*x*x*x))",T(12.34),T(0.0),T(1.0)), + test_xy("equal(x^-10,1/(x*x*x*x*x*x*x*x*x*x))",T(12.34),T(0.0),T(1.0)), + test_xy("equal(x^-11,1/(x*x*x*x*x*x*x*x*x*x*x))",T(12.34),T(0.0),T(1.0)), + test_xy("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)), + test_xy("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)), + test_xy("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)), + test_xy("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)), + test_xy("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)), + test_xy("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)), + test_xy("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)), + test_xy("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)), + test_xy("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)), + test_xy("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)), + test_xy("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)), + test_xy("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)), + test_xy("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))",T(12.34),T(0.0),T(1.0)), + test_xy("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))",T(12.34),T(0.0),T(1.0)), + test_xy("equal( y^-0,1/1)",T(0.0),T(12.34),T(1.0)), + test_xy("equal( y^-1,1/(y))",T(0.0),T(12.34),T(1.0)), + test_xy("equal( y^-2,1/(y*y))",T(0.0),T(12.34),T(1.0)), + test_xy("equal( y^-3,1/(y*y*y))",T(0.0),T(12.34),T(1.0)), + test_xy("equal( y^-4,1/(y*y*y*y))",T(0.0),T(12.34),T(1.0)), + test_xy("equal( y^-5,1/(y*y*y*y*y))",T(0.0),T(12.34),T(1.0)), + test_xy("equal( y^-6,1/(y*y*y*y*y*y))",T(0.0),T(12.34),T(1.0)), + test_xy("equal( y^-7,1/(y*y*y*y*y*y*y))",T(0.0),T(12.34),T(1.0)), + test_xy("equal( y^-8,1/(y*y*y*y*y*y*y*y))",T(0.0),T(12.34),T(1.0)), + test_xy("equal( y^-9,1/(y*y*y*y*y*y*y*y*y))",T(0.0),T(12.34),T(1.0)), + test_xy("equal(y^-10,1/(y*y*y*y*y*y*y*y*y*y))",T(0.0),T(12.34),T(1.0)), + test_xy("equal(y^-11,1/(y*y*y*y*y*y*y*y*y*y*y))",T(0.0),T(12.34),T(1.0)), + test_xy("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)), + test_xy("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)), + test_xy("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)), + test_xy("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)), + test_xy("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)), + test_xy("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)), + test_xy("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)), + test_xy("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)), + test_xy("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)), + test_xy("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)), + test_xy("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)), + test_xy("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)), + test_xy("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))",T(0.0),T(12.34),T(1.0)), + test_xy("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))",T(0.0),T(12.34),T(1.0)), + test_xy("(2 + x) + 7",T(3.0),T(0.0),T((2.0 + 3.0) + 7.0)), + test_xy("(2 + x) - 7",T(3.0),T(0.0),T((2.0 + 3.0) - 7.0)), + test_xy("(2 - x) + 7",T(3.0),T(0.0),T((2.0 - 3.0) + 7.0)), + test_xy("(2 - x) - 7",T(3.0),T(0.0),T((2.0 - 3.0) - 7.0)), + test_xy("(2 * x) * 7",T(3.0),T(0.0),T((2.0 * 3.0) * 7.0)), + test_xy("(2 * x) / 7",T(3.0),T(0.0),T((2.0 * 3.0) / 7.0)), + test_xy("(2 / x) * 7",T(3.0),T(0.0),T((2.0 / 3.0) * 7.0)), + test_xy("(2 / x) / 7",T(3.0),T(0.0),T((2.0 / 3.0) / 7.0)), + test_xy("2 + (x + 7)",T(3.0),T(0.0),T(2.0 + (3.0 + 7.0))), + test_xy("2 + (x - 7)",T(3.0),T(0.0),T(2.0 + (3.0 - 7.0))), + test_xy("2 - (x + 7)",T(3.0),T(0.0),T(2.0 - (3.0 + 7.0))), + test_xy("2 - (x - 7)",T(3.0),T(0.0),T(2.0 - (3.0 - 7.0))), + test_xy("2 * (x * 7)",T(3.0),T(0.0),T(2.0 * (3.0 * 7.0))), + test_xy("2 * (x / 7)",T(3.0),T(0.0),T(2.0 * (3.0 / 7.0))), + test_xy("2 / (x * 7)",T(3.0),T(0.0),T(2.0 / (3.0 * 7.0))), + test_xy("2 / (x / 7)",T(3.0),T(0.0),T(2.0 / (3.0 / 7.0))), + test_xy("2 + (7 + x)",T(3.0),T(0.0),T(2.0 + (7.0 + 3.0))), + test_xy("2 + (7 - x)",T(3.0),T(0.0),T(2.0 + (7.0 - 3.0))), + test_xy("2 - (7 + x)",T(3.0),T(0.0),T(2.0 - (7.0 + 3.0))), + test_xy("2 - (7 - x)",T(3.0),T(0.0),T(2.0 - (7.0 - 3.0))), + test_xy("2 * (7 * x)",T(3.0),T(0.0),T(2.0 * (7.0 * 3.0))), + test_xy("2 * (7 / x)",T(3.0),T(0.0),T(2.0 * (7.0 / 3.0))), + test_xy("2 / (7 * x)",T(3.0),T(0.0),T(2.0 / (7.0 * 3.0))), + test_xy("2 / (7 / x)",T(3.0),T(0.0),T(2.0 / (7.0 / 3.0))), + test_xy("(x + 2) + 7",T(3.0),T(0.0),T((3.0 + 2.0) + 7.0)), + test_xy("(x + 2) - 7",T(3.0),T(0.0),T((3.0 + 2.0) - 7.0)), + test_xy("(x - 2) + 7",T(3.0),T(0.0),T((3.0 - 2.0) + 7.0)), + test_xy("(x - 2) - 7",T(3.0),T(0.0),T((3.0 - 2.0) - 7.0)), + test_xy("(x * 2) * 7",T(3.0),T(0.0),T((3.0 * 2.0) * 7.0)), + test_xy("(x * 2) / 7",T(3.0),T(0.0),T((3.0 * 2.0) / 7.0)), + test_xy("(x / 2) * 7",T(3.0),T(0.0),T((3.0 / 2.0) * 7.0)), + test_xy("(x / 2) / 7",T(3.0),T(0.0),T((3.0 / 2.0) / 7.0)), + test_xy("((2 + x) + (3 + y))",T(7.0),T(9.0),T(((2.0 + 7.0) + (3.0 + 9.0)))), + test_xy("((2 + x) - (3 + y))",T(7.0),T(9.0),T(((2.0 + 7.0) - (3.0 + 9.0)))), + test_xy("((2 - x) - (3 - y))",T(7.0),T(9.0),T(((2.0 - 7.0) - (3.0 - 9.0)))), + test_xy("((2 * x) * (3 * y))",T(7.0),T(9.0),T(((2.0 * 7.0) * (3.0 * 9.0)))), + test_xy("((x + 2) + (y + 3))",T(7.0),T(9.0),T(((7.0 + 2.0) + (9.0 + 3.0)))), + test_xy("((x + 2) - (y + 3))",T(7.0),T(9.0),T(((7.0 + 2.0) - (9.0 + 3.0)))), + test_xy("((x - 2) - (y - 3))",T(7.0),T(9.0),T(((7.0 - 2.0) - (9.0 - 3.0)))), + test_xy("((2 * x) * (3 * y))",T(7.0),T(9.0),T(((2.0 * 7.0) * (3.0 * 9.0)))), + test_xy("((2 + x) + (y + 3))",T(7.0),T(9.0),T(((2.0 + 7.0) + (9.0 + 3.0)))), + test_xy("((2 + x) - (y + 3))",T(7.0),T(9.0),T(((2.0 + 7.0) - (9.0 + 3.0)))), + test_xy("((2 - x) - (y - 3))",T(7.0),T(9.0),T(((2.0 - 7.0) - (9.0 - 3.0)))), + test_xy("((2 * x) * (3 * y))",T(7.0),T(9.0),T(((2.0 * 7.0) * (3.0 * 9.0)))), + test_xy("((x + 2) + (3 + y))",T(7.0),T(9.0),T(((7.0 + 2.0) + (3.0 + 9.0)))), + test_xy("((x + 2) - (3 + y))",T(7.0),T(9.0),T(((7.0 + 2.0) - (3.0 + 9.0)))), + test_xy("((x - 2) - (3 - y))",T(7.0),T(9.0),T(((7.0 - 2.0) - (3.0 - 9.0)))), + test_xy("((2 * x) * (3 * y))",T(7.0),T(9.0),T(((2.0 * 7.0) * (3.0 * 9.0)))), + test_xy("((2 * x) / (3 * y))",T(7.0),T(9.0),T(((2.0 * 7.0) / (3.0 * 9.0)))), + test_xy("((2 / x) * (3 / y))",T(7.0),T(9.0),T(((2.0 / 7.0) * (3.0 / 9.0)))), + test_xy("((2 * x) / (3 / y))",T(7.0),T(9.0),T(((2.0 * 7.0) / (3.0 / 9.0)))), + test_xy("((2 / x) / (3 * y))",T(7.0),T(9.0),T(((2.0 / 7.0) / (3.0 * 9.0)))), + test_xy("((x * 2) / (y * 3))",T(7.0),T(9.0),T(((7.0 * 2.0) / (9.0 * 3.0)))), + test_xy("((x / 2) * (y / 3))",T(7.0),T(9.0),T(((7.0 / 2.0) * (9.0 / 3.0)))), + test_xy("((x * 2) / (y / 3))",T(7.0),T(9.0),T(((7.0 * 2.0) / (9.0 / 3.0)))), + test_xy("((x / 2) / (y * 3))",T(7.0),T(9.0),T(((7.0 / 2.0) / (9.0 * 3.0)))), + test_xy("((2 * x) / (y * 3))",T(7.0),T(9.0),T(((2.0 * 7.0) / (9.0 * 3.0)))), + test_xy("((2 / x) * (y / 3))",T(7.0),T(9.0),T(((2.0 / 7.0) * (9.0 / 3.0)))), + test_xy("((2 * x) / (y / 3))",T(7.0),T(9.0),T(((2.0 * 7.0) / (9.0 / 3.0)))), + test_xy("((2 / x) / (y * 3))",T(7.0),T(9.0),T(((2.0 / 7.0) / (9.0 * 3.0)))), + test_xy("((x * 2) / (3 * y))",T(7.0),T(9.0),T(((7.0 * 2.0) / (3.0 * 9.0)))), + test_xy("((x / 2) * (3 / y))",T(7.0),T(9.0),T(((7.0 / 2.0) * (3.0 / 9.0)))), + test_xy("((x * 2) / (3 / y))",T(7.0),T(9.0),T(((7.0 * 2.0) / (3.0 / 9.0)))), + test_xy("((x / 2) / (3 * y))",T(7.0),T(9.0),T(((7.0 / 2.0) / (3.0 * 9.0)))), + test_xy("0 * (abs (x) + acos (y) + asin (x) + atan (y))",T(1.0),T(1.0),T(0.0)), + test_xy("0 * (ceil (x) + cos (y) + cosh (x) + exp (y))",T(1.0),T(1.0),T(0.0)), + test_xy("0 * (floor(x) + log (y) + log10(x) + round(y))",T(1.0),T(1.0),T(0.0)), + test_xy("0 * (sin (x) + sinh (y) + sqrt (x) + tan (y))",T(1.0),T(1.0),T(0.0)), + test_xy("0 * (sec (x) + csc (y) + tanh (x) + cot (y))",T(1.0),T(1.0),T(0.0)), + test_xy("0 * (erf (x) + erfc (y) + sgn (y) + frac (y))",T(1.0),T(1.0),T(0.0)), + test_xy("0 * (log1p(x) + expm1(y) + acosh(x) + asinh(y))",T(1.0),T(1.0),T(0.0)), + test_xy("0 * (deg2grad(x) + grad2deg(y) + rad2deg(x) + deg2rad(y))",T(1.0),T(1.0),T(0.0)), + test_xy("switch { case (x <= y) : (y - x); default: 1.12345; }",T(1.0),T(2.0),T(1.0)), + test_xy("switch { case (x > y) : 0; case (x <= y) : (y - x); default: 1.12345; }",T(1.0),T(2.0),T(1.0)), + test_xy("switch { case (x <= y) : switch { case (x <= y) : (y - x); default: 1.12345; }; default: 1.12345; }",T(1.0),T(2.0),T(1.0)), + test_xy("switch { case [x <= y] : [y - x]; default: 1.12345; }",T(1.0),T(2.0),T(1.0)), + test_xy("switch { case [x > y] : 0; case [x <= y] : [y - x]; default: 1.12345; }",T(1.0),T(2.0),T(1.0)), + test_xy("switch { case [x <= y] : switch { case [x <= y] : {y - x}; default: 1.12345; }; default: 1.12345; }",T(1.0),T(2.0),T(1.0)), + test_xy("switch { case {x <= y} : x; default: 1.12345; }",T(1.0),T(2.0),T(1.0)), + test_xy("switch { case {x > y} : 0; case {x <= y} : {y - x}; default: 1.12345; }",T(1.0),T(2.0),T(1.0)), + test_xy("switch { case {x <= y} : switch { case {x <= y} : x; default: 1.12345; }; default: 1.12345; }",T(1.0),T(2.0),T(1.0)), + test_xy("switch { case [(x <= y)] : {y - x}; default: 1.12345; }",T(1.0),T(2.0),T(1.0)), + test_xy("switch { case ([x > y]) : [0]; case ([x <= y]) : [y - x]; default: 1.12345; }",T(1.0),T(2.0),T(1.0)), + test_xy("switch { case {(x <= y)} : switch { case ({x <= y}) : x; default: 1.12345; }; default: 1.12345; }",T(1.0),T(2.0),T(1.0)), + test_xy("[*]{ case x < y : x + y; case y < x : y - x; }",T(2.0),T(3.0),T(5.0)), + test_xy("[*]{ case x > y : x + y; case y > x : y - x; }",T(2.0),T(3.0),T(1.0)), + test_xy("[*]{ case x > y : x - y; case y < x : y + x; }",T(2.0),T(3.0),T(0.0)) + }; + + static const std::size_t test_list_size = sizeof(test_list) / sizeof(test_xy); + + const std::size_t rounds = 60; + + for (std::size_t r = 0; r < rounds; ++r) { - test_xy& test = const_cast&>(test_list[i]); - - exprtk::symbol_table symbol_table; - symbol_table.add_variable("x",test.x); - symbol_table.add_variable("y",test.y); - - exprtk::expression expression; - expression.register_symbol_table(symbol_table); - + bool loop_result = true; + for (std::size_t i = 0; i < test_list_size; ++i) { - exprtk::parser parser; - if (!parser.compile(test.expr,expression)) + test_xy& test = const_cast&>(test_list[i]); + + exprtk::symbol_table symbol_table; + symbol_table.add_variable("x",test.x); + symbol_table.add_variable("y",test.y); + + exprtk::expression expression; + expression.register_symbol_table(symbol_table); + { - printf("run_test01() - Error: %s Expression: %s\n", - parser.error().c_str(), - test.expr.c_str()); + exprtk::parser parser; + if (!parser.compile(test.expr,expression)) + { + printf("run_test01() - Error: %s Expression: %s\n", + parser.error().c_str(), + test.expr.c_str()); + loop_result = false; + continue; + } + } + + T result = expression.value(); + + if (not_equal(result,test.result)) + { + printf("run_test01() - Computation Error: Expression: [%s]\tExpected: %19.15f\tResult: %19.15f\n", + test.expr.c_str(), + test.result, + result); loop_result = false; - continue; } } - T result = expression.value(); - - if (not_equal(result,test.result)) + if (!loop_result) { - printf("run_test01() - Computation Error: Expression: [%s]\tExpected: %19.15f\tResult: %19.15f\n", - test.expr.c_str(), - test.result, - result); - loop_result = false; + return false; } } + } - if (!loop_result) + { + static const test_xyz test_list[] = + { + test_xyz("((x / y) / z )",T(7.0),T(9.0),T(3.0),T(((7.0 / 9.0) / 3.0 ))), + test_xyz("((x / y) / 2 )",T(7.0),T(9.0),T(3.0),T(((7.0 / 9.0) / 2.0 ))), + test_xyz("((x / 2) / y )",T(7.0),T(9.0),T(3.0),T(((7.0 / 2.0) / 9.0 ))), + test_xyz("((2 / x) / y )",T(7.0),T(9.0),T(3.0),T(((2.0 / 7.0) / 9.0 ))), + test_xyz("( x / (y / z))",T(7.0),T(9.0),T(3.0),T(( 7.0 / (9.0 / 3.0)))), + test_xyz("( x / (y / 2))",T(7.0),T(9.0),T(3.0),T(( 7.0 / (9.0 / 2.0)))), + test_xyz("( x / (2 / y))",T(7.0),T(9.0),T(3.0),T(( 7.0 / (2.0 / 9.0)))), + test_xyz("( 2 / (x / y))",T(7.0),T(9.0),T(3.0),T(( 2.0 / (7.0 / 9.0)))) + }; + + static const std::size_t test_list_size = sizeof(test_list) / sizeof(test_xyz); + + const std::size_t rounds = 60; + + for (std::size_t r = 0; r < rounds; ++r) { - return false; + bool loop_result = true; + for (std::size_t i = 0; i < test_list_size; ++i) + { + test_xyz& test = const_cast&>(test_list[i]); + + exprtk::symbol_table symbol_table; + symbol_table.add_variable("x",test.x); + symbol_table.add_variable("y",test.y); + symbol_table.add_variable("z",test.z); + + exprtk::expression expression; + expression.register_symbol_table(symbol_table); + + { + exprtk::parser parser; + if (!parser.compile(test.expr,expression)) + { + printf("run_test01() - Error: %s Expression: %s\n", + parser.error().c_str(), + test.expr.c_str()); + loop_result = false; + continue; + } + } + + T result = expression.value(); + + if (not_equal(result,test.result)) + { + printf("run_test01() - Computation Error: Expression: [%s]\tExpected: %19.15f\tResult: %19.15f\n", + test.expr.c_str(), + test.result, + result); + loop_result = false; + } + } + + if (!loop_result) + { + return false; + } } } diff --git a/readme.txt b/readme.txt index 8a6e985..0b0611e 100644 --- a/readme.txt +++ b/readme.txt @@ -415,9 +415,9 @@ There are three primary components, that are specialized upon a given numeric type, which make up the core of ExprTk. The components are as follows: - 1. Symbol Table exprtk::symbol_table - 2. Expression exprtk::expression - 3. Parser exprtk::parser + 1. Symbol Table exprtk::symbol_table + 2. Expression exprtk::expression + 3. Parser exprtk::parser (1) Symbol Table @@ -447,15 +447,15 @@ Expression: z := (x + y^-2.345) * sin(pi / min(w - 7.3,v)) / \ ___/ \___ Variable(x) [Power] / \ ______/ \______ Constant(pi) [Binary-Func(min)] - / \ ___/ \___ - Variable(y) [Negate] / \ - | / Variable(v) - Constant(2.345) / - / - [Subtract] - ____/ \___ - / \ - Variable(w) Constant(7.3) + / \ ____/ \____ + Variable(y) [Negate] / \ + | / Variable(v) + Constant(2.345) / + / + [Subtract] + ____/ \____ + / \ + Variable(w) Constant(7.3) (3) Parser A structure which takes as input a string representation of an @@ -484,58 +484,58 @@ correctly optimize such expressions for a given architecture. +-------------+-------------+ +--------------+------------------+ | Prototype | Operation | | Prototype | Operation | +-------------+-------------+ +--------------+------------------+ - $f00(x,y,z) | (x + y) / z $f47(x,y,z,w) | x + ((y + z) / w) - $f01(x,y,z) | (x + y) * z $f48(x,y,z,w) | x + ((y + z) * w) - $f02(x,y,z) | (x + y) - z $f49(x,y,z,w) | x + ((y - z) / w) - $f03(x,y,z) | (x + y) + z $f50(x,y,z,w) | x + ((y - z) * w) - $f04(x,y,z) | (x - y) / z $f51(x,y,z,w) | x + ((y * z) / w) - $f05(x,y,z) | (x - y) * z $f52(x,y,z,w) | x + ((y * z) * w) - $f06(x,y,z) | (x * y) + z $f53(x,y,z,w) | x + ((y / z) + w) - $f07(x,y,z) | (x * y) - z $f54(x,y,z,w) | x + ((y / z) / w) - $f08(x,y,z) | (x * y) / z $f55(x,y,z,w) | x + ((y / z) * w) - $f09(x,y,z) | (x * y) * z $f56(x,y,z,w) | x - ((y + z) / w) - $f10(x,y,z) | (x / y) + z $f57(x,y,z,w) | x - ((y + z) * w) - $f11(x,y,z) | (x / y) - z $f58(x,y,z,w) | x - ((y - z) / w) - $f12(x,y,z) | (x / y) / z $f59(x,y,z,w) | x - ((y - z) * w) - $f13(x,y,z) | (x / y) * z $f60(x,y,z,w) | x - ((y * z) / w) - $f14(x,y,z) | x / (y + z) $f61(x,y,z,w) | x - ((y * z) * w) - $f15(x,y,z) | x / (y - z) $f62(x,y,z,w) | x - ((y / z) / w) - $f16(x,y,z) | x / (y * z) $f63(x,y,z,w) | x - ((y / z) * w) - $f17(x,y,z) | x / (y / z) $f64(x,y,z,w) | ((x + y) * z) - w - $f18(x,y,z) | x * (y + z) $f65(x,y,z,w) | ((x - y) * z) - w - $f19(x,y,z) | x * (y - z) $f66(x,y,z,w) | ((x * y) * z) - w - $f20(x,y,z) | x * (y * z) $f67(x,y,z,w) | ((x / y) * z) - w - $f21(x,y,z) | x * (y / z) $f68(x,y,z,w) | ((x + y) / z) - w - $f22(x,y,z) | x - (y + z) $f69(x,y,z,w) | ((x - y) / z) - w - $f23(x,y,z) | x - (y - z) $f70(x,y,z,w) | ((x * y) / z) - w - $f24(x,y,z) | x - (y / z) $f71(x,y,z,w) | ((x / y) / z) - w - $f25(x,y,z) | x - (y * z) $f72(x,y,z,w) | (x * y) + (z * w) - $f26(x,y,z) | x + (y * z) $f73(x,y,z,w) | (x * y) - (z * w) - $f27(x,y,z) | x + (y / z) $f74(x,y,z,w) | (x * y) + (z / w) - $f28(x,y,z) | x + (y + z) $f75(x,y,z,w) | (x * y) - (z / w) - $f29(x,y,z) | x + (y - z) $f76(x,y,z,w) | (x / y) + (z / w) - $f30(x,y,z) | x * y^2 + z $f77(x,y,z,w) | (x / y) - (z / w) - $f31(x,y,z) | x * y^3 + z $f78(x,y,z,w) | (x / y) - (z * w) - $f32(x,y,z) | x * y^4 + z $f79(x,y,z,w) | x / (y + (z * w)) - $f33(x,y,z) | x * y^5 + z $f80(x,y,z,w) | x / (y - (z * w)) - $f34(x,y,z) | x * y^6 + z $f81(x,y,z,w) | x * (y + (z * w)) - $f35(x,y,z) | x * y^7 + z $f82(x,y,z,w) | x * (y - (z * w)) - $f36(x,y,z) | x * y^8 + z $f83(x,y,z,w) | x*y^2 + z*w^2 - $f37(x,y,z) | x * y^9 + z $f84(x,y,z,w) | x*y^3 + z*w^3 - $f38(x,y,z) | x * log(y)+z $f85(x,y,z,w) | x*y^4 + z*w^4 - $f39(x,y,z) | x * log(y)-z $f86(x,y,z,w) | x*y^5 + z*w^5 - $f40(x,y,z) | x * log10(y)+z $f87(x,y,z,w) | x*y^6 + z*w^6 - $f41(x,y,z) | x * log10(y)-z $f88(x,y,z,w) | x*y^7 + z*w^7 - $f42(x,y,z) | x * sin(y)+z $f89(x,y,z,w) | x*y^8 + z*w^8 - $f43(x,y,z) | x * sin(y)-z $f90(x,y,z,w) | x*y^9 + z*w^9 - $f44(x,y,z) | x * cos(y)+z $f91(x,y,z,w) | (x and y) ? z : w - $f45(x,y,z) | x * cos(y)-z $f92(x,y,z,w) | (x or y) ? z : w - $f46(x,y,z) | x ? y : z $f93(x,y,z,w) | (x < y) ? z : w - $f94(x,y,z,w) | (x <= y) ? z : w - $f95(x,y,z,w) | (x > y) ? z : w - $f96(x,y,z,w) | (x >= y) ? z : w - $f97(x,y,z,w) | (x == y) ? z : w - $f98(x,y,z,w) | x * sin(y) + z * cos(w) + $f00(x,y,z) | (x + y) / z $f48(x,y,z,w) | x + ((y + z) / w) + $f01(x,y,z) | (x + y) * z $f49(x,y,z,w) | x + ((y + z) * w) + $f02(x,y,z) | (x + y) - z $f50(x,y,z,w) | x + ((y - z) / w) + $f03(x,y,z) | (x + y) + z $f51(x,y,z,w) | x + ((y - z) * w) + $f04(x,y,z) | (x - y) + z $f52(x,y,z,w) | x + ((y * z) / w) + $f05(x,y,z) | (x - y) / z $f53(x,y,z,w) | x + ((y * z) * w) + $f06(x,y,z) | (x - y) * z $f54(x,y,z,w) | x + ((y / z) + w) + $f07(x,y,z) | (x * y) + z $f55(x,y,z,w) | x + ((y / z) / w) + $f08(x,y,z) | (x * y) - z $f56(x,y,z,w) | x + ((y / z) * w) + $f09(x,y,z) | (x * y) / z $f57(x,y,z,w) | x - ((y + z) / w) + $f10(x,y,z) | (x * y) * z $f58(x,y,z,w) | x - ((y + z) * w) + $f11(x,y,z) | (x / y) + z $f59(x,y,z,w) | x - ((y - z) / w) + $f12(x,y,z) | (x / y) - z $f60(x,y,z,w) | x - ((y - z) * w) + $f13(x,y,z) | (x / y) / z $f61(x,y,z,w) | x - ((y * z) / w) + $f14(x,y,z) | (x / y) * z $f62(x,y,z,w) | x - ((y * z) * w) + $f15(x,y,z) | x / (y + z) $f63(x,y,z,w) | x - ((y / z) / w) + $f16(x,y,z) | x / (y - z) $f64(x,y,z,w) | x - ((y / z) * w) + $f17(x,y,z) | x / (y * z) $f65(x,y,z,w) | ((x + y) * z) - w + $f18(x,y,z) | x / (y / z) $f66(x,y,z,w) | ((x - y) * z) - w + $f19(x,y,z) | x * (y + z) $f67(x,y,z,w) | ((x * y) * z) - w + $f20(x,y,z) | x * (y - z) $f68(x,y,z,w) | ((x / y) * z) - w + $f21(x,y,z) | x * (y * z) $f69(x,y,z,w) | ((x + y) / z) - w + $f22(x,y,z) | x * (y / z) $f70(x,y,z,w) | ((x - y) / z) - w + $f23(x,y,z) | x - (y + z) $f71(x,y,z,w) | ((x * y) / z) - w + $f24(x,y,z) | x - (y - z) $f72(x,y,z,w) | ((x / y) / z) - w + $f25(x,y,z) | x - (y / z) $f73(x,y,z,w) | (x * y) + (z * w) + $f26(x,y,z) | x - (y * z) $f74(x,y,z,w) | (x * y) - (z * w) + $f27(x,y,z) | x + (y * z) $f75(x,y,z,w) | (x * y) + (z / w) + $f28(x,y,z) | x + (y / z) $f76(x,y,z,w) | (x * y) - (z / w) + $f29(x,y,z) | x + (y + z) $f77(x,y,z,w) | (x / y) + (z / w) + $f30(x,y,z) | x + (y - z) $f78(x,y,z,w) | (x / y) - (z / w) + $f31(x,y,z) | x * y^2 + z $f79(x,y,z,w) | (x / y) - (z * w) + $f32(x,y,z) | x * y^3 + z $f80(x,y,z,w) | x / (y + (z * w)) + $f33(x,y,z) | x * y^4 + z $f81(x,y,z,w) | x / (y - (z * w)) + $f34(x,y,z) | x * y^5 + z $f82(x,y,z,w) | x * (y + (z * w)) + $f35(x,y,z) | x * y^6 + z $f83(x,y,z,w) | x * (y - (z * w)) + $f36(x,y,z) | x * y^7 + z $f84(x,y,z,w) | x*y^2 + z*w^2 + $f37(x,y,z) | x * y^8 + z $f85(x,y,z,w) | x*y^3 + z*w^3 + $f38(x,y,z) | x * y^9 + z $f86(x,y,z,w) | x*y^4 + z*w^4 + $f39(x,y,z) | x * log(y)+z $f87(x,y,z,w) | x*y^5 + z*w^5 + $f40(x,y,z) | x * log(y)-z $f88(x,y,z,w) | x*y^6 + z*w^6 + $f41(x,y,z) | x * log10(y)+z $f89(x,y,z,w) | x*y^7 + z*w^7 + $f42(x,y,z) | x * log10(y)-z $f90(x,y,z,w) | x*y^8 + z*w^8 + $f43(x,y,z) | x * sin(y)+z $f91(x,y,z,w) | x*y^9 + z*w^9 + $f44(x,y,z) | x * sin(y)-z $f92(x,y,z,w) | (x and y) ? z : w + $f45(x,y,z) | x * cos(y)+z $f93(x,y,z,w) | (x or y) ? z : w + $f46(x,y,z) | x * cos(y)-z $f94(x,y,z,w) | (x < y) ? z : w + $f47(x,y,z) | x ? y : z $f95(x,y,z,w) | (x <= y) ? z : w + $f96(x,y,z,w) | (x > y) ? z : w + $f97(x,y,z,w) | (x >= y) ? z : w + $f98(x,y,z,w) | (x == y) ? z : w + $f99(x,y,z,w) | x * sin(y) + z * cos(w) @@ -604,14 +604,26 @@ correctly optimize such expressions for a given architecture. (18) Recursive calls made from within composited functions will have a stack size bound by the stack of the executing architecture. - (19) The following are examples of compliant floating point value + (19) The entity relationship between symbol_table and an expression + is one-to-many. Hence the intended use case is to have a single + symbol table manage the variable and function requirements of + multiple expressions. An inappropriate approach would be to have + a unique symbol table for each unique expression. + + (20) The common use-case for an expression is to have it compiled + only once and then subsequently have it evaluated multiple + times. An extremely inefficient approach would be to recompile + an expression from its string form every time it requires + evaluating. + + (21) The following are examples of compliant floating point value representations: (a) 12345 (b) -123.456 (c) +123.456e+12 (d) 123.456E-12 (e) +012.045e+07 (f) .1234 (g) 123.456f (h) -321.654E+3L - (20) Expressions may contain any of the following comment styles: + (22) Expressions may contain any of the following comment styles: 1. // .... \n 2. # .... \n 3. /* .... */