1
SUBROUTINE DLANV2( A, B, C, D, RT1R, RT1I, RT2R, RT2I, CS, SN )
3
* -- LAPACK auxiliary routine (version 2.0) --
4
* Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
5
* Courant Institute, Argonne National Lab, and Rice University
8
* .. Scalar Arguments ..
9
DOUBLE PRECISION A, B, C, CS, D, RT1I, RT1R, RT2I, RT2R, SN
15
* DLANV2 computes the Schur factorization of a real 2-by-2 nonsymmetric
16
* matrix in standard form:
18
* [ A B ] = [ CS -SN ] [ AA BB ] [ CS SN ]
19
* [ C D ] [ SN CS ] [ CC DD ] [-SN CS ]
22
* 1) CC = 0 so that AA and DD are real eigenvalues of the matrix, or
23
* 2) AA = DD and BB*CC < 0, so that AA + or - sqrt(BB*CC) are complex
24
* conjugate eigenvalues.
29
* A (input/output) DOUBLE PRECISION
30
* B (input/output) DOUBLE PRECISION
31
* C (input/output) DOUBLE PRECISION
32
* D (input/output) DOUBLE PRECISION
33
* On entry, the elements of the input matrix.
34
* On exit, they are overwritten by the elements of the
35
* standardised Schur form.
37
* RT1R (output) DOUBLE PRECISION
38
* RT1I (output) DOUBLE PRECISION
39
* RT2R (output) DOUBLE PRECISION
40
* RT2I (output) DOUBLE PRECISION
41
* The real and imaginary parts of the eigenvalues. If the
42
* eigenvalues are both real, abs(RT1R) >= abs(RT2R); if the
43
* eigenvalues are a complex conjugate pair, RT1I > 0.
45
* CS (output) DOUBLE PRECISION
46
* SN (output) DOUBLE PRECISION
47
* Parameters of the rotation matrix.
49
* =====================================================================
52
DOUBLE PRECISION ZERO, HALF, ONE
53
PARAMETER ( ZERO = 0.0D+0, HALF = 0.5D+0, ONE = 1.0D+0 )
56
DOUBLE PRECISION AA, BB, CC, CS1, DD, P, SAB, SAC, SIGMA, SN1,
59
* .. External Functions ..
60
DOUBLE PRECISION DLAPY2
63
* .. Intrinsic Functions ..
64
INTRINSIC ABS, SIGN, SQRT
66
* .. Executable Statements ..
68
* Initialize CS and SN
76
ELSE IF( B.EQ.ZERO ) THEN
78
* Swap rows and columns
88
ELSE IF( (A-D).EQ.ZERO .AND. SIGN( ONE, B ).NE.
89
$ SIGN( ONE, C ) ) THEN
93
* Make diagonal elements equal
98
TAU = DLAPY2( SIGMA, TEMP )
99
CS1 = SQRT( HALF*( ONE+ABS( SIGMA ) / TAU ) )
100
SN1 = -( P / ( TAU*CS1 ) )*SIGN( ONE, SIGMA )
102
* Compute [ AA BB ] = [ A B ] [ CS1 -SN1 ]
103
* [ CC DD ] [ C D ] [ SN1 CS1 ]
110
* Compute [ A B ] = [ CS1 SN1 ] [ AA BB ]
111
* [ C D ] [-SN1 CS1 ] [ CC DD ]
118
* Accumulate transformation
120
TEMP = CS*CS1 - SN*SN1
130
IF( SIGN( ONE, B ).EQ.SIGN( ONE, C ) ) THEN
132
* Real eigenvalues: reduce to upper triangular form
134
SAB = SQRT( ABS( B ) )
135
SAC = SQRT( ABS( C ) )
136
P = SIGN( SAB*SAC, C )
137
TAU = ONE / SQRT( ABS( B+C ) )
144
TEMP = CS*CS1 - SN*SN1
160
* Store eigenvalues in (RT1R,RT1I) and (RT2R,RT2I).
168
RT1I = SQRT( ABS( B ) )*SQRT( ABS( C ) )