C++ Mathematical Expression Library (ExprTk) http://www.partow.net/programming/exprtk/index.html
This commit is contained in:
parent
aad301a6eb
commit
cf1e3f25a1
33
exprtk.hpp
33
exprtk.hpp
|
@ -283,6 +283,11 @@ namespace exprtk
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline std::string to_str(std::size_t i)
|
||||||
|
{
|
||||||
|
return to_str(static_cast<int>(i));
|
||||||
|
}
|
||||||
|
|
||||||
inline bool is_hex_digit(const std::string::value_type digit)
|
inline bool is_hex_digit(const std::string::value_type digit)
|
||||||
{
|
{
|
||||||
return (('0' <= digit) && (digit <= '9')) ||
|
return (('0' <= digit) && (digit <= '9')) ||
|
||||||
|
@ -35715,9 +35720,7 @@ namespace exprtk
|
||||||
{
|
{
|
||||||
scoped_bft<func_1param> sb(*this);
|
scoped_bft<func_1param> sb(*this);
|
||||||
base_func::update(v0);
|
base_func::update(v0);
|
||||||
T result = this->value(base_func::expression);
|
return this->value(base_func::expression);
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -35731,9 +35734,7 @@ namespace exprtk
|
||||||
{
|
{
|
||||||
scoped_bft<func_2param> sb(*this);
|
scoped_bft<func_2param> sb(*this);
|
||||||
base_func::update(v0, v1);
|
base_func::update(v0, v1);
|
||||||
T result = this->value(base_func::expression);
|
return this->value(base_func::expression);
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -35747,9 +35748,7 @@ namespace exprtk
|
||||||
{
|
{
|
||||||
scoped_bft<func_3param> sb(*this);
|
scoped_bft<func_3param> sb(*this);
|
||||||
base_func::update(v0, v1, v2);
|
base_func::update(v0, v1, v2);
|
||||||
T result = this->value(base_func::expression);
|
return this->value(base_func::expression);
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -35763,9 +35762,7 @@ namespace exprtk
|
||||||
{
|
{
|
||||||
scoped_bft<func_4param> sb(*this);
|
scoped_bft<func_4param> sb(*this);
|
||||||
base_func::update(v0, v1, v2, v3);
|
base_func::update(v0, v1, v2, v3);
|
||||||
T result = this->value(base_func::expression);
|
return this->value(base_func::expression);
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -35779,9 +35776,7 @@ namespace exprtk
|
||||||
{
|
{
|
||||||
scoped_bft<func_5param> sb(*this);
|
scoped_bft<func_5param> sb(*this);
|
||||||
base_func::update(v0, v1, v2, v3, v4);
|
base_func::update(v0, v1, v2, v3, v4);
|
||||||
T result = this->value(base_func::expression);
|
return this->value(base_func::expression);
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -35795,9 +35790,7 @@ namespace exprtk
|
||||||
{
|
{
|
||||||
scoped_bft<func_6param> sb(*this);
|
scoped_bft<func_6param> sb(*this);
|
||||||
base_func::update(v0, v1, v2, v3, v4, v5);
|
base_func::update(v0, v1, v2, v3, v4, v5);
|
||||||
T result = this->value(base_func::expression);
|
return this->value(base_func::expression);
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -35844,8 +35837,6 @@ namespace exprtk
|
||||||
const Sequence<std::string,Allocator>& var_list,
|
const Sequence<std::string,Allocator>& var_list,
|
||||||
const bool override = false)
|
const bool override = false)
|
||||||
{
|
{
|
||||||
const std::size_t n = var_list.size();
|
|
||||||
|
|
||||||
const typename std::map<std::string,expression_t>::iterator itr = expr_map_.find(name);
|
const typename std::map<std::string,expression_t>::iterator itr = expr_map_.find(name);
|
||||||
|
|
||||||
if (expr_map_.end() != itr)
|
if (expr_map_.end() != itr)
|
||||||
|
@ -35863,6 +35854,8 @@ namespace exprtk
|
||||||
|
|
||||||
if (compile_expression(name,expression,var_list))
|
if (compile_expression(name,expression,var_list))
|
||||||
{
|
{
|
||||||
|
const std::size_t n = var_list.size();
|
||||||
|
|
||||||
fp_map_[n][name]->setup(expr_map_[name]);
|
fp_map_[n][name]->setup(expr_map_[name]);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -70,7 +70,7 @@ void fibonacci()
|
||||||
|
|
||||||
for (std::size_t i = 0; i < 40; ++i)
|
for (std::size_t i = 0; i < 40; ++i)
|
||||||
{
|
{
|
||||||
x = i;
|
x = static_cast<T>(i);
|
||||||
|
|
||||||
T result = expression.value();
|
T result = expression.value();
|
||||||
|
|
||||||
|
|
|
@ -130,7 +130,7 @@ void primes()
|
||||||
|
|
||||||
for (std::size_t i = 0; i < 100; ++i)
|
for (std::size_t i = 0; i < 100; ++i)
|
||||||
{
|
{
|
||||||
x = i;
|
x = static_cast<T>(i);
|
||||||
|
|
||||||
T result1 = expression1.value();
|
T result1 = expression1.value();
|
||||||
T result2 = expression2.value();
|
T result2 = expression2.value();
|
||||||
|
|
|
@ -72,7 +72,7 @@ void newton_sqrt()
|
||||||
|
|
||||||
for (std::size_t i = 0; i < 100; ++i)
|
for (std::size_t i = 0; i < 100; ++i)
|
||||||
{
|
{
|
||||||
x = i;
|
x = static_cast<T>(i);
|
||||||
|
|
||||||
T result = expression.value();
|
T result = expression.value();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue