Mac binaries
[jabaws.git] / website / archive / binaries / mac / src / disembl / Tisean_3.0.1 / source_f / slatec / tred1.f
diff --git a/website/archive/binaries/mac/src/disembl/Tisean_3.0.1/source_f/slatec/tred1.f b/website/archive/binaries/mac/src/disembl/Tisean_3.0.1/source_f/slatec/tred1.f
new file mode 100644 (file)
index 0000000..1586bd5
--- /dev/null
@@ -0,0 +1,142 @@
+*DECK TRED1
+      SUBROUTINE TRED1 (NM, N, A, D, E, E2)
+C***BEGIN PROLOGUE  TRED1
+C***PURPOSE  Reduce a real symmetric matrix to symmetric tridiagonal
+C            matrix using orthogonal similarity transformations.
+C***LIBRARY   SLATEC (EISPACK)
+C***CATEGORY  D4C1B1
+C***TYPE      SINGLE PRECISION (TRED1-S)
+C***KEYWORDS  EIGENVALUES, EIGENVECTORS, EISPACK
+C***AUTHOR  Smith, B. T., et al.
+C***DESCRIPTION
+C
+C     This subroutine is a translation of the ALGOL procedure TRED1,
+C     NUM. MATH. 11, 181-195(1968) by Martin, Reinsch, and Wilkinson.
+C     HANDBOOK FOR AUTO. COMP., VOL.II-LINEAR ALGEBRA, 212-226(1971).
+C
+C     This subroutine reduces a REAL SYMMETRIC matrix
+C     to a symmetric tridiagonal matrix using
+C     orthogonal similarity transformations.
+C
+C     On Input
+C
+C        NM must be set to the row dimension of the two-dimensional
+C          array parameter, A, as declared in the calling program
+C          dimension statement.  NM is an INTEGER variable.
+C
+C        N is the order of the matrix A.  N is an INTEGER variable.
+C          N must be less than or equal to NM.
+C
+C        A contains the real symmetric input matrix.  Only the lower
+C          triangle of the matrix need be supplied.  A is a two-
+C          dimensional REAL array, dimensioned A(NM,N).
+C
+C     On Output
+C
+C        A contains information about the orthogonal transformations
+C          used in the reduction in its strict lower triangle.  The
+C          full upper triangle of A is unaltered.
+C
+C        D contains the diagonal elements of the symmetric tridiagonal
+C          matrix.  D is a one-dimensional REAL array, dimensioned D(N).
+C
+C        E contains the subdiagonal elements of the symmetric
+C          tridiagonal matrix in its last N-1 positions.  E(1) is set
+C          to zero.  E is a one-dimensional REAL array, dimensioned
+C          E(N).
+C
+C        E2 contains the squares of the corresponding elements of E.
+C          E2 may coincide with E if the squares are not needed.
+C          E2 is a one-dimensional REAL array, dimensioned E2(N).
+C
+C     Questions and comments should be directed to B. S. Garbow,
+C     APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
+C     ------------------------------------------------------------------
+C
+C***REFERENCES  B. T. Smith, J. M. Boyle, J. J. Dongarra, B. S. Garbow,
+C                 Y. Ikebe, V. C. Klema and C. B. Moler, Matrix Eigen-
+C                 system Routines - EISPACK Guide, Springer-Verlag,
+C                 1976.
+C***ROUTINES CALLED  (NONE)
+C***REVISION HISTORY  (YYMMDD)
+C   760101  DATE WRITTEN
+C   890831  Modified array declarations.  (WRB)
+C   890831  REVISION DATE from Version 3.2
+C   891214  Prologue converted to Version 4.0 format.  (BAB)
+C   920501  Reformatted the REFERENCES section.  (WRB)
+C***END PROLOGUE  TRED1
+C
+      INTEGER I,J,K,L,N,II,NM,JP1
+      REAL A(NM,*),D(*),E(*),E2(*)
+      REAL F,G,H,SCALE
+C
+C***FIRST EXECUTABLE STATEMENT  TRED1
+      DO 100 I = 1, N
+  100 D(I) = A(I,I)
+C     .......... FOR I=N STEP -1 UNTIL 1 DO -- ..........
+      DO 300 II = 1, N
+         I = N + 1 - II
+         L = I - 1
+         H = 0.0E0
+         SCALE = 0.0E0
+         IF (L .LT. 1) GO TO 130
+C     .......... SCALE ROW (ALGOL TOL THEN NOT NEEDED) ..........
+         DO 120 K = 1, L
+  120    SCALE = SCALE + ABS(A(I,K))
+C
+         IF (SCALE .NE. 0.0E0) GO TO 140
+  130    E(I) = 0.0E0
+         E2(I) = 0.0E0
+         GO TO 290
+C
+  140    DO 150 K = 1, L
+            A(I,K) = A(I,K) / SCALE
+            H = H + A(I,K) * A(I,K)
+  150    CONTINUE
+C
+         E2(I) = SCALE * SCALE * H
+         F = A(I,L)
+         G = -SIGN(SQRT(H),F)
+         E(I) = SCALE * G
+         H = H - F * G
+         A(I,L) = F - G
+         IF (L .EQ. 1) GO TO 270
+         F = 0.0E0
+C
+         DO 240 J = 1, L
+            G = 0.0E0
+C     .......... FORM ELEMENT OF A*U ..........
+            DO 180 K = 1, J
+  180       G = G + A(J,K) * A(I,K)
+C
+            JP1 = J + 1
+            IF (L .LT. JP1) GO TO 220
+C
+            DO 200 K = JP1, L
+  200       G = G + A(K,J) * A(I,K)
+C     .......... FORM ELEMENT OF P ..........
+  220       E(J) = G / H
+            F = F + E(J) * A(I,J)
+  240    CONTINUE
+C
+         H = F / (H + H)
+C     .......... FORM REDUCED A ..........
+         DO 260 J = 1, L
+            F = A(I,J)
+            G = E(J) - H * F
+            E(J) = G
+C
+            DO 260 K = 1, J
+               A(J,K) = A(J,K) - F * E(K) - G * A(I,K)
+  260    CONTINUE
+C
+  270    DO 280 K = 1, L
+  280    A(I,K) = SCALE * A(I,K)
+C
+  290    H = D(I)
+         D(I) = A(I,I)
+         A(I,I) = H
+  300 CONTINUE
+C
+      RETURN
+      END