MicroModelicaCCompiler  4.5.3
ginac_interface.hpp
Go to the documentation of this file.
1 /*****************************************************************************
2 
3  This file is part of QSS Solver.
4 
5  QSS Solver is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  QSS Solver is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with QSS Solver. If not, see <http://www.gnu.org/licenses/>.
17 
18  ******************************************************************************/
19 
20 #ifndef GINAC_INTERFACE_H_
21 #define GINAC_INTERFACE_H_
22 
23 #include <ginac/ex.h>
24 #include <ginac/function.h>
25 #include <ginac/symbol.h>
26 #include <map>
27 #include <string>
28 
29 #include "ast_util.hpp"
30 #include <ast/ast_types.hpp>
32 #include "util_types.hpp"
33 
34 namespace MicroModelica {
35 namespace Util {
36 DECLARE_FUNCTION_2P(var)
37 DECLARE_FUNCTION_2P(der)
38 DECLARE_FUNCTION_2P(der2)
39 DECLARE_FUNCTION_1P(der3)
40 DECLARE_FUNCTION_1P(pre)
41 
42 class ConvertToGiNaC : public AST_Expression_Visitor<GiNaC::ex> {
43  public:
45  GiNaC::ex convert(AST_Expression, bool replaceDer = true, bool generateIndexes = false);
46  GiNaC::symbol& getSymbol(AST_Expression_ComponentReference);
47  GiNaC::symbol& getSymbol(string);
48  GiNaC::symbol& getSymbol(AST_Expression_Derivative);
49  GiNaC::symbol& getTime();
50  GiNaC::symbol& first();
51  GiNaC::symbol& next();
52  bool end();
53  map<string, GiNaC::symbol> directory();
54  string identifier(string str);
55 
56  private:
57  GiNaC::ex foldTraverseElement(AST_Expression);
58  GiNaC::ex foldTraverseElementUMinus(AST_Expression);
59  GiNaC::ex foldTraverseElement(GiNaC::ex, GiNaC::ex, BinOpType);
60  GiNaC::ex expressionVariable();
61  map<string, GiNaC::symbol> _directory;
62  bool _replaceDer;
63  bool _generateIndexes;
65 };
66 
67 class ConvertToExpression {
68  public:
69  static AST_Expression convert(GiNaC::ex);
70 };
71 
72 } // namespace Util
73 } // namespace MicroModelica
74 
75 #endif /* GINAC_INTERFACE_H_ */
MicroModelica::Util::ConvertToExpression::convert
static AST_Expression convert(GiNaC::ex)
Definition: ginac_interface.cpp:305
ast_util.hpp
MicroModelica::Util::ConvertToGiNaC::foldTraverseElement
GiNaC::ex foldTraverseElement(AST_Expression)
Definition: ginac_interface.cpp:212
MicroModelica::Util::ConvertToGiNaC::expressionVariable
GiNaC::ex expressionVariable()
Definition: ginac_interface.cpp:202
Option
Definition: util_types.hpp:32
MicroModelica::Util::ConvertToGiNaC::convert
GiNaC::ex convert(AST_Expression, bool replaceDer=true, bool generateIndexes=false)
Definition: ginac_interface.cpp:104
util_types.hpp
MicroModelica::Util::ConvertToGiNaC::_generateIndexes
bool _generateIndexes
Definition: ginac_interface.hpp:114
MicroModelica::Util::ConvertToGiNaC::getSymbol
GiNaC::symbol & getSymbol(AST_Expression_ComponentReference)
Definition: ginac_interface.cpp:167
MicroModelica::Util::ConvertToGiNaC::first
GiNaC::symbol & first()
Definition: ginac_interface.cpp:116
MicroModelica::Util::ConvertToGiNaC::directory
map< string, GiNaC::symbol > directory()
Definition: ginac_interface.cpp:122
MicroModelica::Util::ConvertToGiNaC::_exp
Option< IR::Expression > _exp
Definition: ginac_interface.hpp:115
AST_Expression_Visitor
Definition: ast_util.hpp:82
MicroModelica::Util::ConvertToGiNaC::next
GiNaC::symbol & next()
Definition: ginac_interface.cpp:118
MicroModelica
Definition: files.cpp:45
MicroModelica::Util::ConvertToGiNaC::_directory
map< string, GiNaC::symbol > _directory
Definition: ginac_interface.hpp:112
MicroModelica::Util::ConvertToGiNaC::_replaceDer
bool _replaceDer
Definition: ginac_interface.hpp:113
MicroModelica::Util::ConvertToGiNaC::end
bool end()
Definition: ginac_interface.cpp:120
built_in_functions.hpp
ast_types.hpp
BinOpType
BinOpType
Definition: ast_types.hpp:137
MicroModelica::Util::ConvertToGiNaC::ConvertToGiNaC
ConvertToGiNaC(Option< IR::Expression > exp)
Definition: ginac_interface.cpp:102
MicroModelica::Util::ConvertToGiNaC::getTime
GiNaC::symbol & getTime()
Definition: ginac_interface.cpp:193
MicroModelica::Util::ConvertToGiNaC::foldTraverseElementUMinus
GiNaC::ex foldTraverseElementUMinus(AST_Expression)
Definition: ginac_interface.cpp:200
MicroModelica::Util::ConvertToGiNaC::identifier
string identifier(string str)
Definition: ginac_interface.cpp:124