MADNESS  version 0.9
muParserComplex.h
Go to the documentation of this file.
1 /*
2  __________
3  _____ __ __\______ \_____ _______ ______ ____ _______
4  / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \
5  | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/
6  |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__|
7  \/ \/ \/ \/
8  Copyright (C) 2004-2008 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 
26 #ifndef MU_PARSER_COMPLEX_H
27 #define MU_PARSER_COMPLEX_H
28 
29 #include "muParserBase.h"
30 #include <vector>
31 #include <complex>
32 
38 namespace mu
39 {
45  class ParserComplex : private ParserBase
46  {
47  public:
48 
49  typedef std::complex<float> complex_type;
50 
51  ParserComplex();
52 
53  using ParserBase::SetExpr;
54 
55  complex_type Eval();
56 
57  private:
58 
59  // !! The unary Minus is a MUST, otherwise you cant use negative signs !!
60  static value_type UnaryMinus(value_type);
61  // binary operator callbacks
62  static value_type Add(value_type v1, value_type v2);
63  static value_type Sub(value_type v1, value_type v2);
64  static value_type Mul(value_type v1, value_type v2);
65  static value_type Div(value_type v1, value_type v2);
66 
67  static value_type Sin(value_type);
68  static value_type Cos(value_type);
69  static value_type Tan(value_type);
70  static value_type Sqrt(value_type);
71 
72  static int IsVal(const char_type* a_szExpr, int *a_iPos, value_type *a_iVal);
73 
74  static complex_type UnpackToComplex(double val);
75  static double PackToDouble(const complex_type &val);
76 
77  virtual void InitOprt();
78  virtual void InitCharSets();
79  virtual void InitFun();
80  virtual void InitConst();
81  };
82 } // namespace mu
83 
84 #endif
std::complex< float > complex_type
Definition: muParserComplex.h:49
This file contains the class definition of the muparser engine.
MUP_BASETYPE value_type
The numeric datatype used by the parser.
Definition: muParserDef.h:222
void SetExpr(const string_type &a_sExpr)
Set the formula.
Definition: muParserBase.cpp:261
const muChar_t * a_szExpr
Definition: muParserDLL.h:78
Namespace for mathematical applications.
Definition: muParser.cpp:47
string_type::value_type char_type
The character type used by the parser.
Definition: muParserDef.h:240
complex_type Eval()
Mathematical expressions parser.
Definition: muParserComplex.h:45
Mathematical expressions parser (base parser engine).
Definition: muParserBase.h:63