36 #define PARSER_CONST_PI 3.141592653589793238462643
39 #define PARSER_CONST_E 2.718281828459045235360287
41 #define wxT(x) MUP_T(x)
93 return (v1) ?
v2 : v3;
117 for (
int i=0;
i<a_iArgc; ++
i) fRes += a_afArg[
i];
132 for (
int i=0;
i<a_iArgc; ++
i) fRes += a_afArg[
i];
133 return fRes/(double)a_iArgc;
148 for (
int i=0;
i<a_iArgc; ++
i) fRes =
std::min(fRes, a_afArg[
i]);
165 for (
int i=0;
i<a_iArgc; ++
i) fRes =
std::max(fRes, a_afArg[
i]);
197 stream.imbue(Parser::s_locale);
199 int iEnd =
static_cast<int>(stream.tellg());
236 DefineNameChars(
wxT(
"0123456789_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") );
237 DefineOprtChars(
wxT(
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+-*^/?<>=#!$%&|~'_") );
352 *a_Var = a_fPos+2 * a_fEpsilon;
f[0] =
Eval();
353 *a_Var = a_fPos+1 * a_fEpsilon;
f[1] =
Eval();
354 *a_Var = a_fPos-1 * a_fEpsilon;
f[2] =
Eval();
355 *a_Var = a_fPos-2 * a_fEpsilon;
f[3] =
Eval();
358 fRes = (-
f[0] + 8*
f[1] - 8*
f[2] +
f[3]) / (12*a_fEpsilon);
Mathematical expressions parser (base parser engine).
void AddValIdent(identfun_type a_pCallback)
void DefineInfixOprt(const string_type &a_strName, fun_type1 a_pOprt, int a_iPrec=prINFIX, bool a_bAllowOpt=true)
Add a user defined operator.
value_type Eval() const
Calculate the result.
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 DefineInfixOprtChars(const char_type *a_szCharset)
Define the set of valid characters to be used in names of infix operators.
void DefineNameChars(const char_type *a_szCharset)
Define the set of valid characters to be used in names of functions, variables, constants.
void DefineFun(const string_type &a_strName, fun_type0 a_pFun, bool a_bAllowOpt=true)
Error class of the parser.
A facet class used to change decimal and thousands separator.
static int IsVal(const char_type *a_szExpr, int *a_iPos, value_type *a_fVal)
Default value recognition callback.
static value_type ATanh(value_type)
static value_type Sign(value_type)
static value_type Tanh(value_type)
void SetThousandsSep(char_type cThousandsSep)
Sets the thousands operator.
static value_type Cosh(value_type)
static value_type ASin(value_type)
static value_type UnaryMinus(value_type)
Callback for the unary minus operator.
static value_type Sum(const value_type *, int)
Callback for adding multiple values.
value_type Diff(value_type *a_Var, value_type a_fPos, value_type a_fEpsilon=0.00074) const
Numerically differentiate with regard to a variable.
static value_type Avg(const value_type *, int)
Callback for averaging multiple values.
virtual void InitCharSets()
Define the character sets.
static value_type Sqrt(value_type)
void SetDecSep(char_type cDecSep)
Set the decimal separator.
static std::locale s_locale
The locale used by the parser.
static value_type Min(const value_type *, int)
Callback for determining the minimum value out of a vector.
virtual void InitOprt()
Initialize operators.
static value_type Sinh(value_type)
static value_type ACos(value_type)
static value_type Tan(value_type)
static value_type Abs(value_type)
static value_type Exp(value_type)
static value_type Rint(value_type)
static value_type ATan(value_type)
static value_type Log10(value_type)
static value_type Cos(value_type)
static value_type ASinh(value_type)
virtual void InitFun()
Initialize the default functions.
static value_type Ite(value_type, value_type, value_type)
Conditional (if then else).
virtual void InitConst()
Initialize constants.
static value_type Log2(value_type)
static value_type Max(const value_type *, int)
Callback for determining the maximum value out of a vector.
static value_type Ln(value_type)
static value_type Sin(value_type)
static value_type ACosh(value_type)
#define MUP_USE_FACET(FACET, LOCALE)
#define PARSER_CONST_E
The eulerian number.
#define PARSER_CONST_PI
Pi (what else?).
Definition of the standard floating point parser.
Namespace for mathematical applications.
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.
double value_type
The numeric datatype used by the parser.
static const char * locale