expm_impl.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 #ifndef CASADI_EXPM_IMPL_HPP
26 #define CASADI_EXPM_IMPL_HPP
27 
28 #include "expm.hpp"
29 #include "function_internal.hpp"
30 #include "plugin_interface.hpp"
31 
33 namespace casadi {
35  class CASADI_EXPORT Expm : public FunctionInternal, public PluginInterface<Expm> {
36  public:
37 
38  // Constructor
39  Expm(const std::string& name, const Sparsity& A);
40  // Destructor
41  ~Expm() override = 0;
42 
44 
47  size_t get_n_in() override { return 2;}
48  size_t get_n_out() override { return 1;}
50 
52 
55  Sparsity get_sparsity_in(casadi_int i) override;
56  Sparsity get_sparsity_out(casadi_int i) override;
58 
60 
63  static const Options options_;
64  const Options& get_options() const override { return options_;}
66 
67  // Initialize
68  void init(const Dict& opts) override;
69 
71 
74  Function get_forward(casadi_int nfwd, const std::string& name,
75  const std::vector<std::string>& inames,
76  const std::vector<std::string>& onames,
77  const Dict& opts) const override;
78  bool has_forward(casadi_int nfwd) const override { return true;}
80 
82 
85  Function get_reverse(casadi_int nadj, const std::string& name,
86  const std::vector<std::string>& inames,
87  const std::vector<std::string>& onames,
88  const Dict& opts) const override;
89  bool has_reverse(casadi_int nadj) const override { return true;}
91 
95  bool get_diff_in(casadi_int i) override { return i != 0 || !const_A_;}
96 
98  Sparsity get_jac_sparsity(casadi_int oind, casadi_int iind, bool symmetric) const override;
99  bool has_jac_sparsity(casadi_int oind, casadi_int iind) const override { return true;}
100 
101  // Creator function for internal class
102  typedef Expm* (*Creator)(const std::string& name, const Sparsity& A);
103 
104  // No static functions exposed
105  struct Exposed{ };
106 
108  static std::map<std::string, Plugin> solvers_;
109 
111  static const std::string infix_;
112 
114  static std::string shortname() { return "expm";}
115 
116  protected:
117  Sparsity A_;
118  bool const_A_;
119 
120  };
121 
122 
123 } // namespace casadi
125 #endif // CASADI_EXPM_IMPL_HPP
The casadi namespace.
GenericType::Dict Dict
C++ equivalent of Python's dict or MATLAB's struct.