1 SUBROUTINE DLAEV2( A, B, C, RT1, RT2, CS1, SN1 )
3 ! -- LAPACK auxiliary routine (version 3.1) --
4 ! Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
7 ! .. Scalar Arguments ..
8 DOUBLE PRECISION A, B, C, CS1, RT1, RT2, SN1
14 ! DLAEV2 computes the eigendecomposition of a 2-by-2 symmetric matrix
17 ! On return, RT1 is the eigenvalue of larger absolute value, RT2 is the
18 ! eigenvalue of smaller absolute value, and (CS1,SN1) is the unit right
19 ! eigenvector for RT1, giving the decomposition
21 ! [ CS1 SN1 ] [ A B ] [ CS1 -SN1 ] = [ RT1 0 ]
22 ! [-SN1 CS1 ] [ B C ] [ SN1 CS1 ] [ 0 RT2 ].
27 ! A (input) DOUBLE PRECISION
28 ! The (1,1) element of the 2-by-2 matrix.
30 ! B (input) DOUBLE PRECISION
31 ! The (1,2) element and the conjugate of the (2,1) element of
34 ! C (input) DOUBLE PRECISION
35 ! The (2,2) element of the 2-by-2 matrix.
37 ! RT1 (output) DOUBLE PRECISION
38 ! The eigenvalue of larger absolute value.
40 ! RT2 (output) DOUBLE PRECISION
41 ! The eigenvalue of smaller absolute value.
43 ! CS1 (output) DOUBLE PRECISION
44 ! SN1 (output) DOUBLE PRECISION
45 ! The vector (CS1, SN1) is a unit right eigenvector for RT1.
50 ! RT1 is accurate to a few ulps barring over/underflow.
52 ! RT2 may be inaccurate if there is massive cancellation in the
53 ! determinant A*C-B*B; higher precision or correctly rounded or
54 ! correctly truncated arithmetic would be needed to compute RT2
55 ! accurately in all cases.
57 ! CS1 and SN1 are accurate to a few ulps barring over/underflow.
59 ! Overflow is possible only if RT1 is within a factor of 5 of overflow.
60 ! Underflow is harmless if the input data is 0 or exceeds
61 ! underflow_threshold / macheps.
63 ! =====================================================================
67 PARAMETER ( ONE = 1.0D0 )
69 PARAMETER ( TWO = 2.0D0 )
71 PARAMETER ( ZERO = 0.0D0 )
73 PARAMETER ( HALF = 0.5D0 )
77 DOUBLE PRECISION AB, ACMN, ACMX, ACS, ADF, CS, CT, DF, RT, SM, &
80 ! .. Intrinsic Functions ..
83 ! .. Executable Statements ..
85 ! Compute the eigenvalues
92 IF( ABS( A ).GT.ABS( C ) ) THEN
100 RT = ADF*SQRT( ONE+( AB / ADF )**2 )
101 ELSE IF( ADF.LT.AB ) THEN
102 RT = AB*SQRT( ONE+( ADF / AB )**2 )
105 ! Includes case AB=ADF=0
109 IF( SM.LT.ZERO ) THEN
113 ! Order of execution important.
114 ! To get fully accurate smaller eigenvalue,
115 ! next line needs to be executed in higher precision.
117 RT2 = ( ACMX / RT1 )*ACMN - ( B / RT1 )*B
118 ELSE IF( SM.GT.ZERO ) THEN
122 ! Order of execution important.
123 ! To get fully accurate smaller eigenvalue,
124 ! next line needs to be executed in higher precision.
126 RT2 = ( ACMX / RT1 )*ACMN - ( B / RT1 )*B
129 ! Includes case RT1 = RT2 = 0
136 ! Compute the eigenvector
138 IF( DF.GE.ZERO ) THEN
148 SN1 = ONE / SQRT( ONE+CT*CT )
151 IF( AB.EQ.ZERO ) THEN
156 CS1 = ONE / SQRT( ONE+TN*TN )
160 IF( SGN1.EQ.SGN2 ) THEN
169 END SUBROUTINE DLAEV2