35#define PARSER_CONST_PI 3.141592653589793238462643
38#define PARSER_CONST_E 2.718281828459045235360287
225 stringstream_type::pos_type iEnd = stream.tellg();
227 if (iEnd == (stringstream_type::pos_type) - 1)
230 *a_iPos += (int)iEnd;
261 DefineNameChars(
_nrT(
"0123456789_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ[]~\\") );
262 DefineOprtChars(
_nrT(
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+-*^/?<>=#!$%&|~'_{}") );
389 fEpsilon(a_fEpsilon),
391 std::array<value_type, 5> f;
392 std::array<double, 5> factors = {-2, -1, 0, 1, 2};
400 for (
size_t i = 0; i < f.size(); i++)
402 *a_Var = a_fPos + factors[i] * fEpsilon;
408 fRes = ( f[0] - 8.0 * f[1] + 8.0 * f[3] - f[4]) / (12.0 * fEpsilon);
410 fRes = (-f[0] + 16.0 * f[1] - 30.0*f[2] + 16.0 * f[3] - f[4]) / (12.0 * fEpsilon * fEpsilon);
412 fRes = (-f[0] + 2.0 * f[1] - 2.0 * f[3] + f[4]) / (2.0 * fEpsilon * fEpsilon * fEpsilon);
Mathematical expressions parser (base parser engine).
void AddValIdent(identfun_type a_pCallback)
Add a value parsing function.
value_type Eval()
Single-value wrapper around the vectorized overload of this member function.
void DefineConst(const string_type &a_sName, value_type a_fVal)
Add a user defined constant.
void DefineOprtChars(const char_type *a_szCharset)
Define the set of valid characters to be used in names of binary operators and postfix operators.
void DefineInfixOprt(const string_type &a_strName, fun_type1 a_pOprt, int a_iPrec=prINFIX, bool optimizeAway=true)
Add a user defined operator.
ParserError exception_type
Type of the error class.
void DefineInfixOprtChars(const char_type *a_szCharset)
Define the set of valid characters to be used in names of infix operators.
static std::locale s_locale
The locale used by the parser.
void DefineFun(const string_type &a_strName, T a_pFun, bool optimizeAway=true)
Define a parser function without arguments.
void DefineNameChars(const char_type *a_szCharset)
Define the set of valid characters to be used in names of functions, variables, constants.
value_type Diff(value_type *a_Var, value_type a_fPos, value_type a_fEpsilon=0, size_t order=1)
Numerically differentiate with regard to a variable.
static value_type ATan(const value_type &)
virtual void InitFun() override
Initialize the default functions.
static value_type ATanh(const value_type &)
static value_type Abs(const value_type &)
static value_type Rint(const value_type &)
static value_type ASinh(const value_type &)
static value_type Sinh(const value_type &)
static value_type Sin(const value_type &)
virtual void InitOprt() override
Initialize operators.
static value_type Log10(const value_type &)
static value_type ACos(const value_type &)
static value_type UnaryMinus(const value_type &)
Callback for the unary minus operator.
static value_type Tan(const value_type &)
static value_type Avg(const value_type *, int)
Callback for averaging multiple values.
static value_type Min(const value_type *, int)
Callback for determining the minimum value out of a vector.
static value_type Sqrt(const value_type &)
virtual void OnDetectVar(string_type *pExpr, int &nStart, int &nEnd) override
static value_type Tanh(const value_type &)
static value_type Ln(const value_type &)
static value_type ACosh(const value_type &)
static int IsVal(const char_type *a_szExpr, int *a_iPos, value_type *a_fVal)
Default value recognition callback.
virtual void InitConst() override
Initialize constants.
static value_type ATan2(const value_type &, const value_type &)
static value_type Max(const value_type *, int)
Callback for determining the maximum value out of a vector.
static value_type Cos(const value_type &)
static value_type ASin(const value_type &)
static value_type Cosh(const value_type &)
static value_type Log2(const value_type &)
virtual void InitCharSets() override
Define the character sets.
static value_type Sign(const value_type &)
static value_type Sum(const value_type *, int)
Callback for adding multiple values.
static value_type Exp(const value_type &)
mu::value_type parser_Sum(const mu::value_type *, int)
This function summarizes all elements in the passed array.
#define PARSER_CONST_PI
Pi (what else?).
mu::value_type parser_Max(const mu::value_type *, int)
This function calculates the maximal value of all elements in the passed array.
mu::value_type parser_Min(const mu::value_type *, int)
This function calculates the minimal value of all elements in the passed array.
mu::value_type parser_Avg(const mu::value_type *, int)
This function calculates the average of all elements in passed array.
Definition of the standard floating point parser.
#define _nrT(x)
Activate this option in order to compile with OpenMP support.
std::complex< double > intPower(const std::complex< double > &, int)
This function calculates the power of a value with the specialization that the exponent is an integer...
CONSTCD11 std::chrono::duration< Rep, Period > abs(std::chrono::duration< Rep, Period > d)
Namespace for mathematical applications.
MUP_BASETYPE value_type
The numeric datatype used by the parser.
string_type::value_type char_type
The character type used by the parser.
std::basic_stringstream< char_type, std::char_traits< char_type >, std::allocator< char_type > > stringstream_type
Typedef for easily using stringstream that respect the parser stringtype.
std::string string_type
The stringtype used by the parser.
A template class for providing wrappers for essential math functions.
static T ACos(const T &v)
static T ASinh(const T &v)
static T Log10(const T &v)
static T Tanh(const T &v)
static T ATan(const T &v)
static T ATan2(const T &v1, const T &v2)
static T Sqrt(const T &v)
static T ATanh(const T &v)
static T Cosh(const T &v)
static T Log2(const T &v)
static T Sinh(const T &v)
static T ACosh(const T &v)
static T ASin(const T &v)
A class singling out integer types at compile time using template meta programming.