1 SUBROUTINE DSTERF
( N
, D
, E
, INFO
)
3 * -- LAPACK routine
(version
3.1) --
4 * Univ
. of Tennessee
, Univ
. of California Berkeley and NAG Ltd
..
7 * .. Scalar Arguments
..
10 * .. Array Arguments
..
11 DOUBLE PRECISION D
( * ), E
( * )
17 * DSTERF computes all eigenvalues of a symmetric tridiagonal matrix
18 * using the Pal
-Walker
-Kahan variant of the QL or QR algorithm
.
24 * The order of the matrix
. N
>= 0.
26 * D
(input
/output
) DOUBLE PRECISION array
, dimension (N
)
27 * On entry
, the n diagonal elements of the tridiagonal matrix
.
28 * On exit
, if INFO
= 0, the eigenvalues in ascending order
.
30 * E
(input
/output
) DOUBLE PRECISION array
, dimension (N
-1)
31 * On entry
, the
(n
-1) subdiagonal elements of the tridiagonal
33 * On exit
, E has been destroyed
.
35 * INFO
(output
) INTEGER
36 * = 0: successful exit
37 * < 0: if INFO
= -i
, the i
-th argument had an illegal value
38 * > 0: the algorithm failed
to find all of the eigenvalues in
39 * a total of
30*N iterations
; if INFO
= i
, then i
40 * elements of E have not converged
to zero
.
42 * =====================================================================
45 DOUBLE PRECISION ZERO
, ONE
, TWO
, THREE
46 PARAMETER ( ZERO
= 0.0D0
, ONE
= 1.0D0
, TWO
= 2.0D0
,
49 PARAMETER ( MAXIT
= 30 )
52 INTEGER I
, ISCALE
, JTOT
, L
, L1
, LEND
, LENDSV
, LSV
, M
,
54 DOUBLE PRECISION ALPHA
, ANORM
, BB
, C
, EPS
, EPS2
, GAMMA
, OLDC
,
55 $ OLDGAM
, P
, R
, RT1
, RT2
, RTE
, S
, SAFMAX
, SAFMIN
,
56 $ SIGMA
, SSFMAX
, SSFMIN
58 * .. External Functions
..
59 DOUBLE PRECISION DLAMCH
, DLANST
, DLAPY2
60 EXTERNAL DLAMCH
, DLANST
, DLAPY2
62 * .. External Subroutines
..
63 EXTERNAL DLAE2
, DLASCL
, DLASRT
, XERBLA
65 * .. Intrinsic Functions
..
66 INTRINSIC ABS
, SIGN
, SQRT
68 * .. Executable Statements
..
70 * Test the input parameters
.
74 * Quick
return if possible
78 CALL XERBLA
( 'DSTERF', -INFO
)
84 * Determine the unit roundoff
for this environment
.
88 SAFMIN
= DLAMCH
( 'S' )
90 SSFMAX
= SQRT
( SAFMAX
) / THREE
91 SSFMIN
= SQRT
( SAFMIN
) / EPS2
93 * Compute the eigenvalues of the tridiagonal matrix
.
99 * Determine where the matrix splits and choose QL or QR iteration
100 * for each block
, according
to whether top or bottom diagonal
101 * element is smaller
.
111 IF( ABS
( E
( M
) ).LE
.( SQRT
( ABS
( D
( M
) ) )*SQRT
( ABS
( D
( M
+
112 $
1 ) ) ) )*EPS
) THEN
128 * Scale submatrix in rows and columns L
to LEND
130 ANORM
= DLANST
( 'I', LEND
-L
+1, D
( L
), E
( L
) )
132 IF( ANORM
.GT
.SSFMAX
) THEN
134 CALL DLASCL
( 'G', 0, 0, ANORM
, SSFMAX
, LEND
-L
+1, 1, D
( L
), N
,
136 CALL DLASCL
( 'G', 0, 0, ANORM
, SSFMAX
, LEND
-L
, 1, E
( L
), N
,
138 ELSE IF( ANORM
.LT
.SSFMIN
) THEN
140 CALL DLASCL
( 'G', 0, 0, ANORM
, SSFMIN
, LEND
-L
+1, 1, D
( L
), N
,
142 CALL DLASCL
( 'G', 0, 0, ANORM
, SSFMIN
, LEND
-L
, 1, E
( L
), N
,
146 DO 40 I
= L
, LEND
- 1
150 * Choose between QL and QR iteration
152 IF( ABS
( D
( LEND
) ).LT
.ABS
( D
( L
) ) ) THEN
161 * Look
for small subdiagonal element
.
165 DO 60 M
= L
, LEND
- 1
166 IF( ABS
( E
( M
) ).LE
.EPS2*ABS
( D
( M
)*D
( M
+1 ) ) )
179 * If remaining matrix is
2 by
2, use DLAE2
to compute its
184 CALL DLAE2
( D
( L
), RTE
, D
( L
+1 ), RT1
, RT2
)
201 SIGMA
= ( D
( L
+1 )-P
) / ( TWO*RTE
)
202 R
= DLAPY2
( SIGMA
, ONE
)
203 SIGMA
= P
- ( RTE
/ ( SIGMA
+SIGN
( R
, SIGMA
) ) )
207 GAMMA
= D
( M
) - SIGMA
212 DO 80 I
= M
- 1, L
, -1
222 GAMMA
= C*
( ALPHA
-SIGMA
) - S*OLDGAM
223 D
( I
+1 ) = OLDGAM
+ ( ALPHA
-GAMMA
)
225 P
= ( GAMMA*GAMMA
) / C
232 D
( L
) = SIGMA
+ GAMMA
249 * Look
for small superdiagonal element
.
252 DO 110 M
= L
, LEND
+ 1, -1
253 IF( ABS
( E
( M
-1 ) ).LE
.EPS2*ABS
( D
( M
)*D
( M
-1 ) ) )
265 * If remaining matrix is
2 by
2, use DLAE2
to compute its
269 RTE
= SQRT
( E
( L
-1 ) )
270 CALL DLAE2
( D
( L
), RTE
, D
( L
-1 ), RT1
, RT2
)
286 RTE
= SQRT
( E
( L
-1 ) )
287 SIGMA
= ( D
( L
-1 )-P
) / ( TWO*RTE
)
288 R
= DLAPY2
( SIGMA
, ONE
)
289 SIGMA
= P
- ( RTE
/ ( SIGMA
+SIGN
( R
, SIGMA
) ) )
293 GAMMA
= D
( M
) - SIGMA
308 GAMMA
= C*
( ALPHA
-SIGMA
) - S*OLDGAM
309 D
( I
) = OLDGAM
+ ( ALPHA
-GAMMA
)
311 P
= ( GAMMA*GAMMA
) / C
318 D
( L
) = SIGMA
+ GAMMA
333 * Undo scaling
if necessary
337 $
CALL DLASCL
( 'G', 0, 0, SSFMAX
, ANORM
, LENDSV
-LSV
+1, 1,
338 $ D
( LSV
), N
, INFO
)
340 $
CALL DLASCL
( 'G', 0, 0, SSFMIN
, ANORM
, LENDSV
-LSV
+1, 1,
341 $ D
( LSV
), N
, INFO
)
343 * Check
for no convergence
to an eigenvalue after a total
344 * of N*MAXIT iterations
.
354 * Sort eigenvalues in increasing order
.
357 CALL DLASRT
( 'I', N
, D
, INFO
)