2 SUBROUTINE TQL2 (NM, N, D, E, Z, IERR)
3 C***BEGIN PROLOGUE TQL2
4 C***PURPOSE Compute the eigenvalues and eigenvectors of symmetric
6 C***LIBRARY SLATEC (EISPACK)
7 C***CATEGORY D4A5, D4C2A
8 C***TYPE SINGLE PRECISION (TQL2-S)
9 C***KEYWORDS EIGENVALUES, EIGENVECTORS, EISPACK
10 C***AUTHOR Smith, B. T., et al.
13 C This subroutine is a translation of the ALGOL procedure TQL2,
14 C NUM. MATH. 11, 293-306(1968) by Bowdler, Martin, Reinsch, and
16 C HANDBOOK FOR AUTO. COMP., VOL.II-LINEAR ALGEBRA, 227-240(1971).
18 C This subroutine finds the eigenvalues and eigenvectors
19 C of a SYMMETRIC TRIDIAGONAL matrix by the QL method.
20 C The eigenvectors of a FULL SYMMETRIC matrix can also
21 C be found if TRED2 has been used to reduce this
22 C full matrix to tridiagonal form.
26 C NM must be set to the row dimension of the two-dimensional
27 C array parameter, Z, as declared in the calling program
28 C dimension statement. NM is an INTEGER variable.
30 C N is the order of the matrix. N is an INTEGER variable.
31 C N must be less than or equal to NM.
33 C D contains the diagonal elements of the symmetric tridiagonal
34 C matrix. D is a one-dimensional REAL array, dimensioned D(N).
36 C E contains the subdiagonal elements of the symmetric
37 C tridiagonal matrix in its last N-1 positions. E(1) is
38 C arbitrary. E is a one-dimensional REAL array, dimensioned
41 C Z contains the transformation matrix produced in the
42 C reduction by TRED2, if performed. If the eigenvectors
43 C of the tridiagonal matrix are desired, Z must contain
44 C the identity matrix. Z is a two-dimensional REAL array,
45 C dimensioned Z(NM,N).
49 C D contains the eigenvalues in ascending order. If an
50 C error exit is made, the eigenvalues are correct but
51 C unordered for indices 1, 2, ..., IERR-1.
53 C E has been destroyed.
55 C Z contains orthonormal eigenvectors of the symmetric
56 C tridiagonal (or full) matrix. If an error exit is made,
57 C Z contains the eigenvectors associated with the stored
60 C IERR is an INTEGER flag set to
61 C Zero for normal return,
62 C J if the J-th eigenvalue has not been
63 C determined after 30 iterations.
65 C Calls PYTHAG(A,B) for sqrt(A**2 + B**2).
67 C Questions and comments should be directed to B. S. Garbow,
68 C APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
69 C ------------------------------------------------------------------
71 C***REFERENCES B. T. Smith, J. M. Boyle, J. J. Dongarra, B. S. Garbow,
72 C Y. Ikebe, V. C. Klema and C. B. Moler, Matrix Eigen-
73 C system Routines - EISPACK Guide, Springer-Verlag,
75 C***ROUTINES CALLED PYTHAG
76 C***REVISION HISTORY (YYMMDD)
78 C 890831 Modified array declarations. (WRB)
79 C 890831 REVISION DATE from Version 3.2
80 C 891214 Prologue converted to Version 4.0 format. (BAB)
81 C 920501 Reformatted the REFERENCES section. (WRB)
84 INTEGER I,J,K,L,M,N,II,L1,L2,NM,MML,IERR
85 REAL D(*),E(*),Z(NM,*)
86 REAL B,C,C2,C3,DL1,EL1,F,G,H,P,R,S,S2
89 C***FIRST EXECUTABLE STATEMENT TQL2
91 IF (N .EQ. 1) GO TO 1001
102 H = ABS(D(L)) + ABS(E(L))
104 C .......... LOOK FOR SMALL SUB-DIAGONAL ELEMENT ..........
106 IF (B + ABS(E(M)) .EQ. B) GO TO 120
107 C .......... E(N) IS ALWAYS ZERO, SO THERE IS NO EXIT
108 C THROUGH THE BOTTOM OF THE LOOP ..........
111 120 IF (M .EQ. L) GO TO 220
112 130 IF (J .EQ. 30) GO TO 1000
114 C .......... FORM SHIFT ..........
118 P = (D(L1) - G) / (2.0E0 * E(L))
120 D(L) = E(L) / (P + SIGN(R,P))
121 D(L1) = E(L) * (P + SIGN(R,P))
124 IF (L2 .GT. N) GO TO 145
130 C .......... QL TRANSFORMATION ..........
137 C .......... FOR I=M-1 STEP -1 UNTIL L DO -- ..........
145 IF (ABS(P) .LT. ABS(E(I))) GO TO 150
154 E(I+1) = S * E(I) * R
157 160 P = C * D(I) - S * G
158 D(I+1) = H + S * (C * G + S * D(I))
159 C .......... FORM VECTOR ..........
162 Z(K,I+1) = S * Z(K,I) + C * H
163 Z(K,I) = C * Z(K,I) - S * H
168 P = -S * S2 * C3 * EL1 * E(L) / DL1
171 IF (B + ABS(E(L)) .GT. B) GO TO 130
174 C .......... ORDER EIGENVALUES AND EIGENVECTORS ..........
181 IF (D(J) .GE. P) GO TO 260
186 IF (K .EQ. I) GO TO 300
199 C .......... SET ERROR -- NO CONVERGENCE TO AN
200 C EIGENVALUE AFTER 30 ITERATIONS ..........