2 SUBROUTINE TQLRAT (N, D, E2, IERR)
3 C***BEGIN PROLOGUE TQLRAT
4 C***PURPOSE Compute the eigenvalues of symmetric tridiagonal matrix
5 C using a rational variant of the QL method.
6 C***LIBRARY SLATEC (EISPACK)
7 C***CATEGORY D4A5, D4C2A
8 C***TYPE SINGLE PRECISION (TQLRAT-S)
9 C***KEYWORDS EIGENVALUES OF A SYMMETRIC TRIDIAGONAL MATRIX, EISPACK,
11 C***AUTHOR Smith, B. T., et al.
14 C This subroutine is a translation of the ALGOL procedure TQLRAT.
16 C This subroutine finds the eigenvalues of a SYMMETRIC
17 C TRIDIAGONAL matrix by the rational QL method.
21 C N is the order of the matrix. N is an INTEGER variable.
23 C D contains the diagonal elements of the symmetric tridiagonal
24 C matrix. D is a one-dimensional REAL array, dimensioned D(N).
26 C E2 contains the squares of the subdiagonal elements of the
27 C symmetric tridiagonal matrix in its last N-1 positions.
28 C E2(1) is arbitrary. E2 is a one-dimensional REAL array,
33 C D contains the eigenvalues in ascending order. If an
34 C error exit is made, the eigenvalues are correct and
35 C ordered for indices 1, 2, ..., IERR-1, but may not be
36 C the smallest eigenvalues.
38 C E2 has been destroyed.
40 C IERR is an INTEGER flag set to
41 C Zero for normal return,
42 C J if the J-th eigenvalue has not been
43 C determined after 30 iterations.
45 C Calls PYTHAG(A,B) for sqrt(A**2 + B**2).
47 C Questions and comments should be directed to B. S. Garbow,
48 C APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
49 C ------------------------------------------------------------------
51 C***REFERENCES B. T. Smith, J. M. Boyle, J. J. Dongarra, B. S. Garbow,
52 C Y. Ikebe, V. C. Klema and C. B. Moler, Matrix Eigen-
53 C system Routines - EISPACK Guide, Springer-Verlag,
55 C C. H. Reinsch, Eigenvalues of a real, symmetric, tri-
56 C diagonal matrix, Algorithm 464, Communications of the
57 C ACM 16, 11 (November 1973), pp. 689.
58 C***ROUTINES CALLED PYTHAG, R1MACH
59 C***REVISION HISTORY (YYMMDD)
61 C 890831 Modified array declarations. (WRB)
62 C 890831 REVISION DATE from Version 3.2
63 C 891214 Prologue converted to Version 4.0 format. (BAB)
64 C 920501 Reformatted the REFERENCES section. (WRB)
65 C***END PROLOGUE TQLRAT
67 INTEGER I,J,L,M,N,II,L1,MML,IERR
69 REAL B,C,F,G,H,P,R,S,MACHEP
75 C***FIRST EXECUTABLE STATEMENT TQLRAT
82 IF (N .EQ. 1) GO TO 1001
93 H = MACHEP * (ABS(D(L)) + SQRT(E2(L)))
94 IF (B .GT. H) GO TO 105
97 C .......... LOOK FOR SMALL SQUARED SUB-DIAGONAL ELEMENT ..........
99 IF (E2(M) .LE. C) GO TO 120
100 C .......... E2(N) IS ALWAYS ZERO, SO THERE IS NO EXIT
101 C THROUGH THE BOTTOM OF THE LOOP ..........
104 120 IF (M .EQ. L) GO TO 210
105 130 IF (J .EQ. 30) GO TO 1000
107 C .......... FORM SHIFT ..........
111 P = (D(L1) - G) / (2.0E0 * S)
113 D(L) = S / (P + SIGN(R,P))
120 C .......... RATIONAL QL TRANSFORMATION ..........
122 IF (G .EQ. 0.0E0) G = B
126 C .......... FOR I=M-1 STEP -1 UNTIL L DO -- ..........
133 D(I+1) = H + S * (H + D(I))
135 IF (G .EQ. 0.0E0) G = B
141 C .......... GUARD AGAINST UNDERFLOW IN CONVERGENCE TEST ..........
142 IF (H .EQ. 0.0E0) GO TO 210
143 IF (ABS(E2(L)) .LE. ABS(C/H)) GO TO 210
145 IF (E2(L) .NE. 0.0E0) GO TO 130
147 C .......... ORDER EIGENVALUES ..........
148 IF (L .EQ. 1) GO TO 250
149 C .......... FOR I=L STEP -1 UNTIL 2 DO -- ..........
152 IF (P .GE. D(I-1)) GO TO 270
161 C .......... SET ERROR -- NO CONVERGENCE TO AN
162 C EIGENVALUE AFTER 30 ITERATIONS ..........