27 #include "muParserTemplateMagic.h"
35 #define PARSER_CONST_PI 3.141592653589793238462643
38 #define PARSER_CONST_E 2.718281828459045235360287
75 #ifdef MUP_MATH_EXCEPTIONS
86 #ifdef MUP_MATH_EXCEPTIONS
97 #ifdef MUP_MATH_EXCEPTIONS
111 #ifdef MUP_MATH_EXCEPTIONS
152 for (
int i=0; i<a_iArgc; ++i) fRes += a_afArg[i];
167 for (
int i=0; i<a_iArgc; ++i) fRes += a_afArg[i];
183 for (
int i=0; i<a_iArgc; ++i)
184 fRes = std::min(fRes, a_afArg[i]);
201 for (
int i=0; i<a_iArgc; ++i) fRes = std::max(fRes, a_afArg[i]);
220 stream.imbue(Parser::s_locale);
222 stringstream_type::pos_type iEnd = stream.tellg();
224 if (iEnd==(stringstream_type::pos_type)-1)
227 *a_iPos += (int)iEnd;
258 DefineNameChars(
_T(
"0123456789_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") );
259 DefineOprtChars(
_T(
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+-*^/?<>=#!$%&|~'_{}") );
337 void Parser::OnDetectVar(
string_type * ,
int & ,
int & )
381 fEpsilon(a_fEpsilon);
388 *a_Var = a_fPos+2 * fEpsilon; f[0] =
Eval();
389 *a_Var = a_fPos+1 * fEpsilon; f[1] =
Eval();
390 *a_Var = a_fPos-1 * fEpsilon; f[2] =
Eval();
391 *a_Var = a_fPos-2 * fEpsilon; f[3] =
Eval();
394 fRes = (-f[0] + 8*f[1] - 8*f[2] + f[3]) / (12*fEpsilon);
void DefineInfixOprtChars(const char_type *a_szCharset)
Define the set of valid characters to be used in names of infix operators.
static value_type UnaryMinus(value_type)
Callback for the unary minus operator.
#define _T(x)
Activate this option in order to compile with OpenMP support.
void DefineNameChars(const char_type *a_szCharset)
Define the set of valid characters to be used in names of functions, variables, constants.
virtual void InitFun()
Initialize the default functions.
static value_type Sum(const value_type *, int)
Callback for adding multiple values.
#define PARSER_CONST_PI
Pi (what else?).
void AddValIdent(identfun_type a_pCallback)
Add a value parsing function.
static value_type Min(const value_type *, int)
Callback for determining the minimum value out of a vector.
Definition of the standard floating point parser.
virtual void InitCharSets()
Define the character sets.
A class singling out integer types at compile time using template meta programming.
value_type Eval() const
Calculate the result.
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.
void DefineInfixOprt(const string_type &a_strName, fun_type1 a_pOprt, int a_iPrec=prINFIX, bool a_bAllowOpt=true)
Add a user defined operator.
void DefineOprtChars(const char_type *a_szCharset)
Define the set of valid characters to be used in names of binary operators and postfix operators...
static int IsVal(const char_type *a_szExpr, int *a_iPos, value_type *a_fVal)
Default value recognition callback.
virtual void InitConst()
Initialize constants.
catch division by zero, sqrt(-1), log(0) (currently unused)
static value_type Avg(const value_type *, int)
Callback for averaging multiple values.
void DefineFun(const string_type &a_strName, T a_pFun, bool a_bAllowOpt=true)
Define a parser function without arguments.
Error class of the parser.
MUP_BASETYPE value_type
The numeric datatype used by the parser.
A template class for providing wrappers for essential math functions.
Namespace for mathematical applications.
static value_type UnaryPlus(value_type)
Callback for the unary minus operator.
string_type::value_type char_type
The character type used by the parser.
static value_type Max(const value_type *, int)
Callback for determining the maximum value out of a vector.
void DefineConst(const string_type &a_sName, value_type a_fVal)
Add a user defined constant.
value_type Diff(value_type *a_Var, value_type a_fPos, value_type a_fEpsilon=0) const
Numerically differentiate with regard to a variable.
MUP_STRING_TYPE string_type
The stringtype used by the parser.
#define PARSER_CONST_E
The Eulerian number.
virtual void InitOprt()
Initialize operators.
Mathematical expressions parser (base parser engine).