jit_function.hpp
1 /*
2  * This file is part of CasADi.
3  *
4  * CasADi -- A symbolic framework for dynamic optimization.
5  * Copyright (C) 2010-2023 Joel Andersson, Joris Gillis, Moritz Diehl,
6  * KU Leuven. All rights reserved.
7  * Copyright (C) 2011-2014 Greg Horn
8  *
9  * CasADi is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 3 of the License, or (at your option) any later version.
13  *
14  * CasADi is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with CasADi; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22  *
23  */
24 
25 
26 #ifndef CASADI_JIT_FUNCTION_HPP
27 #define CASADI_JIT_FUNCTION_HPP
28 
29 #include "function_internal.hpp"
30 
32 
33 namespace casadi {
34  class CASADI_EXPORT JitFunction : public FunctionInternal {
35  public:
39  JitFunction(const std::string& name, const std::string& body,
40  const std::vector<std::string>& name_in,
41  const std::vector<std::string>& name_out,
42  const std::vector<Sparsity>& sparsity_in,
43  const std::vector<Sparsity>& sparsity_out);
44 
48  std::string class_name() const override { return "JitFunction";}
49 
53  ~JitFunction() override;
54 
56 
59  static const Options options_;
60  const Options& get_options() const override { return options_;}
62 
66  void init(const Dict& opts) override;
67 
69 
72  size_t get_n_in() override { return name_in_.size();}
73  size_t get_n_out() override { return name_out_.size();}
75 
79  bool has_codegen() const override { return true;}
80 
84  void codegen_body(CodeGenerator& g) const override;
85 
87 
90  bool has_jacobian() const override;
91  Function get_jacobian(const std::string& name,
92  const std::vector<std::string>& inames,
93  const std::vector<std::string>& onames,
94  const Dict& opts) const override;
96 
97  // Buffer the function calls
98  bool buffered_;
99 
100  // Function body
101  std::string body_;
102 
103  // Jacobian function body
104  std::string jac_body_;
105 
106  // Hessian function body
107  std::string hess_body_;
108  };
109 
110 
111 } // namespace casadi
113 
114 #endif // CASADI_JIT_FUNCTION_HPP
The casadi namespace.
GenericType::Dict Dict
C++ equivalent of Python's dict or MATLAB's struct.