3431
|
1 ## Copyright (C) 1996, 1997 Auburn University. All rights reserved. |
|
2 ## |
|
3 ## This file is part of Octave. |
|
4 ## |
|
5 ## Octave is free software; you can redistribute it and/or modify it |
|
6 ## under the terms of the GNU General Public License as published by |
|
7 ## the Free Software Foundation; either version 2, or (at your option) |
|
8 ## any later version. |
|
9 ## |
|
10 ## Octave is distributed in the hope that it will be useful, but |
|
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 ## General Public License for more details. |
|
14 ## |
|
15 ## You should have received a copy of the GNU General Public License |
|
16 ## along with Octave; see the file COPYING. If not, write to the Free |
|
17 ## Software Foundation, 59 Temple Place - Suite 330, Boston, MA |
|
18 ## 02111-1307, USA. |
|
19 |
|
20 ## -*- texinfo -*- |
5016
|
21 ## @deftypefn {Function File} {@var{x} =} dare (@var{a}, @var{b}, @var{q}, @var{r}, @var{opt}) |
3431
|
22 ## |
|
23 ## Return the solution, @var{x} of the discrete-time algebraic Riccati |
|
24 ## equation |
|
25 ## @iftex |
|
26 ## @tex |
|
27 ## $$ |
5016
|
28 ## A^TXA - X + A^TXB (R + B^TXB)^{-1} B^TXA + Q = 0 |
3431
|
29 ## $$ |
|
30 ## @end tex |
|
31 ## @end iftex |
|
32 ## @ifinfo |
|
33 ## @example |
4611
|
34 ## a' x a - x + a' x b (r + b' x b)^(-1) b' x a + q = 0 |
3431
|
35 ## @end example |
|
36 ## @end ifinfo |
|
37 ## @noindent |
|
38 ## |
|
39 ## @strong{Inputs} |
|
40 ## @table @var |
|
41 ## @item a |
5016
|
42 ## @var{n} by @var{n} matrix; |
3431
|
43 ## |
|
44 ## @item b |
5016
|
45 ## @var{n} by @var{m} matrix; |
3431
|
46 ## |
4611
|
47 ## @item q |
5016
|
48 ## @var{n} by @var{n} matrix, symmetric positive semidefinite, or a @var{p} by @var{n} matrix, |
|
49 ## In the latter case @math{q:=q'*q} is used; |
3431
|
50 ## |
|
51 ## @item r |
5016
|
52 ## @var{m} by @var{m}, symmetric positive definite (invertible); |
3431
|
53 ## |
|
54 ## @item opt |
|
55 ## (optional argument; default = @code{"B"}): |
|
56 ## String option passed to @code{balance} prior to ordered @var{QZ} decomposition. |
|
57 ## @end table |
|
58 ## |
5016
|
59 ## @strong{Output} |
|
60 ## @table @var |
|
61 ## @item x |
|
62 ## solution of @acronym{DARE}. |
|
63 ## @end table |
3431
|
64 ## |
|
65 ## @strong{Method} |
5016
|
66 ## Generalized eigenvalue approach (Van Dooren; @acronym{SIAM} J. |
3431
|
67 ## Sci. Stat. Comput., Vol 2) applied to the appropriate symplectic pencil. |
|
68 ## |
5016
|
69 ## See also: Ran and Rodman, @cite{Stable Hermitian Solutions of Discrete |
|
70 ## Algebraic Riccati Equations}, Mathematics of Control, Signals and |
|
71 ## Systems, Vol 5, no 2 (1992), pp 165--194. |
3431
|
72 ## |
|
73 ## @end deftypefn |
5053
|
74 ## |
3431
|
75 ## @seealso{balance and are} |
|
76 |
|
77 ## Author: A. S. Hodel <a.s.hodel@eng.auburn.edu> |
|
78 ## Created: August 1993 |
|
79 ## Adapted-By: jwe |
|
80 |
4611
|
81 function x = dare (a, b, q, r, opt) |
3431
|
82 |
|
83 if (nargin == 4 | nargin == 5) |
|
84 if (nargin == 5) |
|
85 if (opt != "N" || opt != "P" || opt != "S" || opt != "B") |
|
86 warning ("dare: opt has an invalid value -- setting to B"); |
|
87 opt = "B"; |
|
88 endif |
|
89 else |
|
90 opt = "B"; |
|
91 endif |
|
92 |
4611
|
93 |
|
94 if ((p = issquare (q)) == 0) |
|
95 q = q'*q; |
3431
|
96 endif |
|
97 |
4611
|
98 ##Checking positive definiteness |
|
99 if (isdefinite(r)<=0) |
|
100 error("dare: r not positive definite"); |
|
101 end |
|
102 if (isdefinite(q)<0) |
|
103 error("dare: q not positive semidefinite"); |
|
104 end |
|
105 |
3431
|
106 |
|
107 ## Check r dimensions. |
4611
|
108 [n,m] = size(b); |
4030
|
109 if ((m1 = issquare (r)) == 0) |
4611
|
110 error ("dare: r is not square"); |
3431
|
111 elseif (m1 != m) |
4611
|
112 error ("b,r are not conformable"); |
3431
|
113 endif |
|
114 |
4611
|
115 s1 = [a, zeros(n) ; -q, eye(n)]; |
3431
|
116 s2 = [eye(n), (b/r)*b' ; zeros(n), a']; |
|
117 [c,d,s1,s2] = balance(s1,s2,opt); |
|
118 [aa,bb,u,lam] = qz(s1,s2,"S"); |
|
119 u = d*u; |
|
120 n1 = n+1; |
|
121 n2 = 2*n; |
|
122 x = u (n1:n2, 1:n)/u(1:n, 1:n); |
|
123 else |
4611
|
124 usage ("x = dare (a, b, q, r {,opt})"); |
3431
|
125 endif |
|
126 |
|
127 endfunction |