slicot_dple.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_DPLE_HPP
27 #define CASADI_SLICOT_DPLE_HPP
28 
29 #include "../../core/dple_impl.hpp"
30 #include "../../core/linsol.hpp"
31 #include <casadi/interfaces/slicot/casadi_dple_slicot_export.h>
32 
52 namespace casadi {
53 
54 
55  // Forward declaration
56  class SlicotDple;
57 
58  struct SlicotDpleMemory : public ProtoFunctionMemory {
59 
63  // Xbar Schur form multiplier data
69 
73 
74  double *VZ, *T, *Z, *X, *Xbar, *nnKa, *nnKb, *eig_real, *eig_imag, *F, *FF, *A, *B;
75  double *dwork, *wruntime;
76  casadi_int* partition, *iwruntime;
77 
79  std::vector< std::vector< Linsol> > dpse_solvers;
80 
82  SlicotDpleMemory() {}
83 
85  ~SlicotDpleMemory() {}
86  };
87 
99  class SlicotDple : public Dple {
100  public:
102  explicit SlicotDple();
103 
107  SlicotDple(const std::string& name, const SpDict & st);
108 
110  static Dple* creator(const std::string& name,
111  const SpDict& st) {
112  return new SlicotDple(name, st);
113  }
114 
116  ~SlicotDple() override;
117 
118  // Get name of the plugin
119  const char* plugin_name() const override { return "slicot";}
120 
121  // Get name of the class
122  std::string class_name() const override { return "SlicotDple";}
123 
125 
126  static const Options options_;
127  const Options& get_options() const override { return options_;}
129 
131  void init(const Dict& opts) override;
132 
134  void* alloc_mem() const override { return new SlicotDpleMemory();}
135 
137  int init_mem(void* mem) const override;
138 
140  void free_mem(void *mem) const override { delete static_cast<SlicotDpleMemory*>(mem);}
141 
143  void set_work(void* mem, const double**& arg, double**& res,
144  casadi_int*& iw, double*& w) const override;
145 
147  int eval(const double** arg, double** res, casadi_int* iw, double* w, void* mem) const override;
148 
150  static const std::string meta_doc;
151 
152  SlicotDple(const SpDict & st);
153 
154  private:
156  casadi_int n_;
157 
158  inline casadi_int partindex(const SlicotDpleMemory* m, casadi_int i, casadi_int j, casadi_int k,
159  casadi_int r, casadi_int c) const;
160 
162  double psd_num_zero_;
163 
165  std::string linear_solver_;
166 
168  Dict linear_solver_options_;
169 
171  static bool has_loaded_;
172 
173  };
174 
175 
176  void slicot_periodic_schur(casadi_int n, casadi_int K, const double* a,
177  double* t, double * z,
178  double* dwork, double* eig_real,
179  double *eig_imag, double num_zero=0);
180 } // namespace casadi
181 
183 #endif // CASADI_SLICOT_DPLE_HPP
The casadi namespace.
GenericType::Dict Dict
C++ equivalent of Python's dict or MATLAB's struct.
std::map< std::string, Sparsity > SpDict
Definition: sparsity.hpp:1490