C++ Mathematical Expression Library (ExprTk) http://www.partow.net/programming/exprtk/index.html
This commit is contained in:
parent
d7b199bdbd
commit
386e3e19d1
866
exprtk.hpp
866
exprtk.hpp
File diff suppressed because it is too large
Load Diff
|
@ -814,8 +814,8 @@ inline bool run_test01()
|
|||
test_xy<T>("2x + 3y == 2*x + 3*y" ,T(2.0),T(3.0),T(1.0)),
|
||||
test_xy<T>("2(x + y) == 2*x + 2*y" ,T(2.0),T(3.0),T(1.0)),
|
||||
test_xy<T>(" (x + y)3 == 3*x + 3*y" ,T(2.0),T(3.0),T(1.0)),
|
||||
test_xy<T>("(x+y^3/7) == (x+(y*y*y)/7)",T(2.0),T(3.0),T(1.0)),
|
||||
test_xy<T>("(1-x^3+y^2*7) == (1-(x*x*x)+(y*y)*7)",T(2.0),T(3.0),T(1.0)),
|
||||
test_xy<T>("equal(x+y^3/7,x+(y*y*y)/7)",T(2.0),T(3.0),T(1.0)),
|
||||
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)),
|
||||
test_xy<T>("equal( x^0,1)",T(12.34),T(0.0),T(1.0)),
|
||||
test_xy<T>("equal( x^1,x)",T(12.34),T(0.0),T(1.0)),
|
||||
test_xy<T>("equal( x^2,x*x)",T(12.34),T(0.0),T(1.0)),
|
||||
|
@ -1615,6 +1615,9 @@ inline bool run_test10()
|
|||
}
|
||||
};
|
||||
|
||||
static const std::size_t rounds = 1000;
|
||||
|
||||
for (std::size_t r = 0; r < rounds; ++r)
|
||||
{
|
||||
symbol_table.add_variable("x", x);
|
||||
symbol_table.add_variable("y", y);
|
||||
|
@ -1684,6 +1687,7 @@ inline bool run_test10()
|
|||
}
|
||||
}
|
||||
|
||||
for (std::size_t r = 0; r < rounds; ++r)
|
||||
{
|
||||
myfunc<T> mf;
|
||||
|
||||
|
@ -1713,6 +1717,7 @@ inline bool run_test10()
|
|||
}
|
||||
}
|
||||
|
||||
for (std::size_t r = 0; r < rounds; ++r)
|
||||
{
|
||||
symbol_table.add_stringvar("i",i);
|
||||
symbol_table.add_stringvar("j",j);
|
||||
|
@ -1782,6 +1787,7 @@ inline bool run_test10()
|
|||
}
|
||||
}
|
||||
|
||||
for (std::size_t r = 0; r < rounds; ++r)
|
||||
{
|
||||
symbol_table.add_variable("x", x);
|
||||
symbol_table.add_variable("y", y);
|
||||
|
@ -1826,6 +1832,7 @@ inline bool run_test10()
|
|||
}
|
||||
}
|
||||
|
||||
for (std::size_t r = 0; r < rounds; ++r)
|
||||
{
|
||||
symbol_table.add_variable("x", x);
|
||||
symbol_table.add_variable("y", y);
|
||||
|
@ -1870,6 +1877,7 @@ inline bool run_test10()
|
|||
}
|
||||
}
|
||||
|
||||
for (std::size_t r = 0; r < rounds; ++r)
|
||||
{
|
||||
symbol_table.add_stringvar( "i", i);
|
||||
symbol_table.add_stringvar( "j", j);
|
||||
|
@ -1914,6 +1922,7 @@ inline bool run_test10()
|
|||
}
|
||||
}
|
||||
|
||||
for (std::size_t r = 0; r < rounds; ++r)
|
||||
{
|
||||
symbol_table.add_stringvar("i", i);
|
||||
symbol_table.add_stringvar("j", j);
|
||||
|
|
18
readme.txt
18
readme.txt
|
@ -51,17 +51,18 @@ and the ability to evaluate strings within expressions.
|
|||
(1) exprtk_disable_string_capabilities
|
||||
(2) exprtk_disable_cardinal_pow_optimisation
|
||||
(3) exprtk_disable_extended_optimisations
|
||||
(4) exprtk_disable_extended_operator_optimizations
|
||||
|
||||
(1) "exprtk_disable_string_capabilities"
|
||||
If defined, the macro will disable all string processing capabilities.
|
||||
When defined, if an expression containing a string or string related
|
||||
action is encountered, a compilation error will be raised by the
|
||||
action is encountered, a compilation error will be raised by the
|
||||
parser.
|
||||
|
||||
(2) "exprtk_disable_cardinal_pow_optimisation"
|
||||
If defined, the macro will disable the special case regarding
|
||||
exponentiation of a variable to an integer constant (where the
|
||||
constant is <= 25). Defining this variable may be desirable if the
|
||||
constant is <= 60). Defining this variable may be desirable if the
|
||||
error magnitude of the results using this special case are intolerable
|
||||
with regards to the precision required. When defined, the pow function
|
||||
used for all other powers will be invoked.
|
||||
|
@ -77,6 +78,19 @@ also be noted that some of the third tier optimisations are also
|
|||
available through the predefined 'special functions', however these
|
||||
require that expressions utilize them explicitly.
|
||||
|
||||
(4) "exprtk_disable_extended_operator_optimizations"
|
||||
By default most of the mathematical operators are included as part of
|
||||
the optimisation process. However if this macro is defined, then only
|
||||
the basic mathematical operators (+,-,*,/,^) will be included.
|
||||
|
||||
(5) "exprtk_lean_and_mean"
|
||||
The default mode of ExprTk is lean and mean. This macro encompasses
|
||||
both modes [3] and [4].
|
||||
|
||||
(6) "exprtk_lean_and_mean_numeric_only"
|
||||
The mode when this macro is defined, is 'lean and mean' coupled with
|
||||
all string capabilities disabled [1].
|
||||
|
||||
|
||||
[FILES]
|
||||
(00) Makefile
|
||||
|
|
Loading…
Reference in New Issue