1 *> \brief \b DLAGV2 computes the Generalized Schur factorization of a real 2-by-2 matrix pencil (A,B) where B is upper triangular.
3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
9 *> Download DLAGV2 + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlagv2.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dlagv2.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlagv2.f">
21 * SUBROUTINE DLAGV2( A, LDA, B, LDB, ALPHAR, ALPHAI, BETA, CSL, SNL,
24 * .. Scalar Arguments ..
26 * DOUBLE PRECISION CSL, CSR, SNL, SNR
28 * .. Array Arguments ..
29 * DOUBLE PRECISION A( LDA, * ), ALPHAI( 2 ), ALPHAR( 2 ),
30 * $ B( LDB, * ), BETA( 2 )
39 *> DLAGV2 computes the Generalized Schur factorization of a real 2-by-2
40 *> matrix pencil (A,B) where B is upper triangular. This routine
41 *> computes orthogonal (rotation) matrices given by CSL, SNL and CSR,
44 *> 1) if the pencil (A,B) has two real eigenvalues (include 0/0 or 1/0
47 *> [ a11 a12 ] := [ CSL SNL ] [ a11 a12 ] [ CSR -SNR ]
48 *> [ 0 a22 ] [ -SNL CSL ] [ a21 a22 ] [ SNR CSR ]
50 *> [ b11 b12 ] := [ CSL SNL ] [ b11 b12 ] [ CSR -SNR ]
51 *> [ 0 b22 ] [ -SNL CSL ] [ 0 b22 ] [ SNR CSR ],
53 *> 2) if the pencil (A,B) has a pair of complex conjugate eigenvalues,
56 *> [ a11 a12 ] := [ CSL SNL ] [ a11 a12 ] [ CSR -SNR ]
57 *> [ a21 a22 ] [ -SNL CSL ] [ a21 a22 ] [ SNR CSR ]
59 *> [ b11 0 ] := [ CSL SNL ] [ b11 b12 ] [ CSR -SNR ]
60 *> [ 0 b22 ] [ -SNL CSL ] [ 0 b22 ] [ SNR CSR ]
62 *> where b11 >= b22 > 0.
71 *> A is DOUBLE PRECISION array, dimension (LDA, 2)
72 *> On entry, the 2 x 2 matrix A.
73 *> On exit, A is overwritten by the ``A-part'' of the
74 *> generalized Schur form.
80 *> THe leading dimension of the array A. LDA >= 2.
85 *> B is DOUBLE PRECISION array, dimension (LDB, 2)
86 *> On entry, the upper triangular 2 x 2 matrix B.
87 *> On exit, B is overwritten by the ``B-part'' of the
88 *> generalized Schur form.
94 *> THe leading dimension of the array B. LDB >= 2.
99 *> ALPHAR is DOUBLE PRECISION array, dimension (2)
102 *> \param[out] ALPHAI
104 *> ALPHAI is DOUBLE PRECISION array, dimension (2)
109 *> BETA is DOUBLE PRECISION array, dimension (2)
110 *> (ALPHAR(k)+i*ALPHAI(k))/BETA(k) are the eigenvalues of the
111 *> pencil (A,B), k=1,2, i = sqrt(-1). Note that BETA(k) may
117 *> CSL is DOUBLE PRECISION
118 *> The cosine of the left rotation matrix.
123 *> SNL is DOUBLE PRECISION
124 *> The sine of the left rotation matrix.
129 *> CSR is DOUBLE PRECISION
130 *> The cosine of the right rotation matrix.
135 *> SNR is DOUBLE PRECISION
136 *> The sine of the right rotation matrix.
142 *> \author Univ. of Tennessee
143 *> \author Univ. of California Berkeley
144 *> \author Univ. of Colorado Denver
147 *> \date September 2012
149 *> \ingroup doubleOTHERauxiliary
151 *> \par Contributors:
154 *> Mark Fahey, Department of Mathematics, Univ. of Kentucky, USA
156 * =====================================================================
157 SUBROUTINE DLAGV2( A, LDA, B, LDB, ALPHAR, ALPHAI, BETA, CSL, SNL,
160 * -- LAPACK auxiliary routine (version 3.4.2) --
161 * -- LAPACK is a software package provided by Univ. of Tennessee, --
162 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
165 * .. Scalar Arguments ..
167 DOUBLE PRECISION CSL, CSR, SNL, SNR
169 * .. Array Arguments ..
170 DOUBLE PRECISION A( LDA, * ), ALPHAI( 2 ), ALPHAR( 2 ),
171 $ B( LDB, * ), BETA( 2 )
174 * =====================================================================
177 DOUBLE PRECISION ZERO, ONE
178 PARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0 )
180 * .. Local Scalars ..
181 DOUBLE PRECISION ANORM, ASCALE, BNORM, BSCALE, H1, H2, H3, QQ,
182 $ R, RR, SAFMIN, SCALE1, SCALE2, T, ULP, WI, WR1,
185 * .. External Subroutines ..
186 EXTERNAL DLAG2, DLARTG, DLASV2, DROT
188 * .. External Functions ..
189 DOUBLE PRECISION DLAMCH, DLAPY2
190 EXTERNAL DLAMCH, DLAPY2
192 * .. Intrinsic Functions ..
195 * .. Executable Statements ..
197 SAFMIN = DLAMCH( 'S' )
202 ANORM = MAX( ABS( A( 1, 1 ) )+ABS( A( 2, 1 ) ),
203 $ ABS( A( 1, 2 ) )+ABS( A( 2, 2 ) ), SAFMIN )
205 A( 1, 1 ) = ASCALE*A( 1, 1 )
206 A( 1, 2 ) = ASCALE*A( 1, 2 )
207 A( 2, 1 ) = ASCALE*A( 2, 1 )
208 A( 2, 2 ) = ASCALE*A( 2, 2 )
212 BNORM = MAX( ABS( B( 1, 1 ) ), ABS( B( 1, 2 ) )+ABS( B( 2, 2 ) ),
215 B( 1, 1 ) = BSCALE*B( 1, 1 )
216 B( 1, 2 ) = BSCALE*B( 1, 2 )
217 B( 2, 2 ) = BSCALE*B( 2, 2 )
219 * Check if A can be deflated
221 IF( ABS( A( 2, 1 ) ).LE.ULP ) THEN
230 * Check if B is singular
232 ELSE IF( ABS( B( 1, 1 ) ).LE.ULP ) THEN
233 CALL DLARTG( A( 1, 1 ), A( 2, 1 ), CSL, SNL, R )
236 CALL DROT( 2, A( 1, 1 ), LDA, A( 2, 1 ), LDA, CSL, SNL )
237 CALL DROT( 2, B( 1, 1 ), LDB, B( 2, 1 ), LDB, CSL, SNL )
243 ELSE IF( ABS( B( 2, 2 ) ).LE.ULP ) THEN
244 CALL DLARTG( A( 2, 2 ), A( 2, 1 ), CSR, SNR, T )
246 CALL DROT( 2, A( 1, 1 ), 1, A( 1, 2 ), 1, CSR, SNR )
247 CALL DROT( 2, B( 1, 1 ), 1, B( 1, 2 ), 1, CSR, SNR )
257 * B is nonsingular, first compute the eigenvalues of (A,B)
259 CALL DLAG2( A, LDA, B, LDB, SAFMIN, SCALE1, SCALE2, WR1, WR2,
262 IF( WI.EQ.ZERO ) THEN
264 * two real eigenvalues, compute s*A-w*B
266 H1 = SCALE1*A( 1, 1 ) - WR1*B( 1, 1 )
267 H2 = SCALE1*A( 1, 2 ) - WR1*B( 1, 2 )
268 H3 = SCALE1*A( 2, 2 ) - WR1*B( 2, 2 )
270 RR = DLAPY2( H1, H2 )
271 QQ = DLAPY2( SCALE1*A( 2, 1 ), H3 )
275 * find right rotation matrix to zero 1,1 element of
278 CALL DLARTG( H2, H1, CSR, SNR, T )
282 * find right rotation matrix to zero 2,1 element of
285 CALL DLARTG( H3, SCALE1*A( 2, 1 ), CSR, SNR, T )
290 CALL DROT( 2, A( 1, 1 ), 1, A( 1, 2 ), 1, CSR, SNR )
291 CALL DROT( 2, B( 1, 1 ), 1, B( 1, 2 ), 1, CSR, SNR )
293 * compute inf norms of A and B
295 H1 = MAX( ABS( A( 1, 1 ) )+ABS( A( 1, 2 ) ),
296 $ ABS( A( 2, 1 ) )+ABS( A( 2, 2 ) ) )
297 H2 = MAX( ABS( B( 1, 1 ) )+ABS( B( 1, 2 ) ),
298 $ ABS( B( 2, 1 ) )+ABS( B( 2, 2 ) ) )
300 IF( ( SCALE1*H1 ).GE.ABS( WR1 )*H2 ) THEN
302 * find left rotation matrix Q to zero out B(2,1)
304 CALL DLARTG( B( 1, 1 ), B( 2, 1 ), CSL, SNL, R )
308 * find left rotation matrix Q to zero out A(2,1)
310 CALL DLARTG( A( 1, 1 ), A( 2, 1 ), CSL, SNL, R )
314 CALL DROT( 2, A( 1, 1 ), LDA, A( 2, 1 ), LDA, CSL, SNL )
315 CALL DROT( 2, B( 1, 1 ), LDB, B( 2, 1 ), LDB, CSL, SNL )
322 * a pair of complex conjugate eigenvalues
323 * first compute the SVD of the matrix B
325 CALL DLASV2( B( 1, 1 ), B( 1, 2 ), B( 2, 2 ), R, T, SNR,
328 * Form (A,B) := Q(A,B)Z**T where Q is left rotation matrix and
329 * Z is right rotation matrix computed from DLASV2
331 CALL DROT( 2, A( 1, 1 ), LDA, A( 2, 1 ), LDA, CSL, SNL )
332 CALL DROT( 2, B( 1, 1 ), LDB, B( 2, 1 ), LDB, CSL, SNL )
333 CALL DROT( 2, A( 1, 1 ), 1, A( 1, 2 ), 1, CSR, SNR )
334 CALL DROT( 2, B( 1, 1 ), 1, B( 1, 2 ), 1, CSR, SNR )
345 A( 1, 1 ) = ANORM*A( 1, 1 )
346 A( 2, 1 ) = ANORM*A( 2, 1 )
347 A( 1, 2 ) = ANORM*A( 1, 2 )
348 A( 2, 2 ) = ANORM*A( 2, 2 )
349 B( 1, 1 ) = BNORM*B( 1, 1 )
350 B( 2, 1 ) = BNORM*B( 2, 1 )
351 B( 1, 2 ) = BNORM*B( 1, 2 )
352 B( 2, 2 ) = BNORM*B( 2, 2 )
354 IF( WI.EQ.ZERO ) THEN
355 ALPHAR( 1 ) = A( 1, 1 )
356 ALPHAR( 2 ) = A( 2, 2 )
359 BETA( 1 ) = B( 1, 1 )
360 BETA( 2 ) = B( 2, 2 )
362 ALPHAR( 1 ) = ANORM*WR1 / SCALE1 / BNORM
363 ALPHAI( 1 ) = ANORM*WI / SCALE1 / BNORM
364 ALPHAR( 2 ) = ALPHAR( 1 )
365 ALPHAI( 2 ) = -ALPHAI( 1 )