LAPACK 3.3.1
Linear Algebra PACKage

dgeevx.f

Go to the documentation of this file.
00001       SUBROUTINE DGEEVX( BALANC, JOBVL, JOBVR, SENSE, N, A, LDA, WR, WI,
00002      $                   VL, LDVL, VR, LDVR, ILO, IHI, SCALE, ABNRM,
00003      $                   RCONDE, RCONDV, WORK, LWORK, IWORK, INFO )
00004 *
00005 *  -- LAPACK driver routine (version 3.3.1) --
00006 *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
00007 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00008 *  -- April 2011                                                      --
00009 *
00010 *     .. Scalar Arguments ..
00011       CHARACTER          BALANC, JOBVL, JOBVR, SENSE
00012       INTEGER            IHI, ILO, INFO, LDA, LDVL, LDVR, LWORK, N
00013       DOUBLE PRECISION   ABNRM
00014 *     ..
00015 *     .. Array Arguments ..
00016       INTEGER            IWORK( * )
00017       DOUBLE PRECISION   A( LDA, * ), RCONDE( * ), RCONDV( * ),
00018      $                   SCALE( * ), VL( LDVL, * ), VR( LDVR, * ),
00019      $                   WI( * ), WORK( * ), WR( * )
00020 *     ..
00021 *
00022 *  Purpose
00023 *  =======
00024 *
00025 *  DGEEVX computes for an N-by-N real nonsymmetric matrix A, the
00026 *  eigenvalues and, optionally, the left and/or right eigenvectors.
00027 *
00028 *  Optionally also, it computes a balancing transformation to improve
00029 *  the conditioning of the eigenvalues and eigenvectors (ILO, IHI,
00030 *  SCALE, and ABNRM), reciprocal condition numbers for the eigenvalues
00031 *  (RCONDE), and reciprocal condition numbers for the right
00032 *  eigenvectors (RCONDV).
00033 *
00034 *  The right eigenvector v(j) of A satisfies
00035 *                   A * v(j) = lambda(j) * v(j)
00036 *  where lambda(j) is its eigenvalue.
00037 *  The left eigenvector u(j) of A satisfies
00038 *                u(j)**T * A = lambda(j) * u(j)**T
00039 *  where u(j)**T denotes the transpose of u(j).
00040 *
00041 *  The computed eigenvectors are normalized to have Euclidean norm
00042 *  equal to 1 and largest component real.
00043 *
00044 *  Balancing a matrix means permuting the rows and columns to make it
00045 *  more nearly upper triangular, and applying a diagonal similarity
00046 *  transformation D * A * D**(-1), where D is a diagonal matrix, to
00047 *  make its rows and columns closer in norm and the condition numbers
00048 *  of its eigenvalues and eigenvectors smaller.  The computed
00049 *  reciprocal condition numbers correspond to the balanced matrix.
00050 *  Permuting rows and columns will not change the condition numbers
00051 *  (in exact arithmetic) but diagonal scaling will.  For further
00052 *  explanation of balancing, see section 4.10.2 of the LAPACK
00053 *  Users' Guide.
00054 *
00055 *  Arguments
00056 *  =========
00057 *
00058 *  BALANC  (input) CHARACTER*1
00059 *          Indicates how the input matrix should be diagonally scaled
00060 *          and/or permuted to improve the conditioning of its
00061 *          eigenvalues.
00062 *          = 'N': Do not diagonally scale or permute;
00063 *          = 'P': Perform permutations to make the matrix more nearly
00064 *                 upper triangular. Do not diagonally scale;
00065 *          = 'S': Diagonally scale the matrix, i.e. replace A by
00066 *                 D*A*D**(-1), where D is a diagonal matrix chosen
00067 *                 to make the rows and columns of A more equal in
00068 *                 norm. Do not permute;
00069 *          = 'B': Both diagonally scale and permute A.
00070 *
00071 *          Computed reciprocal condition numbers will be for the matrix
00072 *          after balancing and/or permuting. Permuting does not change
00073 *          condition numbers (in exact arithmetic), but balancing does.
00074 *
00075 *  JOBVL   (input) CHARACTER*1
00076 *          = 'N': left eigenvectors of A are not computed;
00077 *          = 'V': left eigenvectors of A are computed.
00078 *          If SENSE = 'E' or 'B', JOBVL must = 'V'.
00079 *
00080 *  JOBVR   (input) CHARACTER*1
00081 *          = 'N': right eigenvectors of A are not computed;
00082 *          = 'V': right eigenvectors of A are computed.
00083 *          If SENSE = 'E' or 'B', JOBVR must = 'V'.
00084 *
00085 *  SENSE   (input) CHARACTER*1
00086 *          Determines which reciprocal condition numbers are computed.
00087 *          = 'N': None are computed;
00088 *          = 'E': Computed for eigenvalues only;
00089 *          = 'V': Computed for right eigenvectors only;
00090 *          = 'B': Computed for eigenvalues and right eigenvectors.
00091 *
00092 *          If SENSE = 'E' or 'B', both left and right eigenvectors
00093 *          must also be computed (JOBVL = 'V' and JOBVR = 'V').
00094 *
00095 *  N       (input) INTEGER
00096 *          The order of the matrix A. N >= 0.
00097 *
00098 *  A       (input/output) DOUBLE PRECISION array, dimension (LDA,N)
00099 *          On entry, the N-by-N matrix A.
00100 *          On exit, A has been overwritten.  If JOBVL = 'V' or
00101 *          JOBVR = 'V', A contains the real Schur form of the balanced
00102 *          version of the input matrix A.
00103 *
00104 *  LDA     (input) INTEGER
00105 *          The leading dimension of the array A.  LDA >= max(1,N).
00106 *
00107 *  WR      (output) DOUBLE PRECISION array, dimension (N)
00108 *  WI      (output) DOUBLE PRECISION array, dimension (N)
00109 *          WR and WI contain the real and imaginary parts,
00110 *          respectively, of the computed eigenvalues.  Complex
00111 *          conjugate pairs of eigenvalues will appear consecutively
00112 *          with the eigenvalue having the positive imaginary part
00113 *          first.
00114 *
00115 *  VL      (output) DOUBLE PRECISION array, dimension (LDVL,N)
00116 *          If JOBVL = 'V', the left eigenvectors u(j) are stored one
00117 *          after another in the columns of VL, in the same order
00118 *          as their eigenvalues.
00119 *          If JOBVL = 'N', VL is not referenced.
00120 *          If the j-th eigenvalue is real, then u(j) = VL(:,j),
00121 *          the j-th column of VL.
00122 *          If the j-th and (j+1)-st eigenvalues form a complex
00123 *          conjugate pair, then u(j) = VL(:,j) + i*VL(:,j+1) and
00124 *          u(j+1) = VL(:,j) - i*VL(:,j+1).
00125 *
00126 *  LDVL    (input) INTEGER
00127 *          The leading dimension of the array VL.  LDVL >= 1; if
00128 *          JOBVL = 'V', LDVL >= N.
00129 *
00130 *  VR      (output) DOUBLE PRECISION array, dimension (LDVR,N)
00131 *          If JOBVR = 'V', the right eigenvectors v(j) are stored one
00132 *          after another in the columns of VR, in the same order
00133 *          as their eigenvalues.
00134 *          If JOBVR = 'N', VR is not referenced.
00135 *          If the j-th eigenvalue is real, then v(j) = VR(:,j),
00136 *          the j-th column of VR.
00137 *          If the j-th and (j+1)-st eigenvalues form a complex
00138 *          conjugate pair, then v(j) = VR(:,j) + i*VR(:,j+1) and
00139 *          v(j+1) = VR(:,j) - i*VR(:,j+1).
00140 *
00141 *  LDVR    (input) INTEGER
00142 *          The leading dimension of the array VR.  LDVR >= 1, and if
00143 *          JOBVR = 'V', LDVR >= N.
00144 *
00145 *  ILO     (output) INTEGER
00146 *  IHI     (output) INTEGER
00147 *          ILO and IHI are integer values determined when A was
00148 *          balanced.  The balanced A(i,j) = 0 if I > J and
00149 *          J = 1,...,ILO-1 or I = IHI+1,...,N.
00150 *
00151 *  SCALE   (output) DOUBLE PRECISION array, dimension (N)
00152 *          Details of the permutations and scaling factors applied
00153 *          when balancing A.  If P(j) is the index of the row and column
00154 *          interchanged with row and column j, and D(j) is the scaling
00155 *          factor applied to row and column j, then
00156 *          SCALE(J) = P(J),    for J = 1,...,ILO-1
00157 *                   = D(J),    for J = ILO,...,IHI
00158 *                   = P(J)     for J = IHI+1,...,N.
00159 *          The order in which the interchanges are made is N to IHI+1,
00160 *          then 1 to ILO-1.
00161 *
00162 *  ABNRM   (output) DOUBLE PRECISION
00163 *          The one-norm of the balanced matrix (the maximum
00164 *          of the sum of absolute values of elements of any column).
00165 *
00166 *  RCONDE  (output) DOUBLE PRECISION array, dimension (N)
00167 *          RCONDE(j) is the reciprocal condition number of the j-th
00168 *          eigenvalue.
00169 *
00170 *  RCONDV  (output) DOUBLE PRECISION array, dimension (N)
00171 *          RCONDV(j) is the reciprocal condition number of the j-th
00172 *          right eigenvector.
00173 *
00174 *  WORK    (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
00175 *          On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
00176 *
00177 *  LWORK   (input) INTEGER
00178 *          The dimension of the array WORK.   If SENSE = 'N' or 'E',
00179 *          LWORK >= max(1,2*N), and if JOBVL = 'V' or JOBVR = 'V',
00180 *          LWORK >= 3*N.  If SENSE = 'V' or 'B', LWORK >= N*(N+6).
00181 *          For good performance, LWORK must generally be larger.
00182 *
00183 *          If LWORK = -1, then a workspace query is assumed; the routine
00184 *          only calculates the optimal size of the WORK array, returns
00185 *          this value as the first entry of the WORK array, and no error
00186 *          message related to LWORK is issued by XERBLA.
00187 *
00188 *  IWORK   (workspace) INTEGER array, dimension (2*N-2)
00189 *          If SENSE = 'N' or 'E', not referenced.
00190 *
00191 *  INFO    (output) INTEGER
00192 *          = 0:  successful exit
00193 *          < 0:  if INFO = -i, the i-th argument had an illegal value.
00194 *          > 0:  if INFO = i, the QR algorithm failed to compute all the
00195 *                eigenvalues, and no eigenvectors or condition numbers
00196 *                have been computed; elements 1:ILO-1 and i+1:N of WR
00197 *                and WI contain eigenvalues which have converged.
00198 *
00199 *  =====================================================================
00200 *
00201 *     .. Parameters ..
00202       DOUBLE PRECISION   ZERO, ONE
00203       PARAMETER          ( ZERO = 0.0D0, ONE = 1.0D0 )
00204 *     ..
00205 *     .. Local Scalars ..
00206       LOGICAL            LQUERY, SCALEA, WANTVL, WANTVR, WNTSNB, WNTSNE,
00207      $                   WNTSNN, WNTSNV
00208       CHARACTER          JOB, SIDE
00209       INTEGER            HSWORK, I, ICOND, IERR, ITAU, IWRK, K, MAXWRK,
00210      $                   MINWRK, NOUT
00211       DOUBLE PRECISION   ANRM, BIGNUM, CS, CSCALE, EPS, R, SCL, SMLNUM,
00212      $                   SN
00213 *     ..
00214 *     .. Local Arrays ..
00215       LOGICAL            SELECT( 1 )
00216       DOUBLE PRECISION   DUM( 1 )
00217 *     ..
00218 *     .. External Subroutines ..
00219       EXTERNAL           DGEBAK, DGEBAL, DGEHRD, DHSEQR, DLABAD, DLACPY,
00220      $                   DLARTG, DLASCL, DORGHR, DROT, DSCAL, DTREVC,
00221      $                   DTRSNA, XERBLA
00222 *     ..
00223 *     .. External Functions ..
00224       LOGICAL            LSAME
00225       INTEGER            IDAMAX, ILAENV
00226       DOUBLE PRECISION   DLAMCH, DLANGE, DLAPY2, DNRM2
00227       EXTERNAL           LSAME, IDAMAX, ILAENV, DLAMCH, DLANGE, DLAPY2,
00228      $                   DNRM2
00229 *     ..
00230 *     .. Intrinsic Functions ..
00231       INTRINSIC          MAX, SQRT
00232 *     ..
00233 *     .. Executable Statements ..
00234 *
00235 *     Test the input arguments
00236 *
00237       INFO = 0
00238       LQUERY = ( LWORK.EQ.-1 )
00239       WANTVL = LSAME( JOBVL, 'V' )
00240       WANTVR = LSAME( JOBVR, 'V' )
00241       WNTSNN = LSAME( SENSE, 'N' )
00242       WNTSNE = LSAME( SENSE, 'E' )
00243       WNTSNV = LSAME( SENSE, 'V' )
00244       WNTSNB = LSAME( SENSE, 'B' )
00245       IF( .NOT.( LSAME( BALANC, 'N' ) .OR. LSAME( BALANC,
00246      $    'S' ) .OR. LSAME( BALANC, 'P' ) .OR. LSAME( BALANC, 'B' ) ) )
00247      $     THEN
00248          INFO = -1
00249       ELSE IF( ( .NOT.WANTVL ) .AND. ( .NOT.LSAME( JOBVL, 'N' ) ) ) THEN
00250          INFO = -2
00251       ELSE IF( ( .NOT.WANTVR ) .AND. ( .NOT.LSAME( JOBVR, 'N' ) ) ) THEN
00252          INFO = -3
00253       ELSE IF( .NOT.( WNTSNN .OR. WNTSNE .OR. WNTSNB .OR. WNTSNV ) .OR.
00254      $         ( ( WNTSNE .OR. WNTSNB ) .AND. .NOT.( WANTVL .AND.
00255      $         WANTVR ) ) ) THEN
00256          INFO = -4
00257       ELSE IF( N.LT.0 ) THEN
00258          INFO = -5
00259       ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
00260          INFO = -7
00261       ELSE IF( LDVL.LT.1 .OR. ( WANTVL .AND. LDVL.LT.N ) ) THEN
00262          INFO = -11
00263       ELSE IF( LDVR.LT.1 .OR. ( WANTVR .AND. LDVR.LT.N ) ) THEN
00264          INFO = -13
00265       END IF
00266 *
00267 *     Compute workspace
00268 *      (Note: Comments in the code beginning "Workspace:" describe the
00269 *       minimal amount of workspace needed at that point in the code,
00270 *       as well as the preferred amount for good performance.
00271 *       NB refers to the optimal block size for the immediately
00272 *       following subroutine, as returned by ILAENV.
00273 *       HSWORK refers to the workspace preferred by DHSEQR, as
00274 *       calculated below. HSWORK is computed assuming ILO=1 and IHI=N,
00275 *       the worst case.)
00276 *
00277       IF( INFO.EQ.0 ) THEN
00278          IF( N.EQ.0 ) THEN
00279             MINWRK = 1
00280             MAXWRK = 1
00281          ELSE
00282             MAXWRK = N + N*ILAENV( 1, 'DGEHRD', ' ', N, 1, N, 0 )
00283 *
00284             IF( WANTVL ) THEN
00285                CALL DHSEQR( 'S', 'V', N, 1, N, A, LDA, WR, WI, VL, LDVL,
00286      $                WORK, -1, INFO )
00287             ELSE IF( WANTVR ) THEN
00288                CALL DHSEQR( 'S', 'V', N, 1, N, A, LDA, WR, WI, VR, LDVR,
00289      $                WORK, -1, INFO )
00290             ELSE
00291                IF( WNTSNN ) THEN
00292                   CALL DHSEQR( 'E', 'N', N, 1, N, A, LDA, WR, WI, VR,
00293      $                LDVR, WORK, -1, INFO )
00294                ELSE
00295                   CALL DHSEQR( 'S', 'N', N, 1, N, A, LDA, WR, WI, VR,
00296      $                LDVR, WORK, -1, INFO )
00297                END IF
00298             END IF
00299             HSWORK = WORK( 1 )
00300 *
00301             IF( ( .NOT.WANTVL ) .AND. ( .NOT.WANTVR ) ) THEN
00302                MINWRK = 2*N
00303                IF( .NOT.WNTSNN )
00304      $            MINWRK = MAX( MINWRK, N*N+6*N )
00305                MAXWRK = MAX( MAXWRK, HSWORK )
00306                IF( .NOT.WNTSNN )
00307      $            MAXWRK = MAX( MAXWRK, N*N + 6*N )
00308             ELSE
00309                MINWRK = 3*N
00310                IF( ( .NOT.WNTSNN ) .AND. ( .NOT.WNTSNE ) )
00311      $            MINWRK = MAX( MINWRK, N*N + 6*N )
00312                MAXWRK = MAX( MAXWRK, HSWORK )
00313                MAXWRK = MAX( MAXWRK, N + ( N - 1 )*ILAENV( 1, 'DORGHR',
00314      $                       ' ', N, 1, N, -1 ) )
00315                IF( ( .NOT.WNTSNN ) .AND. ( .NOT.WNTSNE ) )
00316      $            MAXWRK = MAX( MAXWRK, N*N + 6*N )
00317                MAXWRK = MAX( MAXWRK, 3*N )
00318             END IF
00319             MAXWRK = MAX( MAXWRK, MINWRK )
00320          END IF
00321          WORK( 1 ) = MAXWRK
00322 *
00323          IF( LWORK.LT.MINWRK .AND. .NOT.LQUERY ) THEN
00324             INFO = -21
00325          END IF
00326       END IF
00327 *
00328       IF( INFO.NE.0 ) THEN
00329          CALL XERBLA( 'DGEEVX', -INFO )
00330          RETURN
00331       ELSE IF( LQUERY ) THEN
00332          RETURN
00333       END IF
00334 *
00335 *     Quick return if possible
00336 *
00337       IF( N.EQ.0 )
00338      $   RETURN
00339 *
00340 *     Get machine constants
00341 *
00342       EPS = DLAMCH( 'P' )
00343       SMLNUM = DLAMCH( 'S' )
00344       BIGNUM = ONE / SMLNUM
00345       CALL DLABAD( SMLNUM, BIGNUM )
00346       SMLNUM = SQRT( SMLNUM ) / EPS
00347       BIGNUM = ONE / SMLNUM
00348 *
00349 *     Scale A if max element outside range [SMLNUM,BIGNUM]
00350 *
00351       ICOND = 0
00352       ANRM = DLANGE( 'M', N, N, A, LDA, DUM )
00353       SCALEA = .FALSE.
00354       IF( ANRM.GT.ZERO .AND. ANRM.LT.SMLNUM ) THEN
00355          SCALEA = .TRUE.
00356          CSCALE = SMLNUM
00357       ELSE IF( ANRM.GT.BIGNUM ) THEN
00358          SCALEA = .TRUE.
00359          CSCALE = BIGNUM
00360       END IF
00361       IF( SCALEA )
00362      $   CALL DLASCL( 'G', 0, 0, ANRM, CSCALE, N, N, A, LDA, IERR )
00363 *
00364 *     Balance the matrix and compute ABNRM
00365 *
00366       CALL DGEBAL( BALANC, N, A, LDA, ILO, IHI, SCALE, IERR )
00367       ABNRM = DLANGE( '1', N, N, A, LDA, DUM )
00368       IF( SCALEA ) THEN
00369          DUM( 1 ) = ABNRM
00370          CALL DLASCL( 'G', 0, 0, CSCALE, ANRM, 1, 1, DUM, 1, IERR )
00371          ABNRM = DUM( 1 )
00372       END IF
00373 *
00374 *     Reduce to upper Hessenberg form
00375 *     (Workspace: need 2*N, prefer N+N*NB)
00376 *
00377       ITAU = 1
00378       IWRK = ITAU + N
00379       CALL DGEHRD( N, ILO, IHI, A, LDA, WORK( ITAU ), WORK( IWRK ),
00380      $             LWORK-IWRK+1, IERR )
00381 *
00382       IF( WANTVL ) THEN
00383 *
00384 *        Want left eigenvectors
00385 *        Copy Householder vectors to VL
00386 *
00387          SIDE = 'L'
00388          CALL DLACPY( 'L', N, N, A, LDA, VL, LDVL )
00389 *
00390 *        Generate orthogonal matrix in VL
00391 *        (Workspace: need 2*N-1, prefer N+(N-1)*NB)
00392 *
00393          CALL DORGHR( N, ILO, IHI, VL, LDVL, WORK( ITAU ), WORK( IWRK ),
00394      $                LWORK-IWRK+1, IERR )
00395 *
00396 *        Perform QR iteration, accumulating Schur vectors in VL
00397 *        (Workspace: need 1, prefer HSWORK (see comments) )
00398 *
00399          IWRK = ITAU
00400          CALL DHSEQR( 'S', 'V', N, ILO, IHI, A, LDA, WR, WI, VL, LDVL,
00401      $                WORK( IWRK ), LWORK-IWRK+1, INFO )
00402 *
00403          IF( WANTVR ) THEN
00404 *
00405 *           Want left and right eigenvectors
00406 *           Copy Schur vectors to VR
00407 *
00408             SIDE = 'B'
00409             CALL DLACPY( 'F', N, N, VL, LDVL, VR, LDVR )
00410          END IF
00411 *
00412       ELSE IF( WANTVR ) THEN
00413 *
00414 *        Want right eigenvectors
00415 *        Copy Householder vectors to VR
00416 *
00417          SIDE = 'R'
00418          CALL DLACPY( 'L', N, N, A, LDA, VR, LDVR )
00419 *
00420 *        Generate orthogonal matrix in VR
00421 *        (Workspace: need 2*N-1, prefer N+(N-1)*NB)
00422 *
00423          CALL DORGHR( N, ILO, IHI, VR, LDVR, WORK( ITAU ), WORK( IWRK ),
00424      $                LWORK-IWRK+1, IERR )
00425 *
00426 *        Perform QR iteration, accumulating Schur vectors in VR
00427 *        (Workspace: need 1, prefer HSWORK (see comments) )
00428 *
00429          IWRK = ITAU
00430          CALL DHSEQR( 'S', 'V', N, ILO, IHI, A, LDA, WR, WI, VR, LDVR,
00431      $                WORK( IWRK ), LWORK-IWRK+1, INFO )
00432 *
00433       ELSE
00434 *
00435 *        Compute eigenvalues only
00436 *        If condition numbers desired, compute Schur form
00437 *
00438          IF( WNTSNN ) THEN
00439             JOB = 'E'
00440          ELSE
00441             JOB = 'S'
00442          END IF
00443 *
00444 *        (Workspace: need 1, prefer HSWORK (see comments) )
00445 *
00446          IWRK = ITAU
00447          CALL DHSEQR( JOB, 'N', N, ILO, IHI, A, LDA, WR, WI, VR, LDVR,
00448      $                WORK( IWRK ), LWORK-IWRK+1, INFO )
00449       END IF
00450 *
00451 *     If INFO > 0 from DHSEQR, then quit
00452 *
00453       IF( INFO.GT.0 )
00454      $   GO TO 50
00455 *
00456       IF( WANTVL .OR. WANTVR ) THEN
00457 *
00458 *        Compute left and/or right eigenvectors
00459 *        (Workspace: need 3*N)
00460 *
00461          CALL DTREVC( SIDE, 'B', SELECT, N, A, LDA, VL, LDVL, VR, LDVR,
00462      $                N, NOUT, WORK( IWRK ), IERR )
00463       END IF
00464 *
00465 *     Compute condition numbers if desired
00466 *     (Workspace: need N*N+6*N unless SENSE = 'E')
00467 *
00468       IF( .NOT.WNTSNN ) THEN
00469          CALL DTRSNA( SENSE, 'A', SELECT, N, A, LDA, VL, LDVL, VR, LDVR,
00470      $                RCONDE, RCONDV, N, NOUT, WORK( IWRK ), N, IWORK,
00471      $                ICOND )
00472       END IF
00473 *
00474       IF( WANTVL ) THEN
00475 *
00476 *        Undo balancing of left eigenvectors
00477 *
00478          CALL DGEBAK( BALANC, 'L', N, ILO, IHI, SCALE, N, VL, LDVL,
00479      $                IERR )
00480 *
00481 *        Normalize left eigenvectors and make largest component real
00482 *
00483          DO 20 I = 1, N
00484             IF( WI( I ).EQ.ZERO ) THEN
00485                SCL = ONE / DNRM2( N, VL( 1, I ), 1 )
00486                CALL DSCAL( N, SCL, VL( 1, I ), 1 )
00487             ELSE IF( WI( I ).GT.ZERO ) THEN
00488                SCL = ONE / DLAPY2( DNRM2( N, VL( 1, I ), 1 ),
00489      $               DNRM2( N, VL( 1, I+1 ), 1 ) )
00490                CALL DSCAL( N, SCL, VL( 1, I ), 1 )
00491                CALL DSCAL( N, SCL, VL( 1, I+1 ), 1 )
00492                DO 10 K = 1, N
00493                   WORK( K ) = VL( K, I )**2 + VL( K, I+1 )**2
00494    10          CONTINUE
00495                K = IDAMAX( N, WORK, 1 )
00496                CALL DLARTG( VL( K, I ), VL( K, I+1 ), CS, SN, R )
00497                CALL DROT( N, VL( 1, I ), 1, VL( 1, I+1 ), 1, CS, SN )
00498                VL( K, I+1 ) = ZERO
00499             END IF
00500    20    CONTINUE
00501       END IF
00502 *
00503       IF( WANTVR ) THEN
00504 *
00505 *        Undo balancing of right eigenvectors
00506 *
00507          CALL DGEBAK( BALANC, 'R', N, ILO, IHI, SCALE, N, VR, LDVR,
00508      $                IERR )
00509 *
00510 *        Normalize right eigenvectors and make largest component real
00511 *
00512          DO 40 I = 1, N
00513             IF( WI( I ).EQ.ZERO ) THEN
00514                SCL = ONE / DNRM2( N, VR( 1, I ), 1 )
00515                CALL DSCAL( N, SCL, VR( 1, I ), 1 )
00516             ELSE IF( WI( I ).GT.ZERO ) THEN
00517                SCL = ONE / DLAPY2( DNRM2( N, VR( 1, I ), 1 ),
00518      $               DNRM2( N, VR( 1, I+1 ), 1 ) )
00519                CALL DSCAL( N, SCL, VR( 1, I ), 1 )
00520                CALL DSCAL( N, SCL, VR( 1, I+1 ), 1 )
00521                DO 30 K = 1, N
00522                   WORK( K ) = VR( K, I )**2 + VR( K, I+1 )**2
00523    30          CONTINUE
00524                K = IDAMAX( N, WORK, 1 )
00525                CALL DLARTG( VR( K, I ), VR( K, I+1 ), CS, SN, R )
00526                CALL DROT( N, VR( 1, I ), 1, VR( 1, I+1 ), 1, CS, SN )
00527                VR( K, I+1 ) = ZERO
00528             END IF
00529    40    CONTINUE
00530       END IF
00531 *
00532 *     Undo scaling if necessary
00533 *
00534    50 CONTINUE
00535       IF( SCALEA ) THEN
00536          CALL DLASCL( 'G', 0, 0, CSCALE, ANRM, N-INFO, 1, WR( INFO+1 ),
00537      $                MAX( N-INFO, 1 ), IERR )
00538          CALL DLASCL( 'G', 0, 0, CSCALE, ANRM, N-INFO, 1, WI( INFO+1 ),
00539      $                MAX( N-INFO, 1 ), IERR )
00540          IF( INFO.EQ.0 ) THEN
00541             IF( ( WNTSNV .OR. WNTSNB ) .AND. ICOND.EQ.0 )
00542      $         CALL DLASCL( 'G', 0, 0, CSCALE, ANRM, N, 1, RCONDV, N,
00543      $                      IERR )
00544          ELSE
00545             CALL DLASCL( 'G', 0, 0, CSCALE, ANRM, ILO-1, 1, WR, N,
00546      $                   IERR )
00547             CALL DLASCL( 'G', 0, 0, CSCALE, ANRM, ILO-1, 1, WI, N,
00548      $                   IERR )
00549          END IF
00550       END IF
00551 *
00552       WORK( 1 ) = MAXWRK
00553       RETURN
00554 *
00555 *     End of DGEEVX
00556 *
00557       END
 All Files Functions