muParser API -  1.35
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
muParser.h
Go to the documentation of this file.
1 /*
2  __________
3  _____ __ __\______ \_____ _______ ______ ____ _______
4  / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \
5  | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/
6  |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__|
7  \/ \/ \/ \/
8  Copyright (C) 2013 Ingo Berg
9 
10  Permission is hereby granted, free of charge, to any person obtaining a copy of this
11  software and associated documentation files (the "Software"), to deal in the Software
12  without restriction, including without limitation the rights to use, copy, modify,
13  merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
14  permit persons to whom the Software is furnished to do so, subject to the following conditions:
15 
16  The above copyright notice and this permission notice shall be included in all copies or
17  substantial portions of the Software.
18 
19  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
20  NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
22  DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 */
25 #ifndef MU_PARSER_H
26 #define MU_PARSER_H
27 
28 //--- Standard includes ------------------------------------------------------------------------
29 #include <vector>
30 
31 //--- Parser includes --------------------------------------------------------------------------
32 #include "muParserBase.h"
33 #include "muParserTemplateMagic.h"
34 
35 /** \file
36  \brief Definition of the standard floating point parser.
37 */
38 
39 namespace mu
40 {
41  /** \brief Mathematical expressions parser.
42 
43  Standard implementation of the mathematical expressions parser.
44  Can be used as a reference implementation for subclassing the parser.
45 
46  <small>
47  (C) 2011 Ingo Berg<br>
48  muparser(at)beltoforion.de
49  </small>
50  */
51  /* final */ class Parser : public ParserBase
52  {
53  public:
54 
55  Parser();
56 
57  virtual void InitCharSets();
58  virtual void InitFun();
59  virtual void InitConst();
60  virtual void InitOprt();
61  virtual void OnDetectVar(string_type *pExpr, int &nStart, int &nEnd);
62 
63  value_type Diff(value_type *a_Var,
64  value_type a_fPos,
65  value_type a_fEpsilon = 0) const;
66 
67  protected:
68 
69  // Trigonometric functions
70  static value_type Sin(value_type);
71  static value_type Cos(value_type);
72  static value_type Tan(value_type);
73  static value_type Tan2(value_type, value_type);
74  // arcus functions
75  static value_type ASin(value_type);
76  static value_type ACos(value_type);
77  static value_type ATan(value_type);
78  static value_type ATan2(value_type, value_type);
79 
80  // hyperbolic functions
81  static value_type Sinh(value_type);
82  static value_type Cosh(value_type);
83  static value_type Tanh(value_type);
84  // arcus hyperbolic functions
85  static value_type ASinh(value_type);
86  static value_type ACosh(value_type);
87  static value_type ATanh(value_type);
88  // Logarithm functions
89  static value_type Log2(value_type); // Logarithm Base 2
90  static value_type Log10(value_type); // Logarithm Base 10
91  static value_type Ln(value_type); // Logarithm Base e (natural logarithm)
92  // misc
93  static value_type Exp(value_type);
94  static value_type Abs(value_type);
95  static value_type Sqrt(value_type);
96  static value_type Rint(value_type);
97  static value_type Sign(value_type);
98 
99  // Prefix operators
100  // !!! Unary Minus is a MUST if you want to use negative signs !!!
103 
104  // Functions with variable number of arguments
105  static value_type Sum(const value_type*, int); // sum
106  static value_type Avg(const value_type*, int); // mean value
107  static value_type Min(const value_type*, int); // minimum
108  static value_type Max(const value_type*, int); // maximum
109 
110  static int IsVal(const char_type* a_szExpr, int *a_iPos, value_type *a_fVal);
111  };
112 } // namespace mu
113 
114 #endif
115 
static value_type UnaryMinus(value_type)
Callback for the unary minus operator.
Definition: muParser.cpp:126
virtual void InitFun()
Initialize the default functions.
Definition: muParser.cpp:265
static value_type Sum(const value_type *, int)
Callback for adding multiple values.
Definition: muParser.cpp:146
static value_type Min(const value_type *, int)
Callback for determining the minimum value out of a vector.
Definition: muParser.cpp:177
virtual void InitCharSets()
Define the character sets.
Definition: muParser.cpp:256
static int IsVal(const char_type *a_szExpr, int *a_iPos, value_type *a_fVal)
Default value recognition callback.
Definition: muParser.cpp:214
virtual void InitConst()
Initialize constants.
Definition: muParser.cpp:319
static value_type Avg(const value_type *, int)
Callback for averaging multiple values.
Definition: muParser.cpp:161
This file contains the class definition of the muparser engine.
MUP_BASETYPE value_type
The numeric datatype used by the parser.
Definition: muParserDef.h:247
Namespace for mathematical applications.
Definition: muParser.cpp:49
static value_type UnaryPlus(value_type)
Callback for the unary minus operator.
Definition: muParser.cpp:136
Parser()
Constructor.
Definition: muParser.cpp:238
string_type::value_type char_type
The character type used by the parser.
Definition: muParserDef.h:259
static value_type Max(const value_type *, int)
Callback for determining the maximum value out of a vector.
Definition: muParser.cpp:195
Mathematical expressions parser.
Definition: muParser.h:51
value_type Diff(value_type *a_Var, value_type a_fPos, value_type a_fEpsilon=0) const
Numerically differentiate with regard to a variable.
Definition: muParser.cpp:374
MUP_STRING_TYPE string_type
The stringtype used by the parser.
Definition: muParserDef.h:253
virtual void InitOprt()
Initialize operators.
Definition: muParser.cpp:330
Mathematical expressions parser (base parser engine).
Definition: muParserBase.h:62