-
Notifications
You must be signed in to change notification settings - Fork 1
/
dprex.h
419 lines (396 loc) · 11.4 KB
/
dprex.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
/* Starting from version 7.8, MATLAB BLAS expects ptrdiff_t arguments for integers */
#if MATLAB_VERSION >= 0x0708
#include <stddef.h>
#include <stdlib.h>
#endif
#include <string.h>
/* Define MX_HAS_INTERLEAVED_COMPLEX for version <9.4 */
#ifndef MX_HAS_INTERLEAVED_COMPLEX
#define MX_HAS_INTERLEAVED_COMPLEX 0
#endif
/* Starting from version 7.6, MATLAB BLAS is seperated */
#if MATLAB_VERSION >= 0x0705
#include <blas.h>
#endif
#include <lapack.h>
#include "f2c.h"
// Conversion of optimal problems with coupling weighting terms to standard problems
#define sb02mt FORTRAN_WRAPPER(sb02mt)
extern void sb02mt(
const char *jobg,
const char *jobl,
const char *fact,
const char *uplo,
const ptrdiff_t *n,
const ptrdiff_t *m,
double *a,
const ptrdiff_t *lda,
double *b,
const ptrdiff_t *ldb,
double *q,
const ptrdiff_t *ldq,
double *r,
const ptrdiff_t *ldr,
double *l,
const ptrdiff_t *ldl,
ptrdiff_t *ipiv,
ptrdiff_t *oufact,
double *g,
const ptrdiff_t *ldg,
ptrdiff_t *iwork,
double *dwork,
const ptrdiff_t *ldwork,
ptrdiff_t *info
);
// Conversion of optimal problems with coupling weighting terms to standard problems (more flexibility)
#define sb02mx FORTRAN_WRAPPER(sb02mx)
extern void sb02mx(
const char *jobg,
const char *jobl,
const char *fact,
const char *uplo,
const char *trans,
const char *flag,
const char *def,
const ptrdiff_t *n,
const ptrdiff_t *m,
double *a,
const ptrdiff_t *lda,
double *b,
const ptrdiff_t *ldb,
double *q,
const ptrdiff_t *ldq,
double *r,
const ptrdiff_t *ldr,
double *l,
const ptrdiff_t *ldl,
ptrdiff_t *ipiv,
ptrdiff_t *oufact,
double *g,
const ptrdiff_t *ldg,
ptrdiff_t *iwork,
double *dwork,
const ptrdiff_t *ldwork,
ptrdiff_t *info
);
// Constructing the 2n-by-2n Hamiltonian or symplectic matrix for linear-quadratic optimization problems
#define sb02mu FORTRAN_WRAPPER(sb02mu)
extern void sb02mu(
const char *dico,
const char *hinv,
const char *uplo,
const ptrdiff_t *n,
double *a,
const ptrdiff_t *lda,
const double *g,
const ptrdiff_t *ldg,
const double *q,
const ptrdiff_t *ldq,
double *s,
const ptrdiff_t *lds,
ptrdiff_t *iwork,
double *dwork,
const ptrdiff_t *ldwork,
ptrdiff_t *info
);
// Constructing the 2n-by-2n Hamiltonian or symplectic matrix for linear-quadratic optimization problems (improved)
#define sb02ru FORTRAN_WRAPPER(sb02ru)
extern void sb02ru(
const char *dico,
const char *hinv,
const char *trana,
const char *uplo,
const ptrdiff_t *n,
const double *a,
const ptrdiff_t *lda,
double *g,
const ptrdiff_t *ldg,
double *q,
const ptrdiff_t *ldq,
double *s,
const ptrdiff_t *lds,
ptrdiff_t *iwork,
double *dwork,
const ptrdiff_t *ldwork,
ptrdiff_t *info
);
// Constructing the extended Hamiltonian or symplectic matrix pairs for linear-quadratic optimization problems, and compressing them to 2N-by-2N matrices
#define sb02oy FORTRAN_WRAPPER(sb02oy)
extern void sb02oy(
const char *type,
const char *dico,
const char *jobb,
const char *fact,
const char *uplo,
const char *jobl,
const char *jobe,
const ptrdiff_t *n,
const ptrdiff_t *m,
const ptrdiff_t *p,
const double *a,
const ptrdiff_t *lda,
const double *b,
const ptrdiff_t *ldb,
const double *q,
const ptrdiff_t *ldq,
const double *r,
const ptrdiff_t *ldr,
const double *l,
const ptrdiff_t *ldl,
const double *e,
const ptrdiff_t *lde,
double *af,
const ptrdiff_t *ldaf,
double *bf,
const ptrdiff_t *ldbf,
double *tol,
ptrdiff_t *iwork,
double *dwork,
const ptrdiff_t *ldwork,
ptrdiff_t *info
);
// Optimal state feedback matrix for an optimal control problem
#define sb02nd FORTRAN_WRAPPER(sb02nd)
extern void sb02nd(
const char *dico,
const char *fact,
const char *uplo,
const char *jobl,
const ptrdiff_t *n,
const ptrdiff_t *m,
const ptrdiff_t *p,
const double *a,
const ptrdiff_t *lda,
double *b,
const ptrdiff_t *ldb,
double *r,
const ptrdiff_t *ldr,
ptrdiff_t *ipiv,
const double *l,
const ptrdiff_t *ldl,
double *x,
const ptrdiff_t *ldx,
const double *rnorm,
double *f,
const ptrdiff_t *ldf,
ptrdiff_t *oufact,
ptrdiff_t *iwork,
double *dwork,
const ptrdiff_t *ldwork,
ptrdiff_t *info
);
// Solution of continuous- or discrete-time algebraic Riccati equations for descriptor systems
#define sg02nd FORTRAN_WRAPPER(sg02nd)
extern void sg02nd(
const char *dico,
const char *jobe,
const char *job,
const char *jobx,
const char *fact,
const char *uplo,
const char *jobl,
const char *trans,
const ptrdiff_t *n,
const ptrdiff_t *m,
const ptrdiff_t *p,
const double *a,
const ptrdiff_t *lda,
const double *e,
const ptrdiff_t *lde,
double *b,
const ptrdiff_t *ldb,
double *r,
const ptrdiff_t *ldr,
ptrdiff_t *ipiv,
const double *l,
const ptrdiff_t *ldl,
double *x,
const ptrdiff_t *ldx,
const double *rnorm,
double *k,
const ptrdiff_t *ldk,
double *h,
const ptrdiff_t *ldh,
double *xe,
const ptrdiff_t *ldxe,
ptrdiff_t *oufact,
ptrdiff_t *iwork,
double *dwork,
const ptrdiff_t *ldwork,
ptrdiff_t *info
);
// Column interchanges in a complex matrix
#define ma02gz FORTRAN_WRAPPER(ma02gz)
extern void ma02gz(
const ptrdiff_t *n,
double *a,
const ptrdiff_t *lda,
const ptrdiff_t *k1,
const ptrdiff_t *k2,
const ptrdiff_t *ipiv,
const ptrdiff_t *incx
);
// Solution of linear equations X op(A) = B
#define mb02vd FORTRAN_WRAPPER(mb02vd)
extern void mb02vd(
const char *trans,
const ptrdiff_t *m,
const ptrdiff_t *n,
double *a,
const ptrdiff_t *lda,
ptrdiff_t *ipiv,
double *b,
const ptrdiff_t *ldb,
ptrdiff_t *info
);
// Periodic Hessenberg form of a product of p matrices using orthogonal similarity transformations
#define mb03vd FORTRAN_WRAPPER(mb03vd)
extern void mb03vd(
const ptrdiff_t *n,
const ptrdiff_t *p,
const ptrdiff_t *ilo,
const ptrdiff_t *ihi,
double *a,
const ptrdiff_t *lda1,
const ptrdiff_t *lda2,
double *tau,
const ptrdiff_t *ldtau,
double *dwork,
ptrdiff_t *info
);
// Orthogonal matrices for reduction to periodic Hessenberg form of a product of matrices
#define mb03vy FORTRAN_WRAPPER(mb03vy)
extern void mb03vy(
const ptrdiff_t *n,
const ptrdiff_t *p,
const ptrdiff_t *ilo,
const ptrdiff_t *ihi,
double *a,
const ptrdiff_t *lda1,
const ptrdiff_t *lda2,
double *tau,
const ptrdiff_t *ldtau,
double *dwork,
const ptrdiff_t *ldwork,
ptrdiff_t *info
);
// Schur decomposition and eigenvalues of a product of matrices in periodic Hessenberg form
#define mb03wd FORTRAN_WRAPPER(mb03wd)
extern void mb03wd(
const char *job,
const char *compz,
const ptrdiff_t *n,
const ptrdiff_t *p,
const ptrdiff_t *ilo,
const ptrdiff_t *ihi,
const ptrdiff_t *iloz,
const ptrdiff_t *ihiz,
double *h,
const ptrdiff_t *ldh1,
const ptrdiff_t *ldh2,
double *z,
const ptrdiff_t *ldz1,
const ptrdiff_t *ldz2,
double *wr,
double *wi,
double *dwork,
const ptrdiff_t *ldwork,
ptrdiff_t *info
);
// Computes the general product of K complex scalars trying to avoid over- and underflow.
#define zlapr1 FORTRAN_WRAPPER(zlapr1)
extern int zlapr1(
doublereal *base,
integer *k,
integer *s,
doublecomplex *a,
integer *inca,
doublecomplex *alpha,
doublecomplex *beta,
integer *scal
);
// Finding the eigenvalues of the complex generalized matrix product.
#define zpgeqz FORTRAN_WRAPPER(zpgeqz)
extern int zpgeqz(
char *job,
char *compq,
integer *k,
integer *n,
integer *ilo,
integer *ihi,
integer *s,
doublecomplex *a,
integer *lda1,
integer *lda2,
doublecomplex *alpha,
doublecomplex *beta,
integer *scal,
doublecomplex *q,
integer *ldq1,
integer *ldq2,
doublereal *dwork,
integer *ldwork,
doublecomplex *zwork,
integer *lzwork,
integer *info
);
// Swaps adjacent diagonal 1-by-1 blocks in a complex generalized matrix product.
#define zpgex2 FORTRAN_WRAPPER(zpgex2)
extern int zpgex2(
logical *wantq,
integer *k,
integer *n,
integer *j,
integer *s,
doublecomplex *a,
integer *lda1,
integer *lda2,
doublecomplex *q,
integer *ldq1,
integer *ldq2,
doublecomplex *zwork,
integer *info
);
// Swaps adjacent diagonal 1-by-1 blocks in a complex generalized matrix product.
#define zpghrd FORTRAN_WRAPPER(zpghrd)
extern int zpghrd(
char *compq,
integer *k,
integer *n,
integer *ilo,
integer *ihi,
integer *s,
doublecomplex *a,
integer *lda1,
integer *lda2,
doublecomplex *q,
integer *ldq1,
integer *ldq2,
doublereal *dwork,
integer *ldwork,
doublecomplex *zwork,
integer *lzwork,
integer *info
);
// Reorders the periodic Schur decomposition of a complex generalized matrix product.
#define zpgord FORTRAN_WRAPPER(zpgord)
extern int zpgord(
logical *wantq,
integer *k,
integer *n,
integer *s,
logical *select,
doublecomplex *a,
integer *lda1,
integer *lda2,
doublecomplex *alpha,
doublecomplex *beta,
integer *scal,
doublecomplex *q,
integer *ldq1,
integer *ldq2,
integer *m,
doublecomplex *zwork,
integer *lzwork,
integer *info
);