C++ Mathematical Expression Library (ExprTk) https://www.partow.net/programming/exprtk/index.html
This commit is contained in:
parent
dbfce796fd
commit
98006471f3
|
@ -65,17 +65,17 @@ void newton_sqrt()
|
||||||
std::string expression_str = "newton_sqrt(x)";
|
std::string expression_str = "newton_sqrt(x)";
|
||||||
|
|
||||||
expression_t expression;
|
expression_t expression;
|
||||||
|
|
||||||
expression.register_symbol_table(symbol_table);
|
expression.register_symbol_table(symbol_table);
|
||||||
|
|
||||||
parser_t parser;
|
parser_t parser;
|
||||||
|
|
||||||
parser.compile(expression_str,expression);
|
parser.compile(expression_str,expression);
|
||||||
|
|
||||||
for (std::size_t i = 0; i < 100; ++i)
|
for (std::size_t i = 0; i < 100; ++i)
|
||||||
{
|
{
|
||||||
x = i;
|
x = i;
|
||||||
|
|
||||||
T result = expression.value();
|
T result = expression.value();
|
||||||
|
|
||||||
printf("sqrt(%03d) - Result: %12.10f\tReal: %12.10f\n",
|
printf("sqrt(%03d) - Result: %12.10f\tReal: %12.10f\n",
|
||||||
static_cast<unsigned int>(i),
|
static_cast<unsigned int>(i),
|
||||||
result,
|
result,
|
||||||
|
|
Loading…
Reference in New Issue