1
SUBROUTINE SB03OU( DISCR, LTRANS, N, M, A, LDA, B, LDB, TAU, U,
2
$ LDU, SCALE, DWORK, LDWORK, INFO )
4
C RELEASE 4.0, WGS COPYRIGHT 1999.
8
C To solve for X = op(U)'*op(U) either the stable non-negative
9
C definite continuous-time Lyapunov equation
11
C op(A)'*X + X*op(A) = -scale *op(B)'*op(B) (1)
13
C or the convergent non-negative definite discrete-time Lyapunov
16
C op(A)'*X*op(A) - X = -scale *op(B)'*op(B) (2)
18
C where op(K) = K or K' (i.e., the transpose of the matrix K), A is
19
C an N-by-N matrix in real Schur form, op(B) is an M-by-N matrix,
20
C U is an upper triangular matrix containing the Cholesky factor of
21
C the solution matrix X, X = op(U)'*op(U), and scale is an output
22
C scale factor, set less than or equal to 1 to avoid overflow in X.
23
C If matrix B has full rank then the solution matrix X will be
24
C positive-definite and hence the Cholesky factor U will be
25
C nonsingular, but if B is rank deficient then X may only be
26
C positive semi-definite and U will be singular.
28
C In the case of equation (1) the matrix A must be stable (that
29
C is, all the eigenvalues of A must have negative real parts),
30
C and for equation (2) the matrix A must be convergent (that is,
31
C all the eigenvalues of A must lie inside the unit circle).
38
C Specifies the type of Lyapunov equation to be solved as
40
C = .TRUE. : Equation (2), discrete-time case;
41
C = .FALSE.: Equation (1), continuous-time case.
44
C Specifies the form of op(K) to be used, as follows:
45
C = .FALSE.: op(K) = K (No transpose);
46
C = .TRUE. : op(K) = K**T (Transpose).
48
C Input/Output Parameters
51
C The order of the matrix A and the number of columns in
52
C matrix op(B). N >= 0.
55
C The number of rows in matrix op(B). M >= 0.
57
C A (input) DOUBLE PRECISION array, dimension (LDA,N)
58
C The leading N-by-N upper Hessenberg part of this array
59
C must contain a real Schur form matrix S. The elements
60
C below the upper Hessenberg part of the array A are not
61
C referenced. The 2-by-2 blocks must only correspond to
62
C complex conjugate pairs of eigenvalues (not to real
66
C The leading dimension of array A. LDA >= MAX(1,N).
68
C B (input/output) DOUBLE PRECISION array, dimension (LDB,N)
69
C if LTRANS = .FALSE., and dimension (LDB,M), if
71
C On entry, if LTRANS = .FALSE., the leading M-by-N part of
72
C this array must contain the coefficient matrix B of the
74
C On entry, if LTRANS = .TRUE., the leading N-by-M part of
75
C this array must contain the coefficient matrix B of the
77
C On exit, if LTRANS = .FALSE., the leading
78
C MIN(M,N)-by-MIN(M,N) upper triangular part of this array
79
C contains the upper triangular matrix R (as defined in
80
C METHOD), and the M-by-MIN(M,N) strictly lower triangular
81
C part together with the elements of the array TAU are
82
C overwritten by details of the matrix P (also defined in
83
C METHOD). When M < N, columns (M+1),...,N of the array B
84
C are overwritten by the matrix Z (see METHOD).
85
C On exit, if LTRANS = .TRUE., the leading
86
C MIN(M,N)-by-MIN(M,N) upper triangular part of
87
C B(1:N,M-N+1), if M >= N, or of B(N-M+1:N,1:M), if M < N,
88
C contains the upper triangular matrix R (as defined in
89
C METHOD), and the remaining elements (below the diagonal
90
C of R) together with the elements of the array TAU are
91
C overwritten by details of the matrix P (also defined in
92
C METHOD). When M < N, rows 1,...,(N-M) of the array B
93
C are overwritten by the matrix Z (see METHOD).
96
C The leading dimension of array B.
97
C LDB >= MAX(1,M), if LTRANS = .FALSE.,
98
C LDB >= MAX(1,N), if LTRANS = .TRUE..
100
C TAU (output) DOUBLE PRECISION array of dimension (MIN(N,M))
101
C This array contains the scalar factors of the elementary
102
C reflectors defining the matrix P.
104
C U (output) DOUBLE PRECISION array of dimension (LDU,N)
105
C The leading N-by-N upper triangular part of this array
106
C contains the Cholesky factor of the solution matrix X of
107
C the problem, X = op(U)'*op(U).
108
C The array U may be identified with B in the calling
109
C statement, if B is properly dimensioned, and the
110
C intermediate results returned in B are not needed.
113
C The leading dimension of array U. LDU >= MAX(1,N).
115
C SCALE (output) DOUBLE PRECISION
116
C The scale factor, scale, set less than or equal to 1 to
117
C prevent the solution overflowing.
121
C DWORK DOUBLE PRECISION array, dimension (LDWORK)
122
C On exit, if INFO = 0, or INFO = 1, DWORK(1) returns the
123
C optimal value of LDWORK.
126
C The length of the array DWORK. LDWORK >= MAX(1,4*N).
127
C For optimum performance LDWORK should sometimes be larger.
132
C = 0: successful exit;
133
C < 0: if INFO = -i, the i-th argument had an illegal
135
C = 1: if the Lyapunov equation is (nearly) singular
136
C (warning indicator);
137
C if DISCR = .FALSE., this means that while the matrix
138
C A has computed eigenvalues with negative real parts,
139
C it is only just stable in the sense that small
140
C perturbations in A can make one or more of the
141
C eigenvalues have a non-negative real part;
142
C if DISCR = .TRUE., this means that while the matrix
143
C A has computed eigenvalues inside the unit circle,
144
C it is nevertheless only just convergent, in the
145
C sense that small perturbations in A can make one or
146
C more of the eigenvalues lie outside the unit circle;
147
C perturbed values were used to solve the equation
148
C (but the matrix A is unchanged);
149
C = 2: if matrix A is not stable (that is, one or more of
150
C the eigenvalues of A has a non-negative real part),
151
C if DISCR = .FALSE., or not convergent (that is, one
152
C or more of the eigenvalues of A lies outside the
153
C unit circle), if DISCR = .TRUE.;
154
C = 3: if matrix A has two or more consecutive non-zero
155
C elements on the first sub-diagonal, so that there is
156
C a block larger than 2-by-2 on the diagonal;
157
C = 4: if matrix A has a 2-by-2 diagonal block with real
158
C eigenvalues instead of a complex conjugate pair.
162
C The method used by the routine is based on the Bartels and
163
C Stewart method [1], except that it finds the upper triangular
164
C matrix U directly without first finding X and without the need
165
C to form the normal matrix op(B)'*op(B) [2].
167
C If LTRANS = .FALSE., the matrix B is factored as
169
C B = P ( R ), M >= N, B = P ( R Z ), M < N,
172
C (QR factorization), where P is an M-by-M orthogonal matrix and
173
C R is a square upper triangular matrix.
175
C If LTRANS = .TRUE., the matrix B is factored as
177
C B = ( 0 R ) P, M >= N, B = ( Z ) P, M < N,
180
C (RQ factorization), where P is an M-by-M orthogonal matrix and
181
C R is a square upper triangular matrix.
183
C These factorizations are used to solve the continuous-time
184
C Lyapunov equation in the canonical form
186
C op(A)'*op(U)'*op(U) + op(U)'*op(U)*op(A) = -scale *op(F)'*op(F),
188
C or the discrete-time Lyapunov equation in the canonical form
190
C op(A)'*op(U)'*op(U)*op(A) - op(U)'*op(U) = -scale *op(F)'*op(F),
192
C where U and F are N-by-N upper triangular matrices, and
194
C F = R, if M >= N, or
196
C F = ( R ), if LTRANS = .FALSE., or
199
C F = ( 0 Z ), if LTRANS = .TRUE., if M < N.
202
C The canonical equation is solved for U.
206
C [1] Bartels, R.H. and Stewart, G.W.
207
C Solution of the matrix equation A'X + XB = C.
208
C Comm. A.C.M., 15, pp. 820-826, 1972.
210
C [2] Hammarling, S.J.
211
C Numerical solution of the stable, non-negative definite
213
C IMA J. Num. Anal., 2, pp. 303-325, 1982.
217
C The algorithm requires 0(N ) operations and is backward stable.
221
C The Lyapunov equation may be very ill-conditioned. In particular,
222
C if A is only just stable (or convergent) then the Lyapunov
223
C equation will be ill-conditioned. "Large" elements in U relative
224
C to those of A and B, or a "small" value for scale, are symptoms
225
C of ill-conditioning. A condition estimate can be computed using
226
C SLICOT Library routine SB03MD.
230
C Release 3.0: V. Sima, Katholieke Univ. Leuven, Belgium, May 1997.
231
C Supersedes Release 2.0 routine SB03CZ by Sven Hammarling,
232
C NAG Ltd, United Kingdom.
233
C Partly based on routine PLYAPS by A. Varga, University of Bochum,
238
C Dec. 1997, April 1998, May 1999.
242
C Lyapunov equation, orthogonal transformation, real Schur form.
244
C ******************************************************************
247
DOUBLE PRECISION ZERO, ONE
248
PARAMETER ( ZERO = 0.0D0, ONE = 1.0D0 )
249
C .. Scalar Arguments ..
250
LOGICAL DISCR, LTRANS
251
INTEGER INFO, LDA, LDB, LDU, LDWORK, M, N
252
DOUBLE PRECISION SCALE
253
C .. Array Arguments ..
254
DOUBLE PRECISION A(LDA,*), B(LDB,*), DWORK(*), TAU(*), U(LDU,*)
255
C .. Local Scalars ..
256
INTEGER I, J, K, L, MN, WRKOPT
257
C .. External Subroutines ..
258
EXTERNAL DCOPY, DGEQRF, DGERQF, DLACPY, DLASET, SB03OT,
260
C .. Intrinsic Functions ..
262
C .. Executable Statements ..
266
C Test the input scalar arguments.
270
ELSE IF( M.LT.0 ) THEN
272
ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
274
ELSE IF( ( LDB.LT.MAX( 1, M ) .AND. .NOT.LTRANS ) .OR.
275
$ ( LDB.LT.MAX( 1, N ) .AND. LTRANS ) ) THEN
277
ELSE IF( LDU.LT.MAX( 1, N ) ) THEN
279
ELSE IF( LDWORK.LT.MAX( 1, 4*N ) ) THEN
283
IF ( INFO.NE.0 ) THEN
287
CALL XERBLA( 'SB03OU', -INFO )
291
C Quick return if possible.
300
C (Note: Comments in the code beginning "Workspace:" describe the
301
C minimal amount of real workspace needed at that point in the
302
C code, as well as the preferred amount for good performance.
303
C NB refers to the optimal block size for the immediately
304
C following subroutine, as returned by ILAENV.)
310
C Perform the RQ factorization of B.
314
CALL DGERQF( N, M, B, LDB, TAU, DWORK, LDWORK, INFO )
316
C The triangular matrix F is constructed in the array U so that
317
C U can share the same memory as B.
320
CALL DLACPY( 'Upper', MN, N, B(1,M-N+1), LDB, U, LDU )
324
CALL DCOPY( N-M+I, B(1,I), 1, U(1,N-M+I), 1 )
327
CALL DLASET( 'Full', N, N-M, ZERO, ZERO, U, LDU )
333
C Perform the QR factorization of B.
337
CALL DGEQRF( M, N, B, LDB, TAU, DWORK, LDWORK, INFO )
338
CALL DLACPY( 'Upper', MN, N, B, LDB, U, LDU )
340
$ CALL DLASET( 'Upper', N-M, N-M, ZERO, ZERO, U(M+1,M+1),
345
C Solve the canonical Lyapunov equation
347
C op(A)'*op(U)'*op(U) + op(U)'*op(U)*op(A) = -scale *op(F)'*op(F),
351
C op(A)'*op(U)'*op(U)*op(A) - op(U)'*op(U) = -scale *op(F)'*op(F)
355
CALL SB03OT( DISCR, LTRANS, N, A, LDA, U, LDU, SCALE, DWORK,
357
IF ( INFO.NE.0 .AND. INFO.NE.1 )
360
C Make the diagonal elements of U non-negative.
365
IF ( U(J,J).LT.ZERO ) THEN
382
IF ( DWORK(L).LT.ZERO ) U(I,J) = -U(I,J)
391
DWORK(1) = MAX( WRKOPT, 4*N )
393
C *** Last line of SB03OU ***