control_systems_torbox 0.2.1

Control systems toolbox
Documentation
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
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
<HTML>
<HEAD><TITLE>SG02CW - SLICOT Library Routine Documentation</TITLE>
</HEAD>
<BODY>

<H2><A Name="SG02CW">SG02CW</A></H2>
<H3>
Residual of continuous- or discrete-time (generalized) algebraic Riccati equations
</H3>
<A HREF ="#Specification"><B>[Specification]</B></A>
<A HREF ="#Arguments"><B>[Arguments]</B></A>
<A HREF ="#Method"><B>[Method]</B></A>
<A HREF ="#References"><B>[References]</B></A>
<A HREF ="#Comments"><B>[Comments]</B></A>
<A HREF ="#Example"><B>[Example]</B></A>

<P>
<B><FONT SIZE="+1">Purpose</FONT></B>
<PRE>
  To compute the residual matrix R for a continuous-time or
  discrete-time Riccati equation and/or the "closed-loop system"
  matrix op(C), using the formulas

     R = op(A)'*X + X*op(A) +/- X*G*X + Q,
     C = op(A) +/- G*X,
  or
     R = op(A)'*X*op(E) + op(E)'*X*op(A) +/- op(E)'*X*G*X*op(E) + Q,
     C = op(A) +/- G*X*op(E),
  or
     R = op(A)'*X*op(E) + op(E)'*X*op(A) +/- H*K + Q,
     C = op(A) +/- B*K,

  in the continuous-time case, or the formulas

     R = op(A)'*X*op(A) - X +/- op(A)'*X*G*X*op(A) + Q,
     C = op(A) +/- G*X*op(A),
  or
     R = op(A)'*X*op(A) - op(E)'*X*op(E) +/- op(A)'*X*G*X*op(A) + Q,
     C = op(A) +/- G*X*op(A),
  or
     R = op(A)'*X*op(A) - op(E)'*X*op(E) +/- H*K + Q,
     C = op(A) +/- B*K,

  in the discrete-time case, where X, G, and Q are symmetric
  matrices, A, E, H, K, B are general matrices, and op(W) is one of

     op(W) = W   or   op(W) = W'.
                                                  _-1
  Instead of the symmetric N-by-N matrix G, G = B*R  *B', the N-by-M
                  _-1
  matrix D, D = B*L  , such that G = D*D', may be given on entry.
             _       _   _  _
  The matrix R, with R = L'*L, is a weighting matrix of the optimal
                                   _            _
  problem, if DICO = 'C', or it is R = B'*X*B + Rd, if DICO = 'D',
       _                              _                         _
  with Rd a similar weighting matrix; L is a Cholesky factor of R,
     _                          _
  if R is positive definite. If R is not positive definite, which
  may happen in the discrete-time case, a UdU' or LdL' factorization
  is used to compute the matrices H and K. If M = 0, the residual
  matrix of a (generalized) Lyapunov or Stein equation is computed.
  To this end, set JOBG = 'D' and JOB = 'R' (since op(C) = A in this
  case).

  Optionally, the quadratic term in the formulas for R is specified
  as H*K, where

     H = L + op(E)'*X*B,  if DICO = 'C', or
     H = L + op(A)'*X*B,  if DICO = 'D', and
         _-1
     K = R *H',

  with L an N-by-M matrix. This is useful, e.g., for DICO = 'D',
                     _                     _
  when L &lt;&gt; 0 and/or Rd is singular, hence R might be numerically
  indefinite; it might be indefinite in the first iterations of
  Newton's algorithm. Depending on JOB, part or all of the matrices
  H, K, and B should be given in such a case.
     _
  If R is positive definite, the quadratic term can be specified
  as F*F', and the second term in the formulas for C is D*F', where
           _-1
     F = H*L .

  The matrices F and/or D should be given. This option is not useful
  when L = 0, unless F and D are available. If DICO = 'C', the
  computational problem with L &lt;&gt; 0 is equivalent with one with
  L = 0 after replacing
                _-1                 _-1
     A := A - B*R* L',   Q := Q - L*R* L'.
                       _             _
  These formulas, with R replaced by Rd, can also be used in the
                         _
  discrete-time case, if Rd is nonsingular and well-conditioned with
  respect to inversion.

  Optionally, the Frobenius norms of the product terms defining the
  denominator of the relative residual are also computed. The norms
  of Q and X are not computed.

</PRE>
<A name="Specification"><B><FONT SIZE="+1">Specification</FONT></B></A>
<PRE>
      SUBROUTINE SG02CW( DICO, JOB, JOBE, FLAG, JOBG, UPLO, TRANS, N, M,
     $                   A, LDA, E, LDE, G, LDG, X, LDX, F, LDF, K, LDK,
     $                   XE, LDXE, R, LDR, C, LDC, NORMS, DWORK, LDWORK,
     $                   INFO )
C     .. Scalar Arguments ..
      CHARACTER         DICO, FLAG, JOB, JOBE, JOBG, TRANS, UPLO
      INTEGER           INFO, LDA, LDC, LDE, LDF, LDG, LDK, LDR, LDWORK,
     $                  LDX, LDXE, M, N
C     .. Array Arguments ..
      DOUBLE PRECISION  A(LDA,*), C(LDC,*), DWORK(*), E(LDE,*),
     $                  F(LDF,*), G(LDG,*), K(LDK,*), NORMS(*),
     $                  R(LDR,*), X(LDX,*), XE(LDXE,*)

</PRE>
<A name="Arguments"><B><FONT SIZE="+1">Arguments</FONT></B></A>
<P>

<B>Mode Parameters</B>
<PRE>
  DICO    CHARACTER*1
          Specifies the type of the Riccati equation, as follows:
          = 'C':  continuous-time algebraic Riccati equation;
          = 'D':  discrete-time algebraic Riccati equation.

  JOB     CHARACTER*1
          Specifies which results must be computed, as follows:
          = 'A':  Both (all) matrices R and C must be computed;
          = 'R':  The matrix R only must be computed;
          = 'C':  The matrix C only must be computed;
          = 'N':  The matrices R and C and the norms must be
                  computed;
          = 'B':  The matrix R and the norms must be computed.

  JOBE    CHARACTER*1
          Specifies whether E is a general or an identity matrix,
          as follows:
          = 'G':  The matrix E is general and is given;
          = 'I':  The matrix E is assumed identity and is not given.

  FLAG    CHARACTER*1
          Specifies which sign is used, as follows:
          = 'P':  The plus sign is used;
          = 'M':  The minus sign is used.

  JOBG    CHARACTER*1
          Specifies how the quadratic term in the formulas for R is
          defined, as follows:
          = 'G':  The matrix G is given;
          = 'D':  The matrix D is given;
          = 'F':  The matrix F is given;
          = 'H':  The matrices H and K are given.

  UPLO    CHARACTER*1
          Specifies which triangles of the symmetric matrices X, G
          (if JOBG = 'G'), and Q (if JOB &lt;&gt; 'C') are given, as
          follows:
          = 'U':  The upper triangular part is given;
          = 'L':  The lower triangular part is given.

  TRANS   CHARACTER*1
          Specifies the form of op(W) to be used in the formulas
          above, as follows:
          = 'N':  op(W) = W;
          = 'T':  op(W) = W';
          = 'C':  op(W) = W'.

</PRE>
<B>Input/Output Parameters</B>
<PRE>
  N       (input) INTEGER
          The order of the matrices A, E, Q, X, C and R.  N &gt;= 0.

  M       (input) INTEGER
          If JOBG &lt;&gt; 'G', the number of columns of the matrices D,
          F, and/or B, H, and K'.  M &gt;= 0.
          If JOBG = 'G', the value of M is meaningless.

  A       (input) DOUBLE PRECISION array, dimension (LDA,N)
          The leading N-by-N part of this array must contain the
          matrix A.

  LDA     INTEGER
          The leading dimension of array A.  LDA &gt;= MAX(1,N).

  E       (input) DOUBLE PRECISION array, dimension (LDE,*)
          If JOBE = 'G' and (JOB &lt;&gt; 'C' or (DICO = 'C' and
          (JOBG = 'G' or JOBG = 'D'))), the leading N-by-N part of
          this array must contain the matrix E.
          If JOBE = 'I' or (JOB = 'C' and (DICO = 'D' or
          JOBG = 'F' or JOBG = 'H')), this array is not referenced.

  LDE     INTEGER
          The leading dimension of array E.
          LDE &gt;= MAX(1,N), if JOBE = 'G' and (JOB &lt;&gt; 'C' or
                             (DICO = 'C' and (JOBG = 'G' or
                                              JOBG = 'D')));
          LDE &gt;= 1,        if JOBE = 'I'  or (JOB  = 'C' and
                             (DICO = 'D'  or  JOBG = 'F' or
                                              JOBG = 'H')).

  G       (input/works.) DOUBLE PRECISION array, dimension (LDG,*)
          If JOBG = 'G', the leading N-by-N upper or lower
          triangular part (depending on UPLO) of this array must
          contain the upper or lower triangular part, respectively,
          of the matrix G. The other strictly triangular part is not
          referenced. If DICO = 'D', (JOB = 'R' or JOB = 'B'), and
          JOBG = 'G', the diagonal elements of this array are
          modified internally, but are restored on exit.
          If JOBG = 'D' or (JOBG = 'F' and JOB &lt;&gt; 'R' and
          JOB &lt;&gt; 'B'), the leading N-by-M part of this array must
          contain the matrix D, so that G = D*D'.
          If JOBG = 'H' and JOB &lt;&gt; 'R' and JOB &lt;&gt; 'B', the leading
          N-by-M part of this array must contain the matrix B.
          If (JOBG = 'F' or JOBG = 'H') and JOB = 'R' or JOB = 'B',
          this array is not referenced.

  LDG     INTEGER
          The leading dimension of array G.
          LDG &gt;= MAX(1,N), if  JOBG = 'G' or  JOBG = 'D' or
                              (JOB &lt;&gt; 'R' and JOB &lt;&gt; 'B');
          LDG &gt;= 1,        if (JOBG = 'F' or JOBG = 'H') and
                              (JOB  = 'R' or JOB  = 'B').

  X       (input/works.) DOUBLE PRECISION array, dimension (LDX,N)
          The leading N-by-N part of this array must contain the
          symmetric matrix X, and it is unchanged on exit.
          If DICO = 'D', JOBE = 'G' and JOB &lt;&gt; 'C', the diagonal
          elements of this array are modified internally, but they
          are restored on exit.
          The full matrix X should be input if DICO = 'C',
          JOBE = 'I', and the conditions in the lines of the table
          below are satisfied

             JOBG     JOB             LDWORK
          ----------------------------------------------
            'F','H'  'A','R'          LDWORK &lt;   N*N
              'G'    'A','R','N'      LDWORK &lt; 2*N*N
              'G'      'C'            LDWORK &lt;   N*N
              'G'      'B'            LDWORK &lt; 3*N*N
              'D'      'R'     (M&lt;=N, LDWORK &lt;   N*N) or
                               (M&gt; N, LDWORK &lt; 3*N*N)
              'D'      'A'     (M&lt;=N, LDWORK &lt;   N*N) or
                                     (LDWORK &gt;=  N*N and
                                      LDWORK &lt; 2*N*N)
          ----------------------------------------------

          For all the other cases, including when the optimal length
          of the workspace array DWORK is used, only the relevant
          upper or lower triangular part (depending on UPLO) of this
          array must be input, and the other strictly triangular
          part is not referenced.

  LDX     INTEGER
          The leading dimension of array X.  LDX &gt;= MAX(1,N).

  F       (input) DOUBLE PRECISION array, dimension (LDF,*)
          If JOBG = 'F', the leading N-by-M part of this array must
          contain the matrix F.
          If JOBG = 'H', the leading N-by-M part of this array must
          contain the matrix H.
          If JOBG = 'G' or JOBG = 'D', this array is not referenced.

  LDF     INTEGER
          The leading dimension of array F.
          LDF &gt;= MAX(1,N), if JOBG = 'F' or JOBG = 'H';
          LDF &gt;= 1,        if JOBG = 'G' or JOBG = 'D'.

  K       (input) DOUBLE PRECISION array, dimension (LDK,*)
          If JOBG = 'H', the leading M-by-N part of this array must
          contain the matrix K.
          If JOBG &lt;&gt; 'H', this array is not referenced.

  LDK     INTEGER
          The leading dimension of array K.
          LDK &gt;= MAX(1,M), if JOBG =  'H';
          LDK &gt;= 1,        if JOBG &lt;&gt; 'H'.

  XE      (input) DOUBLE PRECISION array, dimension (LDXE,*)
          If (JOBG = 'F' or JOBG = 'H'), JOB &lt;&gt; 'C', DICO = 'C', and
          JOBE = 'G', the leading N-by-N part of this array must
          contain the matrix product X*E, if TRANS = 'N', or E*X, if
          TRANS = 'T' or 'C'.
          If (JOBG = 'F' or JOBG = 'H'), JOB &lt;&gt; 'C', and DICO = 'D',
          the leading N-by-N part of this array must contain the
          matrix product X*A, if TRANS = 'N', or A*X, if TRANS = 'T'
          or 'C'.
          These matrix products are needed for computing F or H.
          If JOBG = 'G' or JOBG = 'D' or JOB = 'C' or (DICO = 'C'
          and JOBE = 'I') this array is not referenced.

  LDXE    INTEGER
          The leading dimension of array XE.
          LDXE &gt;= MAX(1,N), if (JOBG = 'F' or JOBG = 'H'),
                            JOB &lt;&gt; 'C', and either DICO = 'C' and
                            JOBE = 'G', or DICO = 'D';
          LDXE &gt;= 1,        if JOBG = 'G' or JOBG = 'D' or JOB = 'C'
                            or (DICO = 'C' and JOBE = 'I').

  R       (input/output) DOUBLE PRECISION array, dimension (LDR,*)
          On entry, if JOB &lt;&gt; 'C', the leading N-by-N upper or lower
          triangular part (depending on UPLO) of this array must
          contain the upper or lower triangular part, respectively,
          of the matrix Q. The other strictly triangular part is not
          referenced.
          On exit, if JOB &lt;&gt; 'C' and INFO = 0, the leading N-by-N
          upper or lower triangular part (depending on UPLO) of this
          array contains the upper or lower triangular part,
          respectively, of the matrix R.
          If JOB = 'C', this array is not referenced.

  LDR     INTEGER
          The leading dimension of array R.
          LDR &gt;= MAX(1,N), if JOB &lt;&gt; 'C';
          LDR &gt;= 1,        if JOB =  'C'.

  C       (output) DOUBLE PRECISION array, dimension (LDC,*)
          If JOB &lt;&gt; 'R' and JOB &lt;&gt; 'B' and INFO = 0, the leading
          N-by-N part of this array contains the matrix op(C).
          If JOB = 'R' or JOB = 'B', this array is not referenced.

  LDC     INTEGER
          The leading dimension of array C.
          LDC &gt;= MAX(1,N), if JOB &lt;&gt; 'R' and JOB &lt;&gt; 'B';
          LDC &gt;= 1,        if JOB =  'R' or  JOB =  'B'.

  NORMS   (output) DOUBLE PRECISION array, dimension (LN)
          If JOB = 'N' or JOB = 'B', LN = 2 or 3, if (DICO = 'C' or
          JOBE = 'I'), or (DICO = 'D' and JOBE = 'G'), respectively.
          If DICO = 'C',
          NORMS(1) contains the Frobenius norm of the matrix
          op(A)'*X (or of X*op(A)), if JOBE = 'I', or of the matrix
          op(A)'*X*op(E) (or of op(E)'*X*op(A)), if JOBE = 'G';
          NORMS(2) contains the Frobenius norm of the matrix
          product X*G*X, if JOBE = 'I', or of the matrix product
          V = op(E)'*X*G*X*op(E), if JOBE = 'G' (for JOBG = 'G' or
          JOBG = 'D'), or of V = F*F', if JOBG = 'F', or of V = H*K,
          if JOBG = 'H'.
          If DICO = 'D',
          NORMS(1) contains the Frobenius norm of the matrix
          op(A)'*X*op(A);
          NORMS(2) contains the Frobenius norm of the matrix product
          V = op(A)'*X*G*X*op(A), if JOBG = 'G' or JOBG = 'D', or of
          V = F*F', if JOBG = 'F', or of V = H*K, if JOBG = 'H';
          if JOBE = 'G', NORMS(3) contains the Frobenius norm of the
          matrix product op(E)'*X*op(E).
          If JOB &lt;&gt; 'N' and JOB &lt;&gt; 'B', this array is not
          referenced.

</PRE>
<B>Workspace</B>
<PRE>
  DWORK   DOUBLE PRECISION array, dimension (LDWORK)
          On exit, if INFO = -30, or if LDWORK = -2 on input, then
          DWORK(1) returns the minimum value of LDWORK.
          On exit, if INFO = 0, or if LDWORK = -1 on input, then
          DWORK(1) returns the optimal value of LDWORK.

  LDWORK  The length of the array DWORK. LDWORK &gt;= MAX(v,1), with v
          specified in the following table, where
             a = 1, if JOBE = 'G';
             a = 0, if JOBE = 'I'.

          DICO     JOBG     JOB             v
          -----------------------------------------------
          'C'    'F','H' 'A','C','R'         0
          'C'    'F','H'    'N'           a*N*N
          'C'    'F','H'    'B'             N*N
          'C'      'G'    'A','C'         a*N*N
          'C'      'G'    'N','R'     (a+1)*N*N
          'C'      'G'      'B'       (a+2)*N*N
          'C'      'D'      'A'       N*MIN(M,(a+1)*N)
          'C'      'D'      'C'         N*MIN(N,M)
          'C'      'D'      'N'       N*(N+MIN(a*N,M))
          'C'      'D'      'B'     N*(N+MIN(N+a*N,M))
          'C'      'D'      'R'     N*MIN(a*N+M,(a+2)*N)
          -----------------------------------------------
          'D'    'F','H'  'A','C'           0
          'D'    'F','H'  'N','R'         a*N*N
          'D'    'F','H'    'B'       (a+1)*N*N
          'D'      'G'    'A','C'           N*N
          'D'      'G'    'N','R'         2*N*N
          'D'      'G'      'B'           3*N*N
          'D'      'D'    'A','N'   N*MIN(MAX(N,M),2*N)
          'D'      'D'      'B'      N*(N+MAX(N,M))
          'D'      'D'      'C'         N*MIN(N,M)
          'D'      'D'      'R'       N*MIN(3*N,N+M)
          -----------------------------------------------

          If LDWORK = -1, an optimal workspace query is assumed; the
          routine only calculates the optimal size of the DWORK
          array, returns this value as the first entry of the DWORK
          array, and no error message is issued by XERBLA.
          This evaluation assumes that only the specified triangle
          of the array X is always used, and the other strict
          triangle is not referenced.

          If LDWORK = -2, a minimal workspace query is assumed; the
          routine only calculates the minimal size of the DWORK
          array, returns this value as the first entry of the DWORK
          array, and no error message is issued by XERBLA.
          This evaluation assumes that full matrix is given in the
          array X, when needed (see the table at the description of
          the array X).

</PRE>
<B>Error Indicator</B>
<PRE>
  INFO    INTEGER
          = 0:  successful exit;
          &lt; 0:  if INFO = -i, the i-th argument had an illegal
                value.

</PRE>
<A name="Method"><B><FONT SIZE="+1">Method</FONT></B></A>
<PRE>
  The matrix expressions are efficiently evaluated, using symmetry,
  common matrix subexpressions, and proper order of matrix
  multiplications.
  If JOB = 'N' or JOB = 'B', then:
  If DICO = 'C', the matrices op(op(A)'*X*op(E)) or op(X*op(A)), and
  V = op(E)'*X*G*X*op(E) or V = F*F' or V = H*K, are efficiently
  computed.
  If DICO = 'D', the matrices op(A)'*X*op(A), V = op(A)'*X*G*X*op(A)
  or V = F*F' or V = H*K, and op(E)'*X*op(E), if JOBE = 'G', are
  efficiently computed. The results are used to evaluate R, op(C)
  (if JOB = 'N'), and the norms.
  If JOB &lt;&gt; 'N', then the needed parts of the intermediate results
  are obtained and used to evaluate R and/or op(C).

</PRE>
<A name="Numerical Aspects"><B><FONT SIZE="+1">Numerical Aspects</FONT></B></A>
<PRE>
  The calculations are backward stable.
                                             3     2
  The algorithm requires approximately (a+b)N  + cN M operations,
  where,
    a = 0,    if JOBE = 'I',
    a = 1,    if JOBE = 'G' and (DICO = 'C' or
                                (DICO = 'D' and JOB = 'C')),
    a = 1.5,  if JOBE = 'G' and  DICO = 'D',
  and b and c are implicitly defined below. Specifically, the effort
  is approximately as follows (using ^ to denote the power operator)

  For DICO = 'C':

  JOBG                      JOB
            C                R                 A, N, B
  'G'  (a+1)*N^3    (a+2)*N^3              (a+2)*N^3,(a+2.5)*N^3
  'D'  (a+2)*N^2*M  (a+1)*N^3+1.5*N^2*M    (a+1)*N^3+2.5*N^2*M
  'F','H'    N^2*M        N^3+0.5*N^2*M        N^3+1.5*N^2*M

  For DICO = 'D':

  JOBG                      JOB
            C                R                 A, N, B
  'G'      2*N^3    (a+3  )*N^3            (a+3  )*N^3
  'D'      3*N^2*M  (a+1.5)*N^3+1.5*N^2*M  (a+1.5)*N^3+2.5*N^2*M
  'F','H'  N^2*M    (a+0.5)*N^3+0.5*N^2*M  (a+0.5)*N^3+1.5*N^2*M

  For JOBG &lt;&gt; 'G' and JOB = 'B', the effort reduces by N^2*M in
  both tables.

  An "operation" includes a multiplication, an addition, and some
  address calculations.

</PRE>

<A name="Comments"><B><FONT SIZE="+1">Further Comments</FONT></B></A>
<PRE>
  None
</PRE>

<A name="Example"><B><FONT SIZE="+1">Example</FONT></B></A>
<P>
<B>Program Text</B>
<PRE>
  None
</PRE>
<B>Program Data</B>
<PRE>
  None
</PRE>
<B>Program Results</B>
<PRE>
  None
</PRE>

<HR>
<p>
<A HREF=..\libindex.html><B>Return to index</B></A></BODY>
</HTML>