1      SUBROUTINE RGG(NM,N,A,B,ALFR,ALFI,BETA,MATZ,Z,IERR)
2C***BEGIN PROLOGUE  RGG
3C***DATE WRITTEN   760101   (YYMMDD)
4C***REVISION DATE  830518   (YYMMDD)
5C***CATEGORY NO.  D4B2
6C***KEYWORDS  EIGENVALUES,EIGENVECTORS,EISPACK
7C***AUTHOR  SMITH, B. T., ET AL.
8C***PURPOSE  Computes eigenvalues and eigenvectors for real generalized
9C            eigenproblem: A*X=(LAMBDA)*B*X.
10C***DESCRIPTION
11C
12C     This subroutine calls the recommended sequence of
13C     subroutines from the eigensystem subroutine package (EISPACK)
14C     to find the eigenvalues and eigenvectors (if desired)
15C     for the REAL GENERAL GENERALIZED eigenproblem  Ax = (LAMBDA)Bx.
16C
17C     On Input
18C
19C        NM  must be set to the row dimension of the two-dimensional
20C        array parameters as declared in the calling program
21C        dimension statement.
22C
23C        N  is the order of the matrices  A  and  B.
24C
25C        A  contains a real general matrix.
26C
27C        B  contains a real general matrix.
28C
29C        MATZ  is an integer variable set equal to zero if
30C        only eigenvalues are desired.  Otherwise it is set to
31C        any non-zero integer for both eigenvalues and eigenvectors.
32C
33C     On Output
34C
35C        ALFR  and  ALFI  contain the real and imaginary parts,
36C        respectively, of the numerators of the eigenvalues.
37C
38C        BETA  contains the denominators of the eigenvalues,
39C        which are thus given by the ratios  (ALFR+I*ALFI)/BETA.
40C        Complex conjugate pairs of eigenvalues appear consecutively
41C        with the eigenvalue having the positive imaginary part first.
42C
43C        Z  contains the real and imaginary parts of the eigenvectors
44C        if MATZ is not zero.  If the J-th eigenvalue is real, the
45C        J-th column of  Z  contains its eigenvector.  If the J-th
46C        eigenvalue is complex with positive imaginary part, the
47C        J-th and (J+1)-th columns of  Z  contain the real and
48C        imaginary parts of its eigenvector.  The conjugate of this
49C        vector is the eigenvector for the conjugate eigenvalue.
50C
51C        IERR  is an integer output variable set equal to an
52C        error completion code described in section 2B of the
53C        documentation.  The normal completion code is zero.
54C
55C     Questions and comments should be directed to B. S. Garbow,
56C     APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
57C     ------------------------------------------------------------------
58C***REFERENCES  B. T. SMITH, J. M. BOYLE, J. J. DONGARRA, B. S. GARBOW,
59C                 Y. IKEBE, V. C. KLEMA, C. B. MOLER, *MATRIX EIGEN-
60C                 SYSTEM ROUTINES - EISPACK GUIDE*, SPRINGER-VERLAG,
61C                 1976.
62C***ROUTINES CALLED  QZHES,QZIT,QZVAL,QZVEC
63C***END PROLOGUE  RGG
64C
65      INTEGER N,NM,IERR,MATZ
66      REAL A(NM,N),B(NM,N),ALFR(N),ALFI(N),BETA(N),Z(NM,N)
67      LOGICAL TF
68C
69C***FIRST EXECUTABLE STATEMENT  RGG
70      IF (N .LE. NM) GO TO 10
71      IERR = 10 * N
72      GO TO 50
73C
74   10 IF (MATZ .NE. 0) GO TO 20
75C     .......... FIND EIGENVALUES ONLY ..........
76      TF = .FALSE.
77      CALL  QZHES(NM,N,A,B,TF,Z)
78      CALL  QZIT(NM,N,A,B,0.0E0,TF,Z,IERR)
79      CALL  QZVAL(NM,N,A,B,ALFR,ALFI,BETA,TF,Z)
80      GO TO 50
81C     .......... FIND BOTH EIGENVALUES AND EIGENVECTORS ..........
82   20 TF = .TRUE.
83      CALL  QZHES(NM,N,A,B,TF,Z)
84      CALL  QZIT(NM,N,A,B,0.0E0,TF,Z,IERR)
85      CALL  QZVAL(NM,N,A,B,ALFR,ALFI,BETA,TF,Z)
86      IF (IERR .NE. 0) GO TO 50
87      CALL  QZVEC(NM,N,A,B,ALFR,ALFI,BETA,Z)
88   50 RETURN
89      END
90