1 *> \brief \b SLANV2 computes the Schur factorization of a real 2-by-2 nonsymmetric matrix in standard form.
3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
9 *> Download SLANV2 + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/slanv2.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/slanv2.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/slanv2.f">
21 * SUBROUTINE SLANV2( A, B, C, D, RT1R, RT1I, RT2R, RT2I, CS, SN )
23 * .. Scalar Arguments ..
24 * REAL A, B, C, CS, D, RT1I, RT1R, RT2I, RT2R, SN
33 *> SLANV2 computes the Schur factorization of a real 2-by-2 nonsymmetric
34 *> matrix in standard form:
36 *> [ A B ] = [ CS -SN ] [ AA BB ] [ CS SN ]
37 *> [ C D ] [ SN CS ] [ CC DD ] [-SN CS ]
40 *> 1) CC = 0 so that AA and DD are real eigenvalues of the matrix, or
41 *> 2) AA = DD and BB*CC < 0, so that AA + or - sqrt(BB*CC) are complex
42 *> conjugate eigenvalues.
66 *> On entry, the elements of the input matrix.
67 *> On exit, they are overwritten by the elements of the
68 *> standardised Schur form.
89 *> The real and imaginary parts of the eigenvalues. If the
90 *> eigenvalues are a complex conjugate pair, RT1I > 0.
101 *> Parameters of the rotation matrix.
107 *> \author Univ. of Tennessee
108 *> \author Univ. of California Berkeley
109 *> \author Univ. of Colorado Denver
112 *> \date September 2012
114 *> \ingroup realOTHERauxiliary
116 *> \par Further Details:
117 * =====================
121 *> Modified by V. Sima, Research Institute for Informatics, Bucharest,
122 *> Romania, to reduce the risk of cancellation errors,
123 *> when computing real eigenvalues, and to ensure, if possible, that
124 *> abs(RT1R) >= abs(RT2R).
127 * =====================================================================
128 SUBROUTINE SLANV2( A, B, C, D, RT1R, RT1I, RT2R, RT2I, CS, SN )
130 * -- LAPACK auxiliary routine (version 3.4.2) --
131 * -- LAPACK is a software package provided by Univ. of Tennessee, --
132 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
135 * .. Scalar Arguments ..
136 REAL A, B, C, CS, D, RT1I, RT1R, RT2I, RT2R, SN
139 * =====================================================================
143 PARAMETER ( ZERO = 0.0E+0, HALF = 0.5E+0, ONE = 1.0E+0 )
145 PARAMETER ( MULTPL = 4.0E+0 )
147 * .. Local Scalars ..
148 REAL AA, BB, BCMAX, BCMIS, CC, CS1, DD, EPS, P, SAB,
149 $ SAC, SCALE, SIGMA, SN1, TAU, TEMP, Z
151 * .. External Functions ..
153 EXTERNAL SLAMCH, SLAPY2
155 * .. Intrinsic Functions ..
156 INTRINSIC ABS, MAX, MIN, SIGN, SQRT
158 * .. Executable Statements ..
166 ELSE IF( B.EQ.ZERO ) THEN
168 * Swap rows and columns
178 ELSE IF( (A-D).EQ.ZERO .AND. SIGN( ONE, B ).NE.
179 $ SIGN( ONE, C ) ) THEN
187 BCMAX = MAX( ABS( B ), ABS( C ) )
188 BCMIS = MIN( ABS( B ), ABS( C ) )*SIGN( ONE, B )*SIGN( ONE, C )
189 SCALE = MAX( ABS( P ), BCMAX )
190 Z = ( P / SCALE )*P + ( BCMAX / SCALE )*BCMIS
192 * If Z is of the order of the machine accuracy, postpone the
193 * decision on the nature of eigenvalues
195 IF( Z.GE.MULTPL*EPS ) THEN
197 * Real eigenvalues. Compute A and D.
199 Z = P + SIGN( SQRT( SCALE )*SQRT( Z ), P )
201 D = D - ( BCMAX / Z )*BCMIS
203 * Compute B and the rotation matrix
212 * Complex eigenvalues, or real (almost) equal eigenvalues.
213 * Make diagonal elements equal.
216 TAU = SLAPY2( SIGMA, TEMP )
217 CS = SQRT( HALF*( ONE+ABS( SIGMA ) / TAU ) )
218 SN = -( P / ( TAU*CS ) )*SIGN( ONE, SIGMA )
220 * Compute [ AA BB ] = [ A B ] [ CS -SN ]
221 * [ CC DD ] [ C D ] [ SN CS ]
228 * Compute [ A B ] = [ CS SN ] [ AA BB ]
229 * [ C D ] [-SN CS ] [ CC DD ]
242 IF( SIGN( ONE, B ).EQ.SIGN( ONE, C ) ) THEN
244 * Real eigenvalues: reduce to upper triangular form
246 SAB = SQRT( ABS( B ) )
247 SAC = SQRT( ABS( C ) )
248 P = SIGN( SAB*SAC, C )
249 TAU = ONE / SQRT( ABS( B+C ) )
256 TEMP = CS*CS1 - SN*SN1
274 * Store eigenvalues in (RT1R,RT1I) and (RT2R,RT2I).
282 RT1I = SQRT( ABS( B ) )*SQRT( ABS( C ) )