# tinvit.f

          SUBROUTINE TINVIT (NM, N, D, E, E2, M, W, IND, Z, IERR, RV1, RV2,
         +   RV3, RV4, RV6)
    C***BEGIN PROLOGUE  TINVIT
    C***PURPOSE  Compute the eigenvectors of symmetric tridiagonal matrix
    C            corresponding to specified eigenvalues, using inverse
    C            iteration.
    C***LIBRARY   SLATEC (EISPACK)
    C***CATEGORY  D4C3
    C***TYPE      SINGLE PRECISION (TINVIT-S)
    C***KEYWORDS  EIGENVECTORS, EISPACK
    C***AUTHOR  Smith, B. T., et al.
    C***DESCRIPTION
    C
    C     This subroutine is a translation of the inverse iteration tech-
    C     nique in the ALGOL procedure TRISTURM by Peters and Wilkinson.
    C     HANDBOOK FOR AUTO. COMP., VOL.II-LINEAR ALGEBRA, 418-439(1971).
    C
    C     This subroutine finds those eigenvectors of a TRIDIAGONAL
    C     SYMMETRIC matrix corresponding to specified eigenvalues,
    C     using inverse iteration.
    C
    C     On Input
    C
    C        NM must be set to the row dimension of the two-dimensional
    C          array parameter, Z, as declared in the calling program
    C          dimension statement.  NM is an INTEGER variable.
    C
    C        N is the order of the matrix.  N is an INTEGER variable.
    C          N must be less than or equal to NM.
    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
    C          arbitrary.  E is a one-dimensional REAL array, dimensioned
    C          E(N).
    C
    C        E2 contains the squares of the corresponding elements of E,
    C          with zeros corresponding to negligible elements of E.
    C          E(I) is considered negligible if it is not larger than
    C          the product of the relative machine precision and the sum
    C          of the magnitudes of D(I) and D(I-1).  E2(1) must contain
    C          0.0e0 if the eigenvalues are in ascending order, or 2.0e0
    C          if the eigenvalues are in descending order.  If  BISECT,
    C          TRIDIB, or  IMTQLV  has been used to find the eigenvalues,
    C          their output E2 array is exactly what is expected here.
    C          E2 is a one-dimensional REAL array, dimensioned E2(N).
    C
    C        M is the number of specified eigenvalues for which eigenvectors
    C          are to be determined.  M is an INTEGER variable.
    C
    C        W contains the M eigenvalues in ascending or descending order.
    C          W is a one-dimensional REAL array, dimensioned W(M).
    C
    C        IND contains in its first M positions the submatrix indices
    C          associated with the corresponding eigenvalues in W --
    C          1 for eigenvalues belonging to the first submatrix from
    C          the top, 2 for those belonging to the second submatrix, etc.
    C          If  BISECT  or  TRIDIB  has been used to determine the
    C          eigenvalues, their output IND array is suitable for input
    C          to TINVIT.  IND is a one-dimensional INTEGER array,
    C          dimensioned IND(M).
    C
    C     On Output
    C
    C       ** All input arrays are unaltered.**
    C
    C        Z contains the associated set of orthonormal eigenvectors.
    C          Any vector which fails to converge is set to zero.
    C          Z is a two-dimensional REAL array, dimensioned Z(NM,M).
    C
    C        IERR is an INTEGER flag set to
    C          Zero       for normal return,
    C          -J         if the eigenvector corresponding to the J-th
    C                     eigenvalue fails to converge in 5 iterations.
    C
    C        RV1, RV2 and RV3 are one-dimensional REAL arrays used for
    C          temporary storage.  They are used to store the main diagonal
    C          and the two adjacent diagonals of the triangular matrix
    C          produced in the inverse iteration process.  RV1, RV2 and
    C          RV3 are dimensioned RV1(N), RV2(N) and RV3(N).
    C
    C        RV4 and RV6 are one-dimensional REAL arrays used for temporary
    C          storage.  RV4 holds the multipliers of the Gaussian
    C          elimination process.  RV6 holds the approximate eigenvectors
    C          in this process.  RV4 and RV6 are dimensioned RV4(N) and
    C          RV6(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   890531  Changed all specific intrinsics to generic.  (WRB)
    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  TINVIT