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

This commit is contained in:
Arash Partow
2016-10-10 13:20:38 +11:00
parent 6b0dfbced9
commit a4fd5ceb54
2 changed files with 56 additions and 0 deletions

View File

@ -36479,6 +36479,56 @@ namespace exprtk
}
};
template <typename T>
class axpbz : public exprtk::igeneric_function<T>
{
public:
typedef typename exprtk::igeneric_function<T> igfun_t;
typedef typename igfun_t::parameter_list_t parameter_list_t;
typedef typename igfun_t::generic_type generic_type;
typedef typename generic_type::scalar_view scalar_t;
typedef typename generic_type::vector_view vector_t;
using exprtk::igeneric_function<T>::operator();
axpbz()
: exprtk::igeneric_function<T>("TVTV|TVTVTT")
/*
z <- ax + b
Overloads:
0. TVTV - a, x(vector), b, z(vector)
1. TVTVTT - a, x(vector), b, z(vector), r0, r1
*/
{}
inline T operator()(const std::size_t& ps_index, parameter_list_t parameters)
{
vector_t x(parameters[1]);
vector_t z(parameters[3]);
std::size_t r0 = 0;
std::size_t r1 = x.size() - 1;
if ((1 == ps_index) && !details::load_vector_range<T>::process(parameters,r0,r1,4,5))
return std::numeric_limits<T>::quiet_NaN();
else if (details::invalid_range(x,r0,r1))
return std::numeric_limits<T>::quiet_NaN();
else if (details::invalid_range(z,r0,r1))
return std::numeric_limits<T>::quiet_NaN();
const T a = scalar_t(parameters[0])();
const T b = scalar_t(parameters[2])();
for (std::size_t i = r0; i <= r1; ++i)
{
z[i] = a * x[i] + b;
}
return T(1);
}
};
template <typename T>
class dot : public exprtk::igeneric_function<T>
{
@ -36595,6 +36645,7 @@ namespace exprtk
axpby <T> b1_axpby;
axpyz <T> b1_axpyz;
axpbyz <T> b1_axpbyz;
axpbz <T> b1_axpbz;
dot <T> dt;
dotk <T> dtk;
@ -36636,6 +36687,8 @@ namespace exprtk
return false;
else if (!symtab.add_function("axpbyz",b1_axpbyz))
return false;
else if (!symtab.add_function("axpbz" ,b1_axpbz))
return false;
else if (!symtab.add_function("dot" ,dt))
return false;
else if (!symtab.add_function("dotk" ,dtk))