muParser: mu::Parser Class Reference

# mu::Parser Class Reference

Mathematical expressions parser. More...

`#include <muParser.h>`

Inheritance diagram for mu::Parser:

List of all members.

## Public Member Functions
| Parser ()
| Constructor.
virtual void | InitCharSets ()
| Define the character sets.
virtual void | InitFun ()
| Initialize the default functions.
virtual void | InitConst ()
| Initialize constants.
virtual void | InitOprt ()
| Initialize operators.
void | SetDecSep (char_type cDecSep)
| Set the decimal separator.
void | SetThousandsSep (char_type cThousandsSep)
| Sets the thousands operator.
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 Private Member Functions
static value_type | Sin (value_type)
static value_type | Cos (value_type)
static value_type | Tan (value_type)
static value_type | ASin (value_type)
static value_type | ACos (value_type)
static value_type | ATan (value_type)
static value_type | Sinh (value_type)
static value_type | Cosh (value_type)
static value_type | Tanh (value_type)
static value_type | ASinh (value_type)
static value_type | ACosh (value_type)
static value_type | ATanh (value_type)
static value_type | Log2 (value_type)
static value_type | Log10 (value_type)
static value_type | Ln (value_type)
static value_type | Exp (value_type)
static value_type | Abs (value_type)
static value_type | Sqrt (value_type)
static value_type | Rint (value_type)
static value_type | Sign (value_type)
static value_type | Ite (value_type, value_type, value_type)
| Conditional (if then else).
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.
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 | Max (const value_type *, int)
| Callback for determining the maximum value out of a vector.
static int | IsVal (const char_type *a_szExpr, int *a_iPos, value_type *a_fVal)
| Default value recognition callback.
## Static Private Attributes
static std::locale | s_locale = std::locale("C")
| The locale used by the parser.
## Classes
class | change_dec_sep
| A facet class used to change decimal and thousands separator. More...

## Detailed Description

Mathematical expressions parser.

Standard implementation of the mathematical expressions parser. Can be used as a reference implementation for subclassing the parser.

(C) 2004-2008 Ingo Berg
ingo_berg(at)gmx.de

Examples:

  calc.cpp.

## Constructor & Destructor Documentation

mu::Parser::Parser | ( |  | ) |

Constructor.

Call ParserBase class constructor and trigger Function, Operator and Constant initialization.

References InitCharSets(), InitConst(), InitFun(), InitOprt(), and IsVal().

## Member Function Documentation

void mu::Parser::InitCharSets | ( |  | ) | `[virtual]`

Define the character sets.

See also:
  DefineNameChars, DefineOprtChars, DefineInfixOprtChars

This function is used for initializing the default character sets that define the characters to be useable in function and variable names and operators.

Implements mu::ParserBase.

References mu::ParserBase::DefineInfixOprtChars(), mu::ParserBase::DefineNameChars(), and mu::ParserBase::DefineOprtChars().

Referenced by Parser().

void mu::Parser::InitConst | ( |  | ) | `[virtual]`

Initialize constants.

By default the parser recognizes two constants. Pi ("pi") and the eulerian number ("_e").

Implements mu::ParserBase.

References mu::ParserBase::DefineConst(), PARSER_CONST_E, and PARSER_CONST_PI.

Referenced by Parser().

void mu::Parser::InitOprt | ( |  | ) | `[virtual]`

Initialize operators.

By default only the unary minus operator is added.

Implements mu::ParserBase.

References mu::ParserBase::DefineInfixOprt(), and UnaryMinus().

Referenced by Parser().

void mu::Parser::SetDecSep | ( | char_type | cDecSep | ) |

Set the decimal separator.

Parameters:

  | cDecSep | Decimal separator as a character value.

See also:
  SetThousandsSep

By default muparser uses the "C" locale. The decimal separator of this locale is overwritten by the one provided here.

Examples:
  calc.cpp.

References s_locale.

void mu::Parser::SetThousandsSep | ( | char_type | cThousandsSep | ) |

Sets the thousands operator.

Parameters:

  | cThousandsSep | The thousands separator as a character

See also:
  SetDecSep

By default muparser uses the "C" locale. The thousands separator of this locale is overwritten by the one provided here.

Examples:
  calc.cpp.

References s_locale.

value_type mu::Parser::Diff | ( | value_type * | a_Var,
|  | value_type | a_fPos,
|  | value_type | a_fEpsilon = `0.00074` |
| ) |  |  | const

Numerically differentiate with regard to a variable.

Parameters:

  `[in]` | a_Var | Pointer to the differentiation variable.
  `[in]` | a_fPos | Position at which the differentiation should take place.
  `[in]` | a_fEpsilon | Epsilon used for the numerical differentiation.

Numerical differentiation uses a 5 point operator yielding a 4th order formula. The default value for epsilon is 0.00074 which is numerical_limits<double>::epsilon() ^ (1/5) as suggested in the muparser forum:

http://sourceforge.net/forum/forum.php?thread_id=1994611&forum_id=462843

References mu::ParserBase::Eval().

value_type mu::Parser::Ite | ( | value_type | v1,
|  | value_type | v2,
|  | value_type | v3 |
| ) |  |  | `[static, private]`

Conditional (if then else).

Parameters:

  | v1 | Condition
  | v2 | First value
  | v3 | Second value

Returns:
  v2 if v1!=0 v3 otherwise.

Referenced by InitFun().

value_type mu::Parser::UnaryMinus | ( | value_type | v | ) | `[static, private]`

Callback for the unary minus operator.

Parameters:

  | v | The value to negate

Returns:
  -v

Referenced by InitOprt().

value_type mu::Parser::Sum | ( | const value_type * | a_afArg,
|  | int | a_iArgc |
| ) |  |  | `[static, private]`

Callback for adding multiple values.

Parameters:

  `[in]` | a_afArg | Vector with the function arguments
  `[in]` | a_iArgc | The size of a_afArg

Referenced by InitFun().

value_type mu::Parser::Avg | ( | const value_type * | a_afArg,
|  | int | a_iArgc |
| ) |  |  | `[static, private]`

Callback for averaging multiple values.

Parameters:

  `[in]` | a_afArg | Vector with the function arguments
  `[in]` | a_iArgc | The size of a_afArg

Referenced by InitFun().

value_type mu::Parser::Min | ( | const value_type * | a_afArg,
|  | int | a_iArgc |
| ) |  |  | `[static, private]`

Callback for determining the minimum value out of a vector.

Parameters:

  `[in]` | a_afArg | Vector with the function arguments
  `[in]` | a_iArgc | The size of a_afArg

Referenced by InitFun().

value_type mu::Parser::Max | ( | const value_type * | a_afArg,
|  | int | a_iArgc |
| ) |  |  | `[static, private]`

Callback for determining the maximum value out of a vector.

Parameters:

  `[in]` | a_afArg | Vector with the function arguments
  `[in]` | a_iArgc | The size of a_afArg

Referenced by InitFun().

int mu::Parser::IsVal | ( | const char_type * | a_szExpr,
|  | int * | a_iPos,
|  | value_type * | a_fVal |
| ) |  |  | `[static, private]`

Default value recognition callback.

Parameters:

  `[in]` | a_szExpr | Pointer to the expression
  `[in,out]` | a_iPos | Pointer to an index storing the current position within the expression
  `[out]` | a_fVal | Pointer where the value should be stored in case one is found.

Returns:
  1 if a value was found 0 otherwise.

References s_locale.

Referenced by Parser().

The documentation for this class was generated from the following files:

- muParser.h
- muParser.cpp