slicot_layer.cpp
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 #include "slicot_layer.hpp"
27 
28 #include <vector>
29 
30 // Need an 8-byte integer since libslicot0 is compiled with fdefault-integer-8
31 typedef long long int f_int;
32 
33 extern "C" {
34  int mb03vd_(f_int* n, f_int* p, f_int* ilo, f_int* ihi, double *a, f_int* lda1, f_int* lda2,
35  double* tau, f_int* ldtau, double* dwork, f_int *info);
36  int mb03vy_(f_int* n, f_int* p, f_int* ilo, f_int* ihi, double *a, f_int* lda1, f_int* lda2,
37  const double* tau, f_int* ldtau, double* dwork, f_int *ld_work, f_int *info);
38  int mb03wd_(char* job, char* compz, f_int* n, f_int* p, f_int* ilo, f_int* ihi, f_int* iloz,
39  f_int* ihiz, double *h, f_int* ldh1, f_int* ldh2, double* z, f_int* ldz1,
40  f_int* ldz2, double* wr, double *wi, double* dwork, f_int *ld_work, f_int *info);
41 
42 
43  int mb05nd_(f_int* n, double* delta, const double* a, f_int* lda,
44  double* ex, f_int* ldex, double * exint, f_int* ldexin,
45  double* tol, f_int* iwork, double * dwork, f_int* ldwork, f_int *info);
46 
47 }
48 
49 namespace casadi {
50 
51  int slicot_mb03vd(int n, int p, int ilo, int ihi, double * a, int lda1, int lda2, double * tau,
52  int ldtau, double * dwork) {
53  f_int n_ = n;
54  f_int p_ = p;
55  f_int ilo_ = ilo;
56  f_int ihi_ = ihi;
57  f_int lda1_ = lda1;
58  f_int lda2_ = lda2;
59  f_int ldtau_ = ldtau;
60  f_int ret_ = 0;
61 
62  mb03vd_(&n_, &p_, &ilo_, &ihi_, a, &lda1_, &lda2_, tau, &ldtau_, dwork, &ret_);
63  return ret_;
64  }
65 
66  int slicot_mb03vy(int n, int p, int ilo, int ihi, double * a, int lda1, int lda2,
67  const double * tau, int ldtau, double * dwork, int ldwork) {
68  f_int n_ = n;
69  f_int p_ = p;
70  f_int ilo_ = ilo;
71  f_int ihi_ = ihi;
72  f_int lda1_ = lda1;
73  f_int lda2_ = lda2;
74  f_int ldtau_ = ldtau;
75  f_int ldwork_ = ldwork;
76  f_int ret_=0;
77  mb03vy_(&n_, &p_, &ilo_, &ihi_, a, &lda1_, &lda2_, tau, &ldtau_, dwork, &ldwork_, &ret_);
78 
79  return ret_;
80 
81  }
82 
83  int slicot_mb03wd(char job, char compz, int n, int p, int ilo, int ihi, int iloz, int ihiz,
84  double *h, int ldh1, int ldh2, double* z, int ldz1, int ldz2, double* wr,
85  double *wi, double * dwork, int ldwork) {
86  f_int n_ = n;
87  f_int p_ = p;
88  f_int ilo_ = ilo;
89  f_int ihi_ = ihi;
90  f_int iloz_ = ilo;
91  f_int ihiz_ = ihi;
92  f_int ldh1_ = ldh1;
93  f_int ldh2_ = ldh2;
94  f_int ldz1_ = ldz1;
95  f_int ldz2_ = ldz2;
96  f_int ldwork_ = ldwork;
97  f_int ret_ = 0;
98  mb03wd_(&job, &compz, &n_, &p_, &ilo_, &ihi_, &iloz_, &ihiz_, h, &ldh1_, &ldh2_,
99  z, &ldz1_, &ldz2_, wr, wi, dwork, &ldwork_, &ret_);
100 
101  return ret_;
102  }
103 
104 
105  int slicot_mb05nd(int n, double delta, const double* a, int lda,
106  double* ex, int ldex, double * exint, int ldexin,
107  double tol, int* iwork, double * dwork, int ldwork) {
108  f_int n_ = n;
109  f_int lda_ = lda;
110  f_int ldex_ = ldex;
111  f_int ldexin_ = ldexin;
112  f_int* iwork_ = reinterpret_cast<f_int*>(iwork);
113  f_int ldwork_ = ldwork;
114  f_int ret_ = 0;
115  mb05nd_(&n_, &delta, a, &lda_, ex, &ldex_, exint, &ldexin_,
116  &tol, iwork_, dwork, &ldwork_, &ret_);
117 
118  return ret_;
119  }
120 
121 } // namespace casadi
The casadi namespace.
Definition: archiver.cpp:28
int slicot_mb03wd(char job, char compz, int n, int p, int ilo, int ihi, int iloz, int ihiz, double *h, int ldh1, int ldh2, double *z, int ldz1, int ldz2, double *wr, double *wi, double *dwork, int ldwork)
int slicot_mb03vy(int n, int p, int ilo, int ihi, double *a, int lda1, int lda2, const double *tau, int ldtau, double *dwork, int ldwork)
int slicot_mb03vd(int n, int p, int ilo, int ihi, double *a, int lda1, int lda2, double *tau, int ldtau, double *dwork)
int slicot_mb05nd(int n, double delta, const double *a, int lda, double *ex, int ldex, double *exint, int ldexin, double tol, int *iwork, double *dwork, int ldwork)