LAPACK  3.6.1
LAPACK: Linear Algebra PACKage
subroutine slae2 ( real  A,
real  B,
real  C,
real  RT1,
real  RT2 
)

SLAE2 computes the eigenvalues of a 2-by-2 symmetric matrix.

Download SLAE2 + dependencies [TGZ] [ZIP] [TXT]

Purpose:
 SLAE2  computes the eigenvalues of a 2-by-2 symmetric matrix
    [  A   B  ]
    [  B   C  ].
 On return, RT1 is the eigenvalue of larger absolute value, and RT2
 is the eigenvalue of smaller absolute value.
Parameters
[in]A
          A is REAL
          The (1,1) element of the 2-by-2 matrix.
[in]B
          B is REAL
          The (1,2) and (2,1) elements of the 2-by-2 matrix.
[in]C
          C is REAL
          The (2,2) element of the 2-by-2 matrix.
[out]RT1
          RT1 is REAL
          The eigenvalue of larger absolute value.
[out]RT2
          RT2 is REAL
          The eigenvalue of smaller absolute value.
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
Date
September 2012
Further Details:
  RT1 is accurate to a few ulps barring over/underflow.

  RT2 may be inaccurate if there is massive cancellation in the
  determinant A*C-B*B; higher precision or correctly rounded or
  correctly truncated arithmetic would be needed to compute RT2
  accurately in all cases.

  Overflow is possible only if RT1 is within a factor of 5 of overflow.
  Underflow is harmless if the input data is 0 or exceeds
     underflow_threshold / macheps.

Definition at line 104 of file slae2.f.

104 *
105 * -- LAPACK auxiliary routine (version 3.4.2) --
106 * -- LAPACK is a software package provided by Univ. of Tennessee, --
107 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
108 * September 2012
109 *
110 * .. Scalar Arguments ..
111  REAL a, b, c, rt1, rt2
112 * ..
113 *
114 * =====================================================================
115 *
116 * .. Parameters ..
117  REAL one
118  parameter ( one = 1.0e0 )
119  REAL two
120  parameter ( two = 2.0e0 )
121  REAL zero
122  parameter ( zero = 0.0e0 )
123  REAL half
124  parameter ( half = 0.5e0 )
125 * ..
126 * .. Local Scalars ..
127  REAL ab, acmn, acmx, adf, df, rt, sm, tb
128 * ..
129 * .. Intrinsic Functions ..
130  INTRINSIC abs, sqrt
131 * ..
132 * .. Executable Statements ..
133 *
134 * Compute the eigenvalues
135 *
136  sm = a + c
137  df = a - c
138  adf = abs( df )
139  tb = b + b
140  ab = abs( tb )
141  IF( abs( a ).GT.abs( c ) ) THEN
142  acmx = a
143  acmn = c
144  ELSE
145  acmx = c
146  acmn = a
147  END IF
148  IF( adf.GT.ab ) THEN
149  rt = adf*sqrt( one+( ab / adf )**2 )
150  ELSE IF( adf.LT.ab ) THEN
151  rt = ab*sqrt( one+( adf / ab )**2 )
152  ELSE
153 *
154 * Includes case AB=ADF=0
155 *
156  rt = ab*sqrt( two )
157  END IF
158  IF( sm.LT.zero ) THEN
159  rt1 = half*( sm-rt )
160 *
161 * Order of execution important.
162 * To get fully accurate smaller eigenvalue,
163 * next line needs to be executed in higher precision.
164 *
165  rt2 = ( acmx / rt1 )*acmn - ( b / rt1 )*b
166  ELSE IF( sm.GT.zero ) THEN
167  rt1 = half*( sm+rt )
168 *
169 * Order of execution important.
170 * To get fully accurate smaller eigenvalue,
171 * next line needs to be executed in higher precision.
172 *
173  rt2 = ( acmx / rt1 )*acmn - ( b / rt1 )*b
174  ELSE
175 *
176 * Includes case RT1 = RT2 = 0
177 *
178  rt1 = half*rt
179  rt2 = -half*rt
180  END IF
181  RETURN
182 *
183 * End of SLAE2
184 *

Here is the caller graph for this function: