NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
muParser.h
Go to the documentation of this file.
1/*
2 __________
3 _____ __ __\______ \_____ _______ ______ ____ _______
4 / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \
5 | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/
6 |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__|
7 \/ \/ \/ \/
8 Copyright (C) 2012 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
38namespace mu
39{
50 /* final */ class Parser : public ParserBase
51 {
52 public:
53
54 Parser();
55
56 virtual void InitCharSets() override;
57 virtual void InitFun() override;
58 virtual void InitConst() override;
59 virtual void InitOprt() override;
60 virtual void OnDetectVar(string_type *pExpr, int &nStart, int &nEnd) override;
61
63 value_type a_fPos,
64 value_type a_fEpsilon = 0,
65 size_t order = 1);
66
67 protected:
68
69 // Trigonometric functions
70 static value_type Sin(const value_type&);
71 static value_type Cos(const value_type&);
72 static value_type Tan(const value_type&);
73 static value_type Tan2(const value_type&, const value_type&);
74 // arcus functions
75 static value_type ASin(const value_type&);
76 static value_type ACos(const value_type&);
77 static value_type ATan(const value_type&);
78 static value_type ATan2(const value_type&, const value_type&);
79
80 // hyperbolic functions
81 static value_type Sinh(const value_type&);
82 static value_type Cosh(const value_type&);
83 static value_type Tanh(const value_type&);
84 // arcus hyperbolic functions
85 static value_type ASinh(const value_type&);
86 static value_type ACosh(const value_type&);
87 static value_type ATanh(const value_type&);
88 // Logarithm functions
89 static value_type Log2(const value_type&); // Logarithm Base 2
90 static value_type Log10(const value_type&); // Logarithm Base 10
91 static value_type Ln(const value_type&); // Logarithm Base e (natural logarithm)
92 // misc
93 static value_type Exp(const value_type&);
94 static value_type Abs(const value_type&);
95 static value_type Sqrt(const value_type&);
96 static value_type Rint(const value_type&);
97 static value_type Sign(const value_type&);
98
99 // Prefix operators
100 // !!! Unary Minus is a MUST if you want to use negative signs !!!
101 static value_type UnaryMinus(const value_type&);
102
103 // Functions with variable number of arguments
104 static value_type Sum(const value_type*, int); // sum
105 static value_type Avg(const value_type*, int); // mean value
106 static value_type Min(const value_type*, int); // minimum
107 static value_type Max(const value_type*, int); // maximum
108
109 static int IsVal(const char_type* a_szExpr, int *a_iPos, value_type *a_fVal);
110 };
111} // namespace mu
112
113#endif
114
115
Mathematical expressions parser (base parser engine).
Definition: muParserBase.h:69
Mathematical expressions parser.
Definition: muParser.h:51
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.
Definition: muParser.cpp:383
static value_type ATan(const value_type &)
Definition: muParser.cpp:78
virtual void InitFun() override
Initialize the default functions.
Definition: muParser.cpp:268
static value_type ATanh(const value_type &)
Definition: muParser.cpp:106
static value_type Abs(const value_type &)
Definition: muParser.cpp:132
static value_type Rint(const value_type &)
Definition: muParser.cpp:140
static value_type ASinh(const value_type &)
Definition: muParser.cpp:98
static value_type Sinh(const value_type &)
Definition: muParser.cpp:86
static value_type Tan2(const value_type &, const value_type &)
static value_type Sin(const value_type &)
Definition: muParser.cpp:58
virtual void InitOprt() override
Initialize operators.
Definition: muParser.cpp:338
static value_type Log10(const value_type &)
Definition: muParser.cpp:117
static value_type ACos(const value_type &)
Definition: muParser.cpp:74
static value_type UnaryMinus(const value_type &)
Callback for the unary minus operator.
Definition: muParser.cpp:154
static value_type Tan(const value_type &)
Definition: muParser.cpp:66
Parser()
Constructor.
Definition: muParser.cpp:241
static value_type Avg(const value_type *, int)
Callback for averaging multiple values.
Definition: muParser.cpp:176
static value_type Min(const value_type *, int)
Callback for determining the minimum value out of a vector.
Definition: muParser.cpp:189
static value_type Sqrt(const value_type &)
Definition: muParser.cpp:136
virtual void OnDetectVar(string_type *pExpr, int &nStart, int &nEnd) override
Definition: muParser.cpp:344
static value_type Tanh(const value_type &)
Definition: muParser.cpp:94
static value_type Ln(const value_type &)
Definition: muParser.cpp:121
static value_type ACosh(const value_type &)
Definition: muParser.cpp:102
static int IsVal(const char_type *a_szExpr, int *a_iPos, value_type *a_fVal)
Default value recognition callback.
Definition: muParser.cpp:217
virtual void InitConst() override
Initialize constants.
Definition: muParser.cpp:328
static value_type ATan2(const value_type &, const value_type &)
Definition: muParser.cpp:82
static value_type Max(const value_type *, int)
Callback for determining the maximum value out of a vector.
Definition: muParser.cpp:202
static value_type Cos(const value_type &)
Definition: muParser.cpp:62
static value_type ASin(const value_type &)
Definition: muParser.cpp:70
static value_type Cosh(const value_type &)
Definition: muParser.cpp:90
static value_type Log2(const value_type &)
Definition: muParser.cpp:113
virtual void InitCharSets() override
Define the character sets.
Definition: muParser.cpp:259
static value_type Sign(const value_type &)
Definition: muParser.cpp:144
static value_type Sum(const value_type *, int)
Callback for adding multiple values.
Definition: muParser.cpp:164
static value_type Exp(const value_type &)
Definition: muParser.cpp:128
This file contains the class definition of the muparser engine.
Namespace for mathematical applications.
Definition: muParser.cpp:53
MUP_BASETYPE value_type
The numeric datatype used by the parser.
Definition: muParserDef.h:251
string_type::value_type char_type
The character type used by the parser.
Definition: muParserDef.h:263
std::string string_type
The stringtype used by the parser.
Definition: muParserDef.h:257