slicot_expm.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_SLICOT_EXPM_HPP
27 #define CASADI_SLICOT_EXPM_HPP
28 
29 #include "../../core/expm_impl.hpp"
30 #include "../../core/linsol.hpp"
31 #include <casadi/interfaces/slicot/casadi_expm_slicot_export.h>
32 
42 namespace casadi {
43 
44 
45  // Forward declaration
46  class SlicotExpm;
47 
48  struct SlicotExpmMemory : public FunctionMemory {
49 
50  double *A, *H;
51  double *dwork;
52  int* iwork;
53 
55  SlicotExpmMemory() {}
56 
58  ~SlicotExpmMemory() {}
59  };
60 
72  class SlicotExpm : public Expm {
73  public:
75  explicit SlicotExpm();
76 
80  SlicotExpm(const std::string& name, const Sparsity& A);
81 
83  static Expm* creator(const std::string& name,
84  const Sparsity& A) {
85  return new SlicotExpm(name, A);
86  }
87 
89  ~SlicotExpm() override;
90 
91  // Get name of the plugin
92  const char* plugin_name() const override { return "slicot";}
93 
94  // Get name of the class
95  std::string class_name() const override { return "SlicotExpm";}
96 
98  void init(const Dict& opts) override;
99 
101  void* alloc_mem() const override { return new SlicotExpmMemory();}
102 
104  int init_mem(void* mem) const override;
105 
107  void free_mem(void *mem) const override { delete static_cast<SlicotExpmMemory*>(mem);}
108 
110  void set_work(void* mem, const double**& arg, double**& res,
111  casadi_int*& iw, double*& w) const override;
112 
114  int eval(const double** arg, double** res, casadi_int* iw, double* w, void* mem) const override;
115 
117  static const std::string meta_doc;
118 
119 
120  private:
121 
122  casadi_int n_;
123 
125  static bool has_loaded_;
126  };
127 
128 } // namespace casadi
129 
131 #endif // CASADI_SLICOT_EXPM_HPP
The casadi namespace.
GenericType::Dict Dict
C++ equivalent of Python's dict or MATLAB's struct.