OpenLibm/slatec/rs.f
Viral B. Shah c977aa998f Add Makefile.extras to build libopenlibm-extras.
Replace amos with slatec
2012-12-31 16:37:05 -05:00

90 lines
3.3 KiB
Fortran

*DECK RS
SUBROUTINE RS (NM, N, A, W, MATZ, Z, FV1, FV2, IERR)
C***BEGIN PROLOGUE RS
C***PURPOSE Compute the eigenvalues and, optionally, the eigenvectors
C of a real symmetric matrix.
C***LIBRARY SLATEC (EISPACK)
C***CATEGORY D4A1
C***TYPE SINGLE PRECISION (RS-S, CH-C)
C***KEYWORDS EIGENVALUES, EIGENVECTORS, EISPACK
C***AUTHOR Smith, B. T., et al.
C***DESCRIPTION
C
C This subroutine calls the recommended sequence of
C subroutines from the eigensystem subroutine package (EISPACK)
C to find the eigenvalues and eigenvectors (if desired)
C of a REAL SYMMETRIC matrix.
C
C On Input
C
C NM must be set to the row dimension of the two-dimensional
C array parameters, A and Z, as declared in the calling
C program 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 matrix. A is a two-dimensional
C REAL array, dimensioned A(NM,N).
C
C MATZ is an INTEGER variable set equal to zero if only
C eigenvalues are desired. Otherwise, it is set to any
C non-zero integer for both eigenvalues and eigenvectors.
C
C On Output
C
C A is unaltered.
C
C W contains the eigenvalues in ascending order. W is a one-
C dimensional REAL array, dimensioned W(N).
C
C Z contains the eigenvectors if MATZ is not zero. The
C eigenvectors are orthonormal. Z is a two-dimensional
C REAL array, dimensioned Z(NM,N).
C
C IERR is an INTEGER flag set to
C Zero for normal return,
C 10*N if N is greater than NM,
C J if the J-th eigenvalue has not been
C determined after 30 iterations.
C The eigenvalues, and eigenvectors if requested,
C should be correct for indices 1, 2, ..., IERR-1.
C
C FV1 and FV2 are one-dimensional REAL arrays used for temporary
C storage, dimensioned FV1(N) and FV2(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 TQL2, TQLRAT, TRED1, TRED2
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 RS
C
INTEGER N,NM,IERR,MATZ
REAL A(NM,*),W(*),Z(NM,*),FV1(*),FV2(*)
C
C***FIRST EXECUTABLE STATEMENT RS
IF (N .LE. NM) GO TO 10
IERR = 10 * N
GO TO 50
C
10 IF (MATZ .NE. 0) GO TO 20
C .......... FIND EIGENVALUES ONLY ..........
CALL TRED1(NM,N,A,W,FV1,FV2)
CALL TQLRAT(N,W,FV2,IERR)
GO TO 50
C .......... FIND BOTH EIGENVALUES AND EIGENVECTORS ..........
20 CALL TRED2(NM,N,A,W,FV1,Z)
CALL TQL2(NM,N,W,FV1,Z,IERR)
50 RETURN
END