C++ Mathematical Expression Library (ExprTk) http://www.partow.net/programming/exprtk/index.html

This commit is contained in:
Arash Partow
2012-05-20 08:30:38 +10:00
parent 26f17458a4
commit 1b4e3d7cc2
3 changed files with 697 additions and 199 deletions

View File

@ -649,12 +649,12 @@ static const test_t test_list[] =
test_t("equal($f09(1.1,2.2,3.3),((1.1/2.2)-3.3))",1.0),
test_t("equal($f10(1.1,2.2,3.3),((1.1/2.2)/3.3))",1.0),
test_t("equal($f11(1.1,2.2,3.3),((1.1/2.2)*3.3))",1.0),
test_t("equal($f12(1.1,2.2,3.3),(3.3/(1.1+2.2)))",1.0),
test_t("equal($f13(1.1,2.2,3.3),(3.3/(1.1-2.2)))",1.0),
test_t("equal($f14(1.1,2.2,3.3),(3.3/(1.1*2.2)))",1.0),
test_t("equal($f15(1.1,2.2,3.3),(3.3/(1.1/2.2)))",1.0),
test_t("equal($f16(1.1,2.2,3.3),(3.3-(1.1/2.2)))",1.0),
test_t("equal($f17(1.1,2.2,3.3),(3.3-(1.1/2.2)))",1.0),
test_t("equal($f12(1.1,2.2,3.3),(1.1/(2.2+3.3)))",1.0),
test_t("equal($f13(1.1,2.2,3.3),(1.1/(2.2-3.3)))",1.0),
test_t("equal($f14(1.1,2.2,3.3),(1.1/(2.2*3.3)))",1.0),
test_t("equal($f15(1.1,2.2,3.3),(1.1/(2.2/3.3)))",1.0),
test_t("equal($f16(1.1,2.2,3.3),(1.1-(2.2/3.3)))",1.0),
test_t("equal($f17(1.1,2.2,3.3),(1.1-(2.2/3.3)))",1.0),
test_t("equal($f18(1.1,2.2,3.3),(1.1*2.2^2+3.3))",1.0),
test_t("equal($f19(1.1,2.2,3.3),(1.1*2.2^3+3.3))",1.0),
test_t("equal($f20(1.1,2.2,3.3),(1.1*2.2^4+3.3))",1.0),
@ -663,39 +663,64 @@ static const test_t test_list[] =
test_t("equal($f23(1.1,2.2,3.3),(1.1*2.2^7+3.3))",1.0),
test_t("equal($f24(1.1,2.2,3.3),(1.1*2.2^8+3.3))",1.0),
test_t("equal($f25(1.1,2.2,3.3),(1.1*2.2^9+3.3))",1.0),
test_t("equal($f26(1.1,2.2,3.3,4.4),(4.4+((1.1+2.2)/3.3)))",1.0),
test_t("equal($f27(1.1,2.2,3.3,4.4),(4.4+((1.1+2.2)*3.3)))",1.0),
test_t("equal($f28(1.1,2.2,3.3,4.4),(4.4+((1.1-2.2)/3.3)))",1.0),
test_t("equal($f29(1.1,2.2,3.3,4.4),(4.4+((1.1-2.2)*3.3)))",1.0),
test_t("equal($f30(1.1,2.2,3.3,4.4),(4.4+((1.1*2.2)/3.3)))",1.0),
test_t("equal($f31(1.1,2.2,3.3,4.4),(4.4+((1.1*2.2)*3.3)))",1.0),
test_t("equal($f32(1.1,2.2,3.3,4.4),(4.4+((1.1/2.2)+3.3)))",1.0),
test_t("equal($f33(1.1,2.2,3.3,4.4),(4.4+((1.1/2.2)/3.3)))",1.0),
test_t("equal($f34(1.1,2.2,3.3,4.4),(4.4+((1.1/2.2)*3.3)))",1.0),
test_t("equal($f35(1.1,2.2,3.3,4.4),(4.4-((1.1+2.2)/3.3)))",1.0),
test_t("equal($f36(1.1,2.2,3.3,4.4),(4.4-((1.1+2.2)*3.3)))",1.0),
test_t("equal($f37(1.1,2.2,3.3,4.4),(4.4-((1.1-2.2)/3.3)))",1.0),
test_t("equal($f38(1.1,2.2,3.3,4.4),(4.4-((1.1-2.2)*3.3)))",1.0),
test_t("equal($f39(1.1,2.2,3.3,4.4),(4.4-((1.1*2.2)/3.3)))",1.0),
test_t("equal($f40(1.1,2.2,3.3,4.4),(4.4-((1.1*2.2)*3.3)))",1.0),
test_t("equal($f41(1.1,2.2,3.3,4.4),(4.4-((1.1/2.2)/3.3)))",1.0),
test_t("equal($f42(1.1,2.2,3.3,4.4),(4.4-((1.1/2.2)*3.3)))",1.0),
test_t("equal($f43(1.1,2.2,3.3,4.4),(((1.1+2.2)*3.3)-4.4))",1.0),
test_t("equal($f44(1.1,2.2,3.3,4.4),(((1.1-2.2)*3.3)-4.4))",1.0),
test_t("equal($f45(1.1,2.2,3.3,4.4),(((1.1*2.2)*3.3)-4.4))",1.0),
test_t("equal($f46(1.1,2.2,3.3,4.4),(((1.1/2.2)*3.3)-4.4))",1.0),
test_t("equal($f47(1.1,2.2,3.3,4.4),(((1.1+2.2)/3.3)-4.4))",1.0),
test_t("equal($f48(1.1,2.2,3.3,4.4),(((1.1-2.2)/3.3)-4.4))",1.0),
test_t("equal($f49(1.1,2.2,3.3,4.4),(((1.1*2.2)/3.3)-4.4))",1.0),
test_t("equal($f50(1.1,2.2,3.3,4.4),(((1.1/2.2)/3.3)-4.4))",1.0),
test_t("equal($f51(1.1,2.2,3.3,4.4),(1.1*2.2^2+3.3*4.4^2))",1.0),
test_t("equal($f52(1.1,2.2,3.3,4.4),(1.1*2.2^3+3.3*4.4^3))",1.0),
test_t("equal($f53(1.1,2.2,3.3,4.4),(1.1*2.2^4+3.3*4.4^4))",1.0),
test_t("equal($f54(1.1,2.2,3.3,4.4),(1.1*2.2^5+3.3*4.4^5))",1.0),
test_t("equal($f55(1.1,2.2,3.3,4.4),(1.1*2.2^6+3.3*4.4^6))",1.0),
test_t("equal($f56(1.1,2.2,3.3,4.4),(1.1*2.2^7+3.3*4.4^7))",1.0),
test_t("equal($f57(1.1,2.2,3.3,4.4),(1.1*2.2^8+3.3*4.4^8))",1.0),
test_t("equal($f58(1.1,2.2,3.3,4.4),(1.1*2.2^9+3.3*4.4^9))",1.0),
test_t("equal($f26(1.1,2.2,3.3),(1.1*log(2.2)+3.3))",1.0),
test_t("equal($f27(1.1,2.2,3.3),(1.1*log(2.2)-3.3))",1.0),
test_t("equal($f28(1.1,2.2,3.3),(1.1*log10(2.2)+3.3))",1.0),
test_t("equal($f29(1.1,2.2,3.3),(1.1*log10(2.2)-3.3))",1.0),
test_t("equal($f30(1.1,2.2,3.3),(1.1*sin(2.2)+3.3))",1.0),
test_t("equal($f31(1.1,2.2,3.3),(1.1*sin(2.2)-3.3))",1.0),
test_t("equal($f32(1.1,2.2,3.3),(1.1*cos(2.2)+3.3))",1.0),
test_t("equal($f33(1.1,2.2,3.3),(1.1*cos(2.2)-3.3))",1.0),
test_t("equal($f34(1.1,2.2,3.3),if((0 != 1.1),2.2,3.3))",1.0),
test_t("equal($f35(1.1,2.2,3.3,4.4),(1.1+((2.2+3.3)/4.4)))",1.0),
test_t("equal($f36(1.1,2.2,3.3,4.4),(1.1+((2.2+3.3)*4.4)))",1.0),
test_t("equal($f37(1.1,2.2,3.3,4.4),(1.1+((2.2-3.3)/4.4)))",1.0),
test_t("equal($f38(1.1,2.2,3.3,4.4),(1.1+((2.2-3.3)*4.4)))",1.0),
test_t("equal($f39(1.1,2.2,3.3,4.4),(1.1+((2.2*3.3)/4.4)))",1.0),
test_t("equal($f40(1.1,2.2,3.3,4.4),(1.1+((2.2*3.3)*4.4)))",1.0),
test_t("equal($f41(1.1,2.2,3.3,4.4),(1.1+((2.2/3.3)+4.4)))",1.0),
test_t("equal($f42(1.1,2.2,3.3,4.4),(1.1+((2.2/3.3)/4.4)))",1.0),
test_t("equal($f43(1.1,2.2,3.3,4.4),(1.1+((2.2/3.3)*4.4)))",1.0),
test_t("equal($f44(1.1,2.2,3.3,4.4),(1.1-((2.2+3.3)/4.4)))",1.0),
test_t("equal($f45(1.1,2.2,3.3,4.4),(1.1-((2.2+3.3)*4.4)))",1.0),
test_t("equal($f46(1.1,2.2,3.3,4.4),(1.1-((2.2-3.3)/4.4)))",1.0),
test_t("equal($f47(1.1,2.2,3.3,4.4),(1.1-((2.2-3.3)*4.4)))",1.0),
test_t("equal($f48(1.1,2.2,3.3,4.4),(1.1-((2.2*3.3)/4.4)))",1.0),
test_t("equal($f49(1.1,2.2,3.3,4.4),(1.1-((2.2*3.3)*4.4)))",1.0),
test_t("equal($f50(1.1,2.2,3.3,4.4),(1.1-((2.2/3.3)/4.4)))",1.0),
test_t("equal($f51(1.1,2.2,3.3,4.4),(1.1-((2.2/3.3)*4.4)))",1.0),
test_t("equal($f52(1.1,2.2,3.3,4.4),(((1.1+2.2)*3.3)-4.4))",1.0),
test_t("equal($f53(1.1,2.2,3.3,4.4),(((1.1-2.2)*3.3)-4.4))",1.0),
test_t("equal($f54(1.1,2.2,3.3,4.4),(((1.1*2.2)*3.3)-4.4))",1.0),
test_t("equal($f55(1.1,2.2,3.3,4.4),(((1.1/2.2)*3.3)-4.4))",1.0),
test_t("equal($f56(1.1,2.2,3.3,4.4),(((1.1+2.2)/3.3)-4.4))",1.0),
test_t("equal($f57(1.1,2.2,3.3,4.4),(((1.1-2.2)/3.3)-4.4))",1.0),
test_t("equal($f58(1.1,2.2,3.3,4.4),(((1.1*2.2)/3.3)-4.4))",1.0),
test_t("equal($f59(1.1,2.2,3.3,4.4),(((1.1/2.2)/3.3)-4.4))",1.0),
test_t("equal($f60(1.1,2.2,3.3,4.4),(1.1*2.2)+(3.3*4.4))",1.0),
test_t("equal($f61(1.1,2.2,3.3,4.4),(1.1*2.2)-(3.3*4.4))",1.0),
test_t("equal($f62(1.1,2.2,3.3,4.4),(1.1*2.2)+(3.3/4.4))",1.0),
test_t("equal($f63(1.1,2.2,3.3,4.4),(1.1*2.2)-(3.3/4.4))",1.0),
test_t("equal($f64(1.1,2.2,3.3,4.4),(1.1/2.2)+(3.3/4.4))",1.0),
test_t("equal($f65(1.1,2.2,3.3,4.4),(1.1/2.2)-(3.3/4.4))",1.0),
test_t("equal($f66(1.1,2.2,3.3,4.4),(1.1/2.2)-(3.3/4.4))",1.0),
test_t("equal($f67(1.1,2.2,3.3,4.4),(1.1/2.2)-(3.3*4.4))",1.0),
test_t("equal($f68(1.1,2.2,3.3,4.4),(1.1*2.2^2+3.3*4.4^2))",1.0),
test_t("equal($f69(1.1,2.2,3.3,4.4),(1.1*2.2^3+3.3*4.4^3))",1.0),
test_t("equal($f70(1.1,2.2,3.3,4.4),(1.1*2.2^4+3.3*4.4^4))",1.0),
test_t("equal($f71(1.1,2.2,3.3,4.4),(1.1*2.2^5+3.3*4.4^5))",1.0),
test_t("equal($f72(1.1,2.2,3.3,4.4),(1.1*2.2^6+3.3*4.4^6))",1.0),
test_t("equal($f73(1.1,2.2,3.3,4.4),(1.1*2.2^7+3.3*4.4^7))",1.0),
test_t("equal($f74(1.1,2.2,3.3,4.4),(1.1*2.2^8+3.3*4.4^8))",1.0),
test_t("equal($f75(1.1,2.2,3.3,4.4),(1.1*2.2^9+3.3*4.4^9))",1.0),
test_t("equal($f76(1.1,2.2,3.3,4.4),if(1.1 and 2.2,3.3,4.4))",1.0),
test_t("equal($f77(1.1,2.2,3.3,4.4),if(1.1 or 2.2,3.3,4.4))",1.0),
test_t("equal($f78(1.1,2.2,3.3,4.4),if(1.1 < 2.2,3.3,4.4))",1.0),
test_t("equal($f79(1.1,2.2,3.3,4.4),if(1.1 <= 2.2,3.3,4.4))",1.0),
test_t("equal($f80(1.1,2.2,3.3,4.4),if(1.1 > 2.2,3.3,4.4))",1.0),
test_t("equal($f81(1.1,2.2,3.3,4.4),if(1.1 >= 2.2,3.3,4.4))",1.0),
test_t("equal($f82(1.1,2.2,3.3,4.4),if(equal(1.1,2.2),3.3,4.4))",1.0),
test_t("equal($f83(1.1,2.2,3.3,4.4),1.1*sin(2.2)+3.3*cos(4.4))",1.0),
test_t("1+2+3+4+5+6+7+8+9+0",45.0),
test_t("1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 0",45.0),
test_t("1.0 + 2.0 + 3.0 + 4.0 + 5.0 + 6.0 + 7.0 + 8.0 + 9.0 + 0.0",45.0),
@ -1461,12 +1486,12 @@ inline bool run_test08()
"equal($f09(x,y,z),((x/y)-z))",
"equal($f10(x,y,z),((x/y)/z))",
"equal($f11(x,y,z),((x/y)*z))",
"equal($f12(x,y,z),(z/(x+y)))",
"equal($f13(x,y,z),(z/(x-y)))",
"equal($f14(x,y,z),(z/(x*y)))",
"equal($f15(x,y,z),(z/(x/y)))",
"equal($f16(x,y,z),(z-(x/y)))",
"equal($f17(x,y,z),(z-(x/y)))",
"equal($f12(x,y,z),(x/(y+z)))",
"equal($f13(x,y,z),(x/(y-z)))",
"equal($f14(x,y,z),(x/(y*z)))",
"equal($f15(x,y,z),(x/(y/z)))",
"equal($f16(x,y,z),(x-(y/z)))",
"equal($f17(x,y,z),(x-(y/z)))",
"equal($f18(x,y,z),(x*y^2+z))",
"equal($f19(x,y,z),(x*y^3+z))",
"equal($f20(x,y,z),(x*y^4+z))",
@ -1475,39 +1500,64 @@ inline bool run_test08()
"equal($f23(x,y,z),(x*y^7+z))",
"equal($f24(x,y,z),(x*y^8+z))",
"equal($f25(x,y,z),(x*y^9+z))",
"equal($f26(x,y,z,w),(w+((x+y)/z)))",
"equal($f27(x,y,z,w),(w+((x+y)*z)))",
"equal($f28(x,y,z,w),(w+((x-y)/z)))",
"equal($f29(x,y,z,w),(w+((x-y)*z)))",
"equal($f30(x,y,z,w),(w+((x*y)/z)))",
"equal($f31(x,y,z,w),(w+((x*y)*z)))",
"equal($f32(x,y,z,w),(w+((x/y)+z)))",
"equal($f33(x,y,z,w),(w+((x/y)/z)))",
"equal($f34(x,y,z,w),(w+((x/y)*z)))",
"equal($f35(x,y,z,w),(w-((x+y)/z)))",
"equal($f36(x,y,z,w),(w-((x+y)*z)))",
"equal($f37(x,y,z,w),(w-((x-y)/z)))",
"equal($f38(x,y,z,w),(w-((x-y)*z)))",
"equal($f39(x,y,z,w),(w-((x*y)/z)))",
"equal($f40(x,y,z,w),(w-((x*y)*z)))",
"equal($f41(x,y,z,w),(w-((x/y)/z)))",
"equal($f42(x,y,z,w),(w-((x/y)*z)))",
"equal($f43(x,y,z,w),(((x+y)*z)-w))",
"equal($f44(x,y,z,w),(((x-y)*z)-w))",
"equal($f45(x,y,z,w),(((x*y)*z)-w))",
"equal($f46(x,y,z,w),(((x/y)*z)-w))",
"equal($f47(x,y,z,w),(((x+y)/z)-w))",
"equal($f48(x,y,z,w),(((x-y)/z)-w))",
"equal($f49(x,y,z,w),(((x*y)/z)-w))",
"equal($f50(x,y,z,w),(((x/y)/z)-w))",
"equal($f51(x,y,z,w),(x*y^2+z*w^2))",
"equal($f52(x,y,z,w),(x*y^3+z*w^3))",
"equal($f53(x,y,z,w),(x*y^4+z*w^4))",
"equal($f54(x,y,z,w),(x*y^5+z*w^5))",
"equal($f55(x,y,z,w),(x*y^6+z*w^6))",
"equal($f56(x,y,z,w),(x*y^7+z*w^7))",
"equal($f57(x,y,z,w),(x*y^8+z*w^8))",
"equal($f58(x,y,z,w),(x*y^9+z*w^9))"
"equal($f26(x,y,z),(x*log(y)+z))",
"equal($f27(x,y,z),(x*log(y)-z))",
"equal($f28(x,y,z),(x*log10(y)+z))",
"equal($f29(x,y,z),(x*log10(y)-z))",
"equal($f30(x,y,z),(x*sin(y)+z))",
"equal($f31(x,y,z),(x*sin(y)-z))",
"equal($f32(x,y,z),(x*cos(y)+z))",
"equal($f33(x,y,z),(x*cos(y)-z))",
"equal($f34(x,y,z),if((0 != x),y,z))",
"equal($f35(x,y,z,w),(x+((y+z)/w)))",
"equal($f36(x,y,z,w),(x+((y+z)*w)))",
"equal($f37(x,y,z,w),(x+((y-z)/w)))",
"equal($f38(x,y,z,w),(x+((y-z)*w)))",
"equal($f39(x,y,z,w),(x+((y*z)/w)))",
"equal($f40(x,y,z,w),(x+((y*z)*w)))",
"equal($f41(x,y,z,w),(x+((y/z)+w)))",
"equal($f42(x,y,z,w),(x+((y/z)/w)))",
"equal($f43(x,y,z,w),(x+((y/z)*w)))",
"equal($f44(x,y,z,w),(x-((y+z)/w)))",
"equal($f45(x,y,z,w),(x-((y+z)*w)))",
"equal($f46(x,y,z,w),(x-((y-z)/w)))",
"equal($f47(x,y,z,w),(x-((y-z)*w)))",
"equal($f48(x,y,z,w),(x-((y*z)/w)))",
"equal($f49(x,y,z,w),(x-((y*z)*w)))",
"equal($f50(x,y,z,w),(x-((y/z)/w)))",
"equal($f51(x,y,z,w),(x-((y/z)*w)))",
"equal($f52(x,y,z,w),(((x+y)*z)-w))",
"equal($f53(x,y,z,w),(((x-y)*z)-w))",
"equal($f54(x,y,z,w),(((x*y)*z)-w))",
"equal($f55(x,y,z,w),(((x/y)*z)-w))",
"equal($f56(x,y,z,w),(((x+y)/z)-w))",
"equal($f57(x,y,z,w),(((x-y)/z)-w))",
"equal($f58(x,y,z,w),(((x*y)/z)-w))",
"equal($f59(x,y,z,w),(((x/y)/z)-w))",
"equal($f60(x,y,z,w),(x*y)+(z*w))",
"equal($f61(x,y,z,w),(x*y)-(z*w))",
"equal($f62(x,y,z,w),(x*y)+(z/w))",
"equal($f63(x,y,z,w),(x*y)-(z/w))",
"equal($f64(x,y,z,w),(x/y)+(z/w))",
"equal($f65(x,y,z,w),(x/y)-(z/w))",
"equal($f66(x,y,z,w),(x/y)-(z/w))",
"equal($f67(x,y,z,w),(x/y)-(z*w))",
"equal($f68(x,y,z,w),(x*y^2+z*w^2))",
"equal($f69(x,y,z,w),(x*y^3+z*w^3))",
"equal($f70(x,y,z,w),(x*y^4+z*w^4))",
"equal($f71(x,y,z,w),(x*y^5+z*w^5))",
"equal($f72(x,y,z,w),(x*y^6+z*w^6))",
"equal($f73(x,y,z,w),(x*y^7+z*w^7))",
"equal($f74(x,y,z,w),(x*y^8+z*w^8))",
"equal($f75(x,y,z,w),(x*y^9+z*w^9))",
"equal($f76(x,y,z,w),if(x and y,z,w))",
"equal($f77(x,y,z,w),if(x or y,z,w))",
"equal($f78(x,y,z,w),if(x < y,z,w))",
"equal($f79(x,y,z,w),if(x <= y,z,w))",
"equal($f80(x,y,z,w),if(x > y,z,w))",
"equal($f81(x,y,z,w),if(x >= y,z,w))",
"equal($f82(x,y,z,w),if(equal(x,y),z,w))",
"equal($f83(x,y,z,w),x*sin(y)+z*cos(w))"
};
static const std::size_t expr_str_size = sizeof(expr_str) / sizeof(std::string);
@ -2147,6 +2197,79 @@ inline bool run_test11()
return true;
}
template <typename T>
inline bool run_test12()
{
typedef exprtk::expression<T> expression_t;
static const std::string expression_string[] =
{
"equal(poly1(x,2.2,1.1),(2.2x^1+1.1))",
"equal(poly2(x,3.3,2.2,1.1),(3.3x^2+2.2x^1+1.1))",
"equal(poly3(x,4.4,3.3,2.2,1.1),(4.4x^3+3.3x^2+2.2x^1+1.1))",
"equal(poly4(x,5.5,4.4,3.3,2.2,1.1),(5.5x^4+4.4x^3+3.3x^2+2.2x^1+1.1))",
"equal(poly5(x,6.6,5.5,4.4,3.3,2.2,1.1),(6.6x^5+5.5x^4+4.4x^3+3.3x^2+2.2x^1+1.1))",
"equal(poly6(x,7.7,6.6,5.5,4.4,3.3,2.2,1.1),(7.7x^6+6.6x^5+5.5x^4+4.4x^3+3.3x^2+2.2x^1+1.1))",
"equal(poly7(x,8.8,7.7,6.6,5.5,4.4,3.3,2.2,1.1),(8.8x^7+7.7x^6+6.6x^5+5.5x^4+4.4x^3+3.3x^2+2.2x^1+1.1))",
"equal(poly8(x,9.9,8.8,7.7,6.6,5.5,4.4,3.3,2.2,1.1),(9.9x^8+8.8x^7+7.7x^6+6.6x^5+5.5x^4+4.4x^3+3.3x^2+2.2x^1+1.1))",
"equal(poly9(x,1.1,9.9,8.8,7.7,6.6,5.5,4.4,3.3,2.2,1.1),(1.1x^9+9.9x^8+8.8x^7+7.7x^6+6.6x^5+5.5x^4+4.4x^3+3.3x^2+2.2x^1+1.1))"
};
static const std::size_t expression_string_size = sizeof(expression_string) / sizeof(std::string);
T x = T(1.23456);
exprtk::polynomial<T, 1> poly1;
exprtk::polynomial<T, 2> poly2;
exprtk::polynomial<T, 3> poly3;
exprtk::polynomial<T, 4> poly4;
exprtk::polynomial<T, 5> poly5;
exprtk::polynomial<T, 6> poly6;
exprtk::polynomial<T, 7> poly7;
exprtk::polynomial<T, 8> poly8;
exprtk::polynomial<T, 9> poly9;
exprtk::polynomial<T,10> poly10;
exprtk::symbol_table<T> symbol_table;
symbol_table.add_variable("x",x);
symbol_table.add_function( "poly1", poly1);
symbol_table.add_function( "poly2", poly2);
symbol_table.add_function( "poly3", poly3);
symbol_table.add_function( "poly4", poly4);
symbol_table.add_function( "poly5", poly5);
symbol_table.add_function( "poly6", poly6);
symbol_table.add_function( "poly7", poly7);
symbol_table.add_function( "poly8", poly8);
symbol_table.add_function( "poly9", poly9);
symbol_table.add_function("poly10",poly10);
expression_t expression;
expression.register_symbol_table(symbol_table);
static const std::size_t rounds = 10000;
for (std::size_t i = 0; i < rounds; ++i)
{
for (std::size_t j = 0; j < expression_string_size; ++j)
{
const std::string& expr_str = expression_string[j];
{
exprtk::parser<T> parser;
if (!parser.compile(expr_str,expression))
{
std::cout << "run_test12() - Error: " << parser.error() << "\tExpression: " << expr_str << std::endl;
return false;
}
}
if (T(1.0) != expression.value())
{
std::cout << "run_test12() - Error in evaluation! Expression: " << expr_str << std::endl;
return false;
}
}
}
return true;
}
int main()
{
return (
@ -2161,7 +2284,8 @@ int main()
run_test08<double>() &&
run_test09<double>() &&
run_test10<double>() &&
run_test11<double>()
run_test11<double>() &&
run_test12<double>()
)
? 0 : 1;
}