C++ Mathematical Expression Library (ExprTk) http://www.partow.net/programming/exprtk/index.html
This commit is contained in:
parent
d068f6e14b
commit
0392927ab3
16
exprtk.hpp
16
exprtk.hpp
|
@ -5080,8 +5080,10 @@ namespace exprtk
|
|||
{
|
||||
if (1 != (arg_list.size() & 1))
|
||||
return;
|
||||
|
||||
arg_list_.resize(arg_list.size());
|
||||
delete_branch_.resize(arg_list.size());
|
||||
|
||||
for (std::size_t i = 0; i < arg_list.size(); ++i)
|
||||
{
|
||||
if (arg_list[i])
|
||||
|
@ -5114,22 +5116,20 @@ namespace exprtk
|
|||
{
|
||||
if (!arg_list_.empty())
|
||||
{
|
||||
if (1 != (arg_list_.size() & 1))
|
||||
{
|
||||
return std::numeric_limits<T>::quiet_NaN();
|
||||
}
|
||||
const std::size_t upper_bound = (arg_list_.size() - 1);
|
||||
|
||||
for (std::size_t i = 0; i < arg_list_.size() / 2; ++i)
|
||||
for (std::size_t i = 0; i < upper_bound; i += 2)
|
||||
{
|
||||
expression_ptr condition = arg_list_[(2 * i) ];
|
||||
expression_ptr consequent = arg_list_[(2 * i) + 1];
|
||||
expression_ptr condition = arg_list_[i ];
|
||||
expression_ptr consequent = arg_list_[i + 1];
|
||||
|
||||
if (is_true(condition))
|
||||
{
|
||||
return consequent->value();
|
||||
}
|
||||
}
|
||||
|
||||
return arg_list_.back()->value();
|
||||
return arg_list_[upper_bound]->value();
|
||||
}
|
||||
else
|
||||
return std::numeric_limits<T>::quiet_NaN();
|
||||
|
|
18
readme.txt
18
readme.txt
|
@ -1252,7 +1252,23 @@ into account when using Exprtk:
|
|||
8. null != null --> false
|
||||
9. null != x --> false
|
||||
|
||||
(27) Every ExprTk statement is a "value returning" expression. Unlike
|
||||
(27) The following is a list of reserved words and symbols used by
|
||||
ExprTk. Attempting to add a variable or custom function to a
|
||||
symbol table using any of the reserved words will result in
|
||||
a failure.
|
||||
|
||||
abs, acos, acosh, and, asin, asinh, atan, atan2, atanh, avg,
|
||||
break, case, ceil, clamp, continue, cosh, cos, cot, csc,
|
||||
default, deg2grad, deg2rad, else, equal, erfc, erf, exp,
|
||||
expm1, false, floor, for, frac, grad2deg, hypot, iclamp, if,
|
||||
ilike, in, inrange, in, like, log, log10, log1p, log2, logn,
|
||||
mand, max, min, mod, mor, mul, nand, ncdf, nor, not,
|
||||
not_equal, not, null, or, pow, rad2deg, repeat, root,
|
||||
roundn, round, sec, sgn, shl, shr, sinc, sinh, sin, sqrt,
|
||||
sum, swap, switch, tanh, tan, true, trunc, until, var,
|
||||
while, xnor, xor, xor
|
||||
|
||||
(28) Every ExprTk statement is a "value returning" expression. Unlike
|
||||
some languages that limit the types of expressions that can be
|
||||
performed in certain situations, in ExprTk any valid expression
|
||||
can be used in any "value consuming" context. Eg:
|
||||
|
|
Loading…
Reference in New Issue