LAPACK 3.12.0
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches

◆ slaev2()

subroutine slaev2 ( real  a,
real  b,
real  c,
real  rt1,
real  rt2,
real  cs1,
real  sn1 
)

SLAEV2 computes the eigenvalues and eigenvectors of a 2-by-2 symmetric/Hermitian matrix.

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

Purpose:
 SLAEV2 computes the eigendecomposition of a 2-by-2 symmetric matrix
    [  A   B  ]
    [  B   C  ].
 On return, RT1 is the eigenvalue of larger absolute value, RT2 is the
 eigenvalue of smaller absolute value, and (CS1,SN1) is the unit right
 eigenvector for RT1, giving the decomposition

    [ CS1  SN1 ] [  A   B  ] [ CS1 -SN1 ]  =  [ RT1  0  ]
    [-SN1  CS1 ] [  B   C  ] [ SN1  CS1 ]     [  0  RT2 ].
Parameters
[in]A
          A is REAL
          The (1,1) element of the 2-by-2 matrix.
[in]B
          B is REAL
          The (1,2) element and the conjugate of the (2,1) element 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.
[out]CS1
          CS1 is REAL
[out]SN1
          SN1 is REAL
          The vector (CS1, SN1) is a unit right eigenvector for RT1.
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
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.

  CS1 and SN1 are accurate to a few ulps barring over/underflow.

  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 119 of file slaev2.f.

120*
121* -- LAPACK auxiliary routine --
122* -- LAPACK is a software package provided by Univ. of Tennessee, --
123* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
124*
125* .. Scalar Arguments ..
126 REAL A, B, C, CS1, RT1, RT2, SN1
127* ..
128*
129* =====================================================================
130*
131* .. Parameters ..
132 REAL ONE
133 parameter( one = 1.0e0 )
134 REAL TWO
135 parameter( two = 2.0e0 )
136 REAL ZERO
137 parameter( zero = 0.0e0 )
138 REAL HALF
139 parameter( half = 0.5e0 )
140* ..
141* .. Local Scalars ..
142 INTEGER SGN1, SGN2
143 REAL AB, ACMN, ACMX, ACS, ADF, CS, CT, DF, RT, SM,
144 $ TB, TN
145* ..
146* .. Intrinsic Functions ..
147 INTRINSIC abs, sqrt
148* ..
149* .. Executable Statements ..
150*
151* Compute the eigenvalues
152*
153 sm = a + c
154 df = a - c
155 adf = abs( df )
156 tb = b + b
157 ab = abs( tb )
158 IF( abs( a ).GT.abs( c ) ) THEN
159 acmx = a
160 acmn = c
161 ELSE
162 acmx = c
163 acmn = a
164 END IF
165 IF( adf.GT.ab ) THEN
166 rt = adf*sqrt( one+( ab / adf )**2 )
167 ELSE IF( adf.LT.ab ) THEN
168 rt = ab*sqrt( one+( adf / ab )**2 )
169 ELSE
170*
171* Includes case AB=ADF=0
172*
173 rt = ab*sqrt( two )
174 END IF
175 IF( sm.LT.zero ) THEN
176 rt1 = half*( sm-rt )
177 sgn1 = -1
178*
179* Order of execution important.
180* To get fully accurate smaller eigenvalue,
181* next line needs to be executed in higher precision.
182*
183 rt2 = ( acmx / rt1 )*acmn - ( b / rt1 )*b
184 ELSE IF( sm.GT.zero ) THEN
185 rt1 = half*( sm+rt )
186 sgn1 = 1
187*
188* Order of execution important.
189* To get fully accurate smaller eigenvalue,
190* next line needs to be executed in higher precision.
191*
192 rt2 = ( acmx / rt1 )*acmn - ( b / rt1 )*b
193 ELSE
194*
195* Includes case RT1 = RT2 = 0
196*
197 rt1 = half*rt
198 rt2 = -half*rt
199 sgn1 = 1
200 END IF
201*
202* Compute the eigenvector
203*
204 IF( df.GE.zero ) THEN
205 cs = df + rt
206 sgn2 = 1
207 ELSE
208 cs = df - rt
209 sgn2 = -1
210 END IF
211 acs = abs( cs )
212 IF( acs.GT.ab ) THEN
213 ct = -tb / cs
214 sn1 = one / sqrt( one+ct*ct )
215 cs1 = ct*sn1
216 ELSE
217 IF( ab.EQ.zero ) THEN
218 cs1 = one
219 sn1 = zero
220 ELSE
221 tn = -cs / tb
222 cs1 = one / sqrt( one+tn*tn )
223 sn1 = tn*cs1
224 END IF
225 END IF
226 IF( sgn1.EQ.sgn2 ) THEN
227 tn = cs1
228 cs1 = -sn1
229 sn1 = tn
230 END IF
231 RETURN
232*
233* End of SLAEV2
234*
Here is the caller graph for this function: