View | Details | Raw Unified
Collapse All | Expand All

(-) LAPACK/BLAS/TESTING/cblat2.f (-2 / +6 lines)
 Lines 64-69    Link Here 
*     Richard Hanson, Sandia National Labs.
*     Richard Hanson, Sandia National Labs.
*     Jeremy Du Croz, NAG Central Office.
*     Jeremy Du Croz, NAG Central Office.
*
*
*     10-9-00:  Change STATUS='NEW' to 'UNKNOWN' so that the testers
*               can be run multiple times without deleting generated
*               output files (susan)
*
*     .. Parameters ..
*     .. Parameters ..
      INTEGER            NIN
      INTEGER            NIN
      PARAMETER          ( NIN = 5 )
      PARAMETER          ( NIN = 5 )
 Lines 126-132    Link Here 
*
*
      READ( NIN, FMT = * )SUMMRY
      READ( NIN, FMT = * )SUMMRY
      READ( NIN, FMT = * )NOUT
      READ( NIN, FMT = * )NOUT
      OPEN( NOUT, FILE = SUMMRY, STATUS = 'NEW' )
      OPEN( NOUT, FILE = SUMMRY, STATUS = 'UNKNOWN' )
      NOUTC = NOUT
      NOUTC = NOUT
*
*
*     Read name and unit number for snapshot output file and open file.
*     Read name and unit number for snapshot output file and open file.
 Lines 135-141    Link Here 
      READ( NIN, FMT = * )NTRA
      READ( NIN, FMT = * )NTRA
      TRACE = NTRA.GE.0
      TRACE = NTRA.GE.0
      IF( TRACE )THEN
      IF( TRACE )THEN
         OPEN( NTRA, FILE = SNAPS, STATUS = 'NEW' )
         OPEN( NTRA, FILE = SNAPS, STATUS = 'UNKNOWN' )
      END IF
      END IF
*     Read the flag that directs rewinding of the snapshot file.
*     Read the flag that directs rewinding of the snapshot file.
      READ( NIN, FMT = * )REWI
      READ( NIN, FMT = * )REWI
(-) LAPACK/BLAS/TESTING/cblat3.f (+4 lines)
 Lines 46-51    Link Here 
*     Jeremy Du Croz, Numerical Algorithms Group Ltd.
*     Jeremy Du Croz, Numerical Algorithms Group Ltd.
*     Sven Hammarling, Numerical Algorithms Group Ltd.
*     Sven Hammarling, Numerical Algorithms Group Ltd.
*
*
*     10-9-00:  Change STATUS='NEW' to 'UNKNOWN' so that the testers
*               can be run multiple times without deleting generated
*               output files (susan)
*
*     .. Parameters ..
*     .. Parameters ..
      INTEGER            NIN
      INTEGER            NIN
      PARAMETER          ( NIN = 5 )
      PARAMETER          ( NIN = 5 )
(-) LAPACK/BLAS/TESTING/dblat2.f (-2 / +6 lines)
 Lines 63-68    Link Here 
*     Richard Hanson, Sandia National Labs.
*     Richard Hanson, Sandia National Labs.
*     Jeremy Du Croz, NAG Central Office.
*     Jeremy Du Croz, NAG Central Office.
*
*
*     10-9-00:  Change STATUS='NEW' to 'UNKNOWN' so that the testers
*               can be run multiple times without deleting generated
*               output files (susan)
*
*     .. Parameters ..
*     .. Parameters ..
      INTEGER            NIN
      INTEGER            NIN
      PARAMETER          ( NIN = 5 )
      PARAMETER          ( NIN = 5 )
 Lines 121-127    Link Here 
*
*
      READ( NIN, FMT = * )SUMMRY
      READ( NIN, FMT = * )SUMMRY
      READ( NIN, FMT = * )NOUT
      READ( NIN, FMT = * )NOUT
      OPEN( NOUT, FILE = SUMMRY, STATUS = 'NEW' )
      OPEN( NOUT, FILE = SUMMRY, STATUS = 'UNKNOWN' )
      NOUTC = NOUT
      NOUTC = NOUT
*
*
*     Read name and unit number for snapshot output file and open file.
*     Read name and unit number for snapshot output file and open file.
 Lines 130-136    Link Here 
      READ( NIN, FMT = * )NTRA
      READ( NIN, FMT = * )NTRA
      TRACE = NTRA.GE.0
      TRACE = NTRA.GE.0
      IF( TRACE )THEN
      IF( TRACE )THEN
         OPEN( NTRA, FILE = SNAPS, STATUS = 'NEW' )
         OPEN( NTRA, FILE = SNAPS, STATUS = 'UNKNOWN' )
      END IF
      END IF
*     Read the flag that directs rewinding of the snapshot file.
*     Read the flag that directs rewinding of the snapshot file.
      READ( NIN, FMT = * )REWI
      READ( NIN, FMT = * )REWI
(-) LAPACK/BLAS/TESTING/dblat3.f (-2 / +6 lines)
 Lines 43-48    Link Here 
*     Jeremy Du Croz, Numerical Algorithms Group Ltd.
*     Jeremy Du Croz, Numerical Algorithms Group Ltd.
*     Sven Hammarling, Numerical Algorithms Group Ltd.
*     Sven Hammarling, Numerical Algorithms Group Ltd.
*
*
*     10-9-00:  Change STATUS='NEW' to 'UNKNOWN' so that the testers
*               can be run multiple times without deleting generated
*               output files (susan)
*
*     .. Parameters ..
*     .. Parameters ..
      INTEGER            NIN
      INTEGER            NIN
      PARAMETER          ( NIN = 5 )
      PARAMETER          ( NIN = 5 )
 Lines 96-102    Link Here 
*
*
      READ( NIN, FMT = * )SUMMRY
      READ( NIN, FMT = * )SUMMRY
      READ( NIN, FMT = * )NOUT
      READ( NIN, FMT = * )NOUT
      OPEN( NOUT, FILE = SUMMRY, STATUS = 'NEW' )
      OPEN( NOUT, FILE = SUMMRY, STATUS = 'UNKNOWN' )
      NOUTC = NOUT
      NOUTC = NOUT
*
*
*     Read name and unit number for snapshot output file and open file.
*     Read name and unit number for snapshot output file and open file.
 Lines 105-111    Link Here 
      READ( NIN, FMT = * )NTRA
      READ( NIN, FMT = * )NTRA
      TRACE = NTRA.GE.0
      TRACE = NTRA.GE.0
      IF( TRACE )THEN
      IF( TRACE )THEN
         OPEN( NTRA, FILE = SNAPS, STATUS = 'NEW' )
         OPEN( NTRA, FILE = SNAPS, STATUS = 'UNKNOWN' )
      END IF
      END IF
*     Read the flag that directs rewinding of the snapshot file.
*     Read the flag that directs rewinding of the snapshot file.
      READ( NIN, FMT = * )REWI
      READ( NIN, FMT = * )REWI
(-) LAPACK/BLAS/TESTING/sblat2.f (-2 / +6 lines)
 Lines 63-68    Link Here 
*     Richard Hanson, Sandia National Labs.
*     Richard Hanson, Sandia National Labs.
*     Jeremy Du Croz, NAG Central Office.
*     Jeremy Du Croz, NAG Central Office.
*
*
*     10-9-00:  Change STATUS='NEW' to 'UNKNOWN' so that the testers
*               can be run multiple times without deleting generated
*               output files (susan)
*
*     .. Parameters ..
*     .. Parameters ..
      INTEGER            NIN
      INTEGER            NIN
      PARAMETER          ( NIN = 5 )
      PARAMETER          ( NIN = 5 )
 Lines 121-127    Link Here 
*
*
      READ( NIN, FMT = * )SUMMRY
      READ( NIN, FMT = * )SUMMRY
      READ( NIN, FMT = * )NOUT
      READ( NIN, FMT = * )NOUT
      OPEN( NOUT, FILE = SUMMRY, STATUS = 'NEW' )
      OPEN( NOUT, FILE = SUMMRY, STATUS = 'UNKNOWN' )
      NOUTC = NOUT
      NOUTC = NOUT
*
*
*     Read name and unit number for snapshot output file and open file.
*     Read name and unit number for snapshot output file and open file.
 Lines 130-136    Link Here 
      READ( NIN, FMT = * )NTRA
      READ( NIN, FMT = * )NTRA
      TRACE = NTRA.GE.0
      TRACE = NTRA.GE.0
      IF( TRACE )THEN
      IF( TRACE )THEN
         OPEN( NTRA, FILE = SNAPS, STATUS = 'NEW' )
         OPEN( NTRA, FILE = SNAPS, STATUS = 'UNKNOWN' )
      END IF
      END IF
*     Read the flag that directs rewinding of the snapshot file.
*     Read the flag that directs rewinding of the snapshot file.
      READ( NIN, FMT = * )REWI
      READ( NIN, FMT = * )REWI
(-) LAPACK/BLAS/TESTING/sblat3.f (+4 lines)
 Lines 43-48    Link Here 
*     Jeremy Du Croz, Numerical Algorithms Group Ltd.
*     Jeremy Du Croz, Numerical Algorithms Group Ltd.
*     Sven Hammarling, Numerical Algorithms Group Ltd.
*     Sven Hammarling, Numerical Algorithms Group Ltd.
*
*
*     10-9-00:  Change STATUS='NEW' to 'UNKNOWN' so that the testers
*               can be run multiple times without deleting generated
*               output files (susan)
*
*     .. Parameters ..
*     .. Parameters ..
      INTEGER            NIN
      INTEGER            NIN
      PARAMETER          ( NIN = 5 )
      PARAMETER          ( NIN = 5 )
(-) LAPACK/BLAS/TESTING/zblat2.f (-2 / +6 lines)
 Lines 64-69    Link Here 
*     Richard Hanson, Sandia National Labs.
*     Richard Hanson, Sandia National Labs.
*     Jeremy Du Croz, NAG Central Office.
*     Jeremy Du Croz, NAG Central Office.
*
*
*     10-9-00:  Change STATUS='NEW' to 'UNKNOWN' so that the testers
*               can be run multiple times without deleting generated
*               output files (susan)
*
*     .. Parameters ..
*     .. Parameters ..
      INTEGER            NIN
      INTEGER            NIN
      PARAMETER          ( NIN = 5 )
      PARAMETER          ( NIN = 5 )
 Lines 127-133    Link Here 
*
*
      READ( NIN, FMT = * )SUMMRY
      READ( NIN, FMT = * )SUMMRY
      READ( NIN, FMT = * )NOUT
      READ( NIN, FMT = * )NOUT
      OPEN( NOUT, FILE = SUMMRY, STATUS = 'NEW' )
      OPEN( NOUT, FILE = SUMMRY, STATUS = 'UNKNOWN' )
      NOUTC = NOUT
      NOUTC = NOUT
*
*
*     Read name and unit number for snapshot output file and open file.
*     Read name and unit number for snapshot output file and open file.
 Lines 136-142    Link Here 
      READ( NIN, FMT = * )NTRA
      READ( NIN, FMT = * )NTRA
      TRACE = NTRA.GE.0
      TRACE = NTRA.GE.0
      IF( TRACE )THEN
      IF( TRACE )THEN
         OPEN( NTRA, FILE = SNAPS, STATUS = 'NEW' )
         OPEN( NTRA, FILE = SNAPS, STATUS = 'UNKNOWN' )
      END IF
      END IF
*     Read the flag that directs rewinding of the snapshot file.
*     Read the flag that directs rewinding of the snapshot file.
      READ( NIN, FMT = * )REWI
      READ( NIN, FMT = * )REWI
(-) LAPACK/BLAS/TESTING/zblat3.f (-2 / +9 lines)
 Lines 46-51    Link Here 
*     Jeremy Du Croz, Numerical Algorithms Group Ltd.
*     Jeremy Du Croz, Numerical Algorithms Group Ltd.
*     Sven Hammarling, Numerical Algorithms Group Ltd.
*     Sven Hammarling, Numerical Algorithms Group Ltd.
*
*
*     10-9-00:  Change STATUS='NEW' to 'UNKNOWN' so that the testers
*               can be run multiple times without deleting generated
*               output files (susan)
*
*     .. Parameters ..
*     .. Parameters ..
      INTEGER            NIN
      INTEGER            NIN
      PARAMETER          ( NIN = 5 )
      PARAMETER          ( NIN = 5 )
 Lines 104-110    Link Here 
*
*
      READ( NIN, FMT = * )SUMMRY
      READ( NIN, FMT = * )SUMMRY
      READ( NIN, FMT = * )NOUT
      READ( NIN, FMT = * )NOUT
      OPEN( NOUT, FILE = SUMMRY, STATUS = 'NEW' )
      OPEN( NOUT, FILE = SUMMRY, STATUS = 'UNKNOWN' )
      NOUTC = NOUT
      NOUTC = NOUT
*
*
*     Read name and unit number for snapshot output file and open file.
*     Read name and unit number for snapshot output file and open file.
 Lines 113-119    Link Here 
      READ( NIN, FMT = * )NTRA
      READ( NIN, FMT = * )NTRA
      TRACE = NTRA.GE.0
      TRACE = NTRA.GE.0
      IF( TRACE )THEN
      IF( TRACE )THEN
         OPEN( NTRA, FILE = SNAPS, STATUS = 'NEW' )
         OPEN( NTRA, FILE = SNAPS, STATUS = 'UNKNOWN' )
      END IF
      END IF
*     Read the flag that directs rewinding of the snapshot file.
*     Read the flag that directs rewinding of the snapshot file.
      READ( NIN, FMT = * )REWI
      READ( NIN, FMT = * )REWI
 Lines 1962-1967    Link Here 
*  3-19-92:  Initialize ALPHA, BETA, RALPHA, and RBETA  (eca)
*  3-19-92:  Initialize ALPHA, BETA, RALPHA, and RBETA  (eca)
*  3-19-92:  Fix argument 12 in calls to ZSYMM and ZHEMM
*  3-19-92:  Fix argument 12 in calls to ZSYMM and ZHEMM
*            with INFOT = 9  (eca)
*            with INFOT = 9  (eca)
*  10-9-00:  Declared INTRINSIC DCMPLX (susan)
*
*
*     .. Scalar Arguments ..
*     .. Scalar Arguments ..
      INTEGER            ISNUM, NOUT
      INTEGER            ISNUM, NOUT
 Lines 1980-1985    Link Here 
*     .. External Subroutines ..
*     .. External Subroutines ..
      EXTERNAL           ZGEMM, ZHEMM, ZHER2K, ZHERK, CHKXER, ZSYMM,
      EXTERNAL           ZGEMM, ZHEMM, ZHER2K, ZHERK, CHKXER, ZSYMM,
     $                   ZSYR2K, ZSYRK, ZTRMM, ZTRSM
     $                   ZSYR2K, ZSYRK, ZTRMM, ZTRSM
*     .. Intrinsic Functions ..
      INTRINSIC          DCMPLX
*     .. Common blocks ..
*     .. Common blocks ..
      COMMON             /INFOC/INFOT, NOUTC, OK, LERR
      COMMON             /INFOC/INFOT, NOUTC, OK, LERR
*     .. Executable Statements ..
*     .. Executable Statements ..
(-) LAPACK/INSTALL/make.inc.LINUX (-1 / +1 lines)
 Lines 17-23    Link Here 
#  desired load options for your machine.
#  desired load options for your machine.
#
#
FORTRAN  = g77 
FORTRAN  = g77 
OPTS     = -funroll-all-loops -fno-f2c -O3
OPTS     = -funroll-all-loops -O3
DRVOPTS  = $(OPTS)
DRVOPTS  = $(OPTS)
NOOPT    =
NOOPT    =
LOADER   = g77
LOADER   = g77
(-) LAPACK/SRC/cbdsqr.f (-19 / +31 lines)
 Lines 4-10    Link Here 
*  -- LAPACK routine (version 3.0) --
*  -- LAPACK routine (version 3.0) --
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Courant Institute, Argonne National Lab, and Rice University
*     Courant Institute, Argonne National Lab, and Rice University
*     October 31, 1999
*     April 25, 2001
*
*
*     .. Scalar Arguments ..
*     .. Scalar Arguments ..
      CHARACTER          UPLO
      CHARACTER          UPLO
 Lines 18-31    Link Here 
*  Purpose
*  Purpose
*  =======
*  =======
*
*
*  CBDSQR computes the singular value decomposition (SVD) of a real
*  CBDSQR computes the singular values and, optionally, the right and/or
*  N-by-N (upper or lower) bidiagonal matrix B:  B = Q * S * P' (P'
*  left singular vectors from the singular value decomposition (SVD) of
*  denotes the transpose of P), where S is a diagonal matrix with
*  a real N-by-N (upper or lower) bidiagonal matrix B using the implicit
*  non-negative diagonal elements (the singular values of B), and Q
*  zero-shift QR algorithm.  The SVD of B has the form
*  and P are orthogonal matrices.
*  
*
*     B = Q * S * P**H
*  The routine computes S, and optionally computes U * Q, P' * VT,
*  
*  or Q' * C, for given complex input matrices U, VT, and C.
*  where S is the diagonal matrix of singular values, Q is an orthogonal
*  matrix of left singular vectors, and P is an orthogonal matrix of
*  right singular vectors.  If left singular vectors are requested, this
*  subroutine actually returns U*Q instead of Q, and, if right singular
*  vectors are requested, this subroutine returns P**H*VT instead of
*  P**H, for given complex input matrices U and VT.  When U and VT are
*  the unitary matrices that reduce a general matrix A to bidiagonal
*  form: A = U*B*VT, as computed by CGEBRD, then
*  
*     A = (U*Q) * S * (P**H*VT)
*  
*  is the SVD of A.  Optionally, the subroutine may also compute Q**H*C
*  for a given complex input matrix C.
*
*
*  See "Computing  Small Singular Values of Bidiagonal Matrices With
*  See "Computing  Small Singular Values of Bidiagonal Matrices With
*  Guaranteed High Relative Accuracy," by J. Demmel and W. Kahan,
*  Guaranteed High Relative Accuracy," by J. Demmel and W. Kahan,
 Lines 61-78    Link Here 
*          order.
*          order.
*
*
*  E       (input/output) REAL array, dimension (N)
*  E       (input/output) REAL array, dimension (N)
*          On entry, the elements of E contain the
*          On entry, the N-1 offdiagonal elements of the bidiagonal
*          offdiagonal elements of of the bidiagonal matrix whose SVD
*          matrix B.
*          is desired. On normal exit (INFO = 0), E is destroyed.
*          On exit, if INFO = 0, E is destroyed; if INFO > 0, D and E
*          If the algorithm does not converge (INFO > 0), D and E
*          will contain the diagonal and superdiagonal elements of a
*          will contain the diagonal and superdiagonal elements of a
*          bidiagonal matrix orthogonally equivalent to the one given
*          bidiagonal matrix orthogonally equivalent to the one given
*          as input. E(N) is used for workspace.
*          as input. E(N) is used for workspace.
*
*
*  VT      (input/output) COMPLEX array, dimension (LDVT, NCVT)
*  VT      (input/output) COMPLEX array, dimension (LDVT, NCVT)
*          On entry, an N-by-NCVT matrix VT.
*          On entry, an N-by-NCVT matrix VT.
*          On exit, VT is overwritten by P' * VT.
*          On exit, VT is overwritten by P**H * VT.
*          VT is not referenced if NCVT = 0.
*          Not referenced if NCVT = 0.
*
*
*  LDVT    (input) INTEGER
*  LDVT    (input) INTEGER
*          The leading dimension of the array VT.
*          The leading dimension of the array VT.
 Lines 81-101    Link Here 
*  U       (input/output) COMPLEX array, dimension (LDU, N)
*  U       (input/output) COMPLEX array, dimension (LDU, N)
*          On entry, an NRU-by-N matrix U.
*          On entry, an NRU-by-N matrix U.
*          On exit, U is overwritten by U * Q.
*          On exit, U is overwritten by U * Q.
*          U is not referenced if NRU = 0.
*          Not referenced if NRU = 0.
*
*
*  LDU     (input) INTEGER
*  LDU     (input) INTEGER
*          The leading dimension of the array U.  LDU >= max(1,NRU).
*          The leading dimension of the array U.  LDU >= max(1,NRU).
*
*
*  C       (input/output) COMPLEX array, dimension (LDC, NCC)
*  C       (input/output) COMPLEX array, dimension (LDC, NCC)
*          On entry, an N-by-NCC matrix C.
*          On entry, an N-by-NCC matrix C.
*          On exit, C is overwritten by Q' * C.
*          On exit, C is overwritten by Q**H * C.
*          C is not referenced if NCC = 0.
*          Not referenced if NCC = 0.
*
*
*  LDC     (input) INTEGER
*  LDC     (input) INTEGER
*          The leading dimension of the array C.
*          The leading dimension of the array C.
*          LDC >= max(1,N) if NCC > 0; LDC >=1 if NCC = 0.
*          LDC >= max(1,N) if NCC > 0; LDC >=1 if NCC = 0.
*
*
*  RWORK   (workspace) REAL array, dimension (4*N)
*  RWORK   (workspace) REAL array, dimension (2*N) 
*          if NCVT = NRU = NCC = 0, (max(1, 4*N-4)) otherwise
*
*
*  INFO    (output) INTEGER
*  INFO    (output) INTEGER
*          = 0:  successful exit
*          = 0:  successful exit
(-) LAPACK/SRC/cgebd2.f (-5 / +7 lines)
 Lines 3-9    Link Here 
*  -- LAPACK routine (version 3.0) --
*  -- LAPACK routine (version 3.0) --
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Courant Institute, Argonne National Lab, and Rice University
*     Courant Institute, Argonne National Lab, and Rice University
*     September 30, 1994
*     May 7, 2001
*
*
*     .. Scalar Arguments ..
*     .. Scalar Arguments ..
      INTEGER            INFO, LDA, M, N
      INTEGER            INFO, LDA, M, N
 Lines 172-179    Link Here 
*
*
*           Apply H(i)' to A(i:m,i+1:n) from the left
*           Apply H(i)' to A(i:m,i+1:n) from the left
*
*
            CALL CLARF( 'Left', M-I+1, N-I, A( I, I ), 1,
            IF( I.LT.N )
     $                  CONJG( TAUQ( I ) ), A( I, I+1 ), LDA, WORK )
     $         CALL CLARF( 'Left', M-I+1, N-I, A( I, I ), 1,
     $                     CONJG( TAUQ( I ) ), A( I, I+1 ), LDA, WORK )
            A( I, I ) = D( I )
            A( I, I ) = D( I )
*
*
            IF( I.LT.N ) THEN
            IF( I.LT.N ) THEN
 Lines 215-222    Link Here 
*
*
*           Apply G(i) to A(i+1:m,i:n) from the right
*           Apply G(i) to A(i+1:m,i:n) from the right
*
*
            CALL CLARF( 'Right', M-I, N-I+1, A( I, I ), LDA, TAUP( I ),
            IF( I.LT.M )
     $                  A( MIN( I+1, M ), I ), LDA, WORK )
     $         CALL CLARF( 'Right', M-I, N-I+1, A( I, I ), LDA,
     $                     TAUP( I ), A( MIN( I+1, M ), I ), LDA, WORK )
            CALL CLACGV( N-I+1, A( I, I ), LDA )
            CALL CLACGV( N-I+1, A( I, I ), LDA )
            A( I, I ) = D( I )
            A( I, I ) = D( I )
*
*
(-) LAPACK/SRC/cgees.f (-15 / +14 lines)
 Lines 5-10    Link Here 
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Courant Institute, Argonne National Lab, and Rice University
*     Courant Institute, Argonne National Lab, and Rice University
*     June 30, 1999
*     June 30, 1999
*     8-15-00:  Improve consistency of WS calculations (eca)
*
*
*     .. Scalar Arguments ..
*     .. Scalar Arguments ..
      CHARACTER          JOBVS, SORT
      CHARACTER          JOBVS, SORT
 Lines 89-98    Link Here 
*          The dimension of the array WORK.  LWORK >= max(1,2*N).
*          The dimension of the array WORK.  LWORK >= max(1,2*N).
*          For good performance, LWORK must generally be larger.
*          For good performance, LWORK must generally be larger.
*
*
*          If LWORK = -1, then a workspace query is assumed; the routine
*          If LWORK = -1, a workspace query is assumed.  The optimal
*          only calculates the optimal size of the WORK array, returns
*          size for the WORK array is calculated and stored in WORK(1),
*          this value as the first entry of the WORK array, and no error
*          and no other work except argument checking is performed.
*          message related to LWORK is issued by XERBLA.
*
*
*  RWORK   (workspace) REAL array, dimension (N)
*  RWORK   (workspace) REAL array, dimension (N)
*
*
 Lines 120-130    Link Here 
*  =====================================================================
*  =====================================================================
*
*
*     .. Parameters ..
*     .. Parameters ..
      INTEGER            LQUERV
      PARAMETER          ( LQUERV = -1 )
      REAL               ZERO, ONE
      REAL               ZERO, ONE
      PARAMETER          ( ZERO = 0.0E0, ONE = 1.0E0 )
      PARAMETER          ( ZERO = 0.0E0, ONE = 1.0E0 )
*     ..
*     ..
*     .. Local Scalars ..
*     .. Local Scalars ..
      LOGICAL            LQUERY, SCALEA, WANTST, WANTVS
      LOGICAL            SCALEA, WANTST, WANTVS
      INTEGER            HSWORK, I, IBAL, ICOND, IERR, IEVAL, IHI, ILO,
      INTEGER            HSWORK, I, IBAL, ICOND, IERR, IEVAL, IHI, ILO,
     $                   ITAU, IWRK, K, MAXB, MAXWRK, MINWRK
     $                   ITAU, IWRK, K, MAXB, MAXWRK, MINWRK
      REAL               ANRM, BIGNUM, CSCALE, EPS, S, SEP, SMLNUM
      REAL               ANRM, BIGNUM, CSCALE, EPS, S, SEP, SMLNUM
 Lines 150-156    Link Here 
*     Test the input arguments
*     Test the input arguments
*
*
      INFO = 0
      INFO = 0
      LQUERY = ( LWORK.EQ.-1 )
      WANTVS = LSAME( JOBVS, 'V' )
      WANTVS = LSAME( JOBVS, 'V' )
      WANTST = LSAME( SORT, 'S' )
      WANTST = LSAME( SORT, 'S' )
      IF( ( .NOT.WANTVS ) .AND. ( .NOT.LSAME( JOBVS, 'N' ) ) ) THEN
      IF( ( .NOT.WANTVS ) .AND. ( .NOT.LSAME( JOBVS, 'N' ) ) ) THEN
 Lines 177-183    Link Here 
*       the worst case.)
*       the worst case.)
*
*
      MINWRK = 1
      MINWRK = 1
      IF( INFO.EQ.0 .AND. ( LWORK.GE.1 .OR. LQUERY ) ) THEN
      IF( INFO.EQ.0 ) THEN
         MAXWRK = N + N*ILAENV( 1, 'CGEHRD', ' ', N, 1, N, 0 )
         MAXWRK = N + N*ILAENV( 1, 'CGEHRD', ' ', N, 1, N, 0 )
         MINWRK = MAX( 1, 2*N )
         MINWRK = MAX( 1, 2*N )
         IF( .NOT.WANTVS ) THEN
         IF( .NOT.WANTVS ) THEN
 Lines 196-214    Link Here 
            MAXWRK = MAX( MAXWRK, HSWORK, 1 )
            MAXWRK = MAX( MAXWRK, HSWORK, 1 )
         END IF
         END IF
         WORK( 1 ) = MAXWRK
         WORK( 1 ) = MAXWRK
         IF( LWORK.LT.MINWRK .AND. LWORK.NE.LQUERV )
     $      INFO = -12
      END IF
      END IF
      IF( LWORK.LT.MINWRK .AND. .NOT.LQUERY ) THEN
*
         INFO = -12
*     Quick returns
      END IF
*
      IF( INFO.NE.0 ) THEN
      IF( INFO.NE.0 ) THEN
         CALL XERBLA( 'CGEES ', -INFO )
         CALL XERBLA( 'CGEES ', -INFO )
         RETURN
         RETURN
      ELSE IF( LQUERY ) THEN
         RETURN
      END IF
      END IF
*
      IF( LWORK.EQ.LQUERV ) RETURN
*     Quick return if possible
*
      IF( N.EQ.0 ) THEN
      IF( N.EQ.0 ) THEN
         SDIM = 0
         SDIM = 0
         RETURN
         RETURN
(-) LAPACK/SRC/cgeesx.f (-7 / +20 lines)
 Lines 6-11    Link Here 
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Courant Institute, Argonne National Lab, and Rice University
*     Courant Institute, Argonne National Lab, and Rice University
*     June 30, 1999
*     June 30, 1999
*     8-15-00:  Do WS calculations if LWORK = -1 (eca)
*
*
*     .. Scalar Arguments ..
*     .. Scalar Arguments ..
      CHARACTER          JOBVS, SENSE, SORT
      CHARACTER          JOBVS, SENSE, SORT
 Lines 119-124    Link Here 
*          this routine.  Note that 2*SDIM*(N-SDIM) <= N*N/2.
*          this routine.  Note that 2*SDIM*(N-SDIM) <= N*N/2.
*          For good performance, LWORK must generally be larger.
*          For good performance, LWORK must generally be larger.
*
*
*          If LWORK = -1, a workspace query is assumed.  The optimal
*          size for the WORK array is calculated and stored in WORK(1),
*          and no other work except argument checking is performed.
*
*  RWORK   (workspace) REAL array, dimension (N)
*  RWORK   (workspace) REAL array, dimension (N)
*
*
*  BWORK   (workspace) LOGICAL array, dimension (N)
*  BWORK   (workspace) LOGICAL array, dimension (N)
 Lines 144-149    Link Here 
*  =====================================================================
*  =====================================================================
*
*
*     .. Parameters ..
*     .. Parameters ..
      INTEGER            LQUERV
      PARAMETER          ( LQUERV = -1 )
      REAL               ZERO, ONE
      REAL               ZERO, ONE
      PARAMETER          ( ZERO = 0.0E0, ONE = 1.0E0 )
      PARAMETER          ( ZERO = 0.0E0, ONE = 1.0E0 )
*     ..
*     ..
 Lines 211-217    Link Here 
*       in the code.)
*       in the code.)
*
*
      MINWRK = 1
      MINWRK = 1
      IF( INFO.EQ.0 .AND. ( LWORK.GE.1 ) ) THEN
      IF( INFO.EQ.0 ) THEN
         MAXWRK = N + N*ILAENV( 1, 'CGEHRD', ' ', N, 1, N, 0 )
         MAXWRK = N + N*ILAENV( 1, 'CGEHRD', ' ', N, 1, N, 0 )
         MINWRK = MAX( 1, 2*N )
         MINWRK = MAX( 1, 2*N )
         IF( .NOT.WANTVS ) THEN
         IF( .NOT.WANTVS ) THEN
 Lines 229-246    Link Here 
            HSWORK = MAX( K*( K+2 ), 2*N )
            HSWORK = MAX( K*( K+2 ), 2*N )
            MAXWRK = MAX( MAXWRK, HSWORK, 1 )
            MAXWRK = MAX( MAXWRK, HSWORK, 1 )
         END IF
         END IF
*
*        Estimate the workspace needed by CTRSEN.
*
         IF( WANTST ) THEN
            MAXWRK = MAX( MAXWRK, (N*N+1)/2 )
         END IF
         WORK( 1 ) = MAXWRK
         WORK( 1 ) = MAXWRK
         IF( LWORK.LT.MINWRK .AND. LWORK.NE.LQUERV )
     &      INFO = -15
      END IF
      END IF
      IF( LWORK.LT.MINWRK ) THEN
*
         INFO = -15
*     Quick returns
      END IF
*
      IF( INFO.NE.0 ) THEN
      IF( INFO.NE.0 ) THEN
         CALL XERBLA( 'CGEESX', -INFO )
         CALL XERBLA( 'CGEESX', -INFO )
         RETURN
         RETURN
      END IF
      END IF
*
      IF( LWORK.EQ.LQUERV ) RETURN
*     Quick return if possible
*
      IF( N.EQ.0 ) THEN
      IF( N.EQ.0 ) THEN
         SDIM = 0
         SDIM = 0
         RETURN
         RETURN
(-) LAPACK/SRC/cgeev.f (-15 / +14 lines)
 Lines 5-10    Link Here 
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Courant Institute, Argonne National Lab, and Rice University
*     Courant Institute, Argonne National Lab, and Rice University
*     June 30, 1999
*     June 30, 1999
*     8-15-00:  Improve consistency of WS calculations (eca)
*
*
*     .. Scalar Arguments ..
*     .. Scalar Arguments ..
      CHARACTER          JOBVL, JOBVR
      CHARACTER          JOBVL, JOBVR
 Lines 85-94    Link Here 
*          The dimension of the array WORK.  LWORK >= max(1,2*N).
*          The dimension of the array WORK.  LWORK >= max(1,2*N).
*          For good performance, LWORK must generally be larger.
*          For good performance, LWORK must generally be larger.
*
*
*          If LWORK = -1, then a workspace query is assumed; the routine
*          If LWORK = -1, a workspace query is assumed.  The optimal
*          only calculates the optimal size of the WORK array, returns
*          size for the WORK array is calculated and stored in WORK(1),
*          this value as the first entry of the WORK array, and no error
*          and no other work except argument checking is performed.
*          message related to LWORK is issued by XERBLA.
*
*
*  RWORK   (workspace) REAL array, dimension (2*N)
*  RWORK   (workspace) REAL array, dimension (2*N)
*
*
 Lines 103-113    Link Here 
*  =====================================================================
*  =====================================================================
*
*
*     .. Parameters ..
*     .. Parameters ..
      INTEGER            LQUERV
      PARAMETER          ( LQUERV = -1 )
      REAL               ZERO, ONE
      REAL               ZERO, ONE
      PARAMETER          ( ZERO = 0.0E0, ONE = 1.0E0 )
      PARAMETER          ( ZERO = 0.0E0, ONE = 1.0E0 )
*     ..
*     ..
*     .. Local Scalars ..
*     .. Local Scalars ..
      LOGICAL            LQUERY, SCALEA, WANTVL, WANTVR
      LOGICAL            SCALEA, WANTVL, WANTVR
      CHARACTER          SIDE
      CHARACTER          SIDE
      INTEGER            HSWORK, I, IBAL, IERR, IHI, ILO, IRWORK, ITAU,
      INTEGER            HSWORK, I, IBAL, IERR, IHI, ILO, IRWORK, ITAU,
     $                   IWRK, K, MAXB, MAXWRK, MINWRK, NOUT
     $                   IWRK, K, MAXB, MAXWRK, MINWRK, NOUT
 Lines 136-142    Link Here 
*     Test the input arguments
*     Test the input arguments
*
*
      INFO = 0
      INFO = 0
      LQUERY = ( LWORK.EQ.-1 )
      WANTVL = LSAME( JOBVL, 'V' )
      WANTVL = LSAME( JOBVL, 'V' )
      WANTVR = LSAME( JOBVR, 'V' )
      WANTVR = LSAME( JOBVR, 'V' )
      IF( ( .NOT.WANTVL ) .AND. ( .NOT.LSAME( JOBVL, 'N' ) ) ) THEN
      IF( ( .NOT.WANTVL ) .AND. ( .NOT.LSAME( JOBVL, 'N' ) ) ) THEN
 Lines 165-171    Link Here 
*       the worst case.)
*       the worst case.)
*
*
      MINWRK = 1
      MINWRK = 1
      IF( INFO.EQ.0 .AND. ( LWORK.GE.1 .OR. LQUERY ) ) THEN
      IF( INFO.EQ.0 ) THEN
         MAXWRK = N + N*ILAENV( 1, 'CGEHRD', ' ', N, 1, N, 0 )
         MAXWRK = N + N*ILAENV( 1, 'CGEHRD', ' ', N, 1, N, 0 )
         IF( ( .NOT.WANTVL ) .AND. ( .NOT.WANTVR ) ) THEN
         IF( ( .NOT.WANTVL ) .AND. ( .NOT.WANTVR ) ) THEN
            MINWRK = MAX( 1, 2*N )
            MINWRK = MAX( 1, 2*N )
 Lines 185-203    Link Here 
            MAXWRK = MAX( MAXWRK, HSWORK, 2*N )
            MAXWRK = MAX( MAXWRK, HSWORK, 2*N )
         END IF
         END IF
         WORK( 1 ) = MAXWRK
         WORK( 1 ) = MAXWRK
         IF( LWORK.LT.MINWRK .AND. LWORK.NE.LQUERV )
     $      INFO = -12
      END IF
      END IF
      IF( LWORK.LT.MINWRK .AND. .NOT.LQUERY ) THEN
*
         INFO = -12
*     Quick returns
      END IF
*
      IF( INFO.NE.0 ) THEN
      IF( INFO.NE.0 ) THEN
         CALL XERBLA( 'CGEEV ', -INFO )
         CALL XERBLA( 'CGEEV ', -INFO )
         RETURN
         RETURN
      ELSE IF( LQUERY ) THEN
         RETURN
      END IF
      END IF
*
      IF( LWORK.EQ.LQUERV ) RETURN
*     Quick return if possible
*
      IF( N.EQ.0 )
      IF( N.EQ.0 )
     $   RETURN
     $   RETURN
*
*
(-) LAPACK/SRC/cgeevx.f (-16 / +15 lines)
 Lines 6-11    Link Here 
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Courant Institute, Argonne National Lab, and Rice University
*     Courant Institute, Argonne National Lab, and Rice University
*     June 30, 1999
*     June 30, 1999
*     8-15-00:  Improve consistency of WS calculations (eca)
*
*
*     .. Scalar Arguments ..
*     .. Scalar Arguments ..
      CHARACTER          BALANC, JOBVL, JOBVR, SENSE
      CHARACTER          BALANC, JOBVL, JOBVR, SENSE
 Lines 166-175    Link Here 
*          LWORK >= N*N+2*N.
*          LWORK >= N*N+2*N.
*          For good performance, LWORK must generally be larger.
*          For good performance, LWORK must generally be larger.
*
*
*          If LWORK = -1, then a workspace query is assumed; the routine
*          If LWORK = -1, a workspace query is assumed.  The optimal
*          only calculates the optimal size of the WORK array, returns
*          size for the WORK array is calculated and stored in WORK(1),
*          this value as the first entry of the WORK array, and no error
*          and no other work except argument checking is performed.
*          message related to LWORK is issued by XERBLA.
*
*
*  RWORK   (workspace) REAL array, dimension (2*N)
*  RWORK   (workspace) REAL array, dimension (2*N)
*
*
 Lines 184-195    Link Here 
*  =====================================================================
*  =====================================================================
*
*
*     .. Parameters ..
*     .. Parameters ..
      INTEGER            LQUERV
      PARAMETER          ( LQUERV = -1 )
      REAL               ZERO, ONE
      REAL               ZERO, ONE
      PARAMETER          ( ZERO = 0.0E0, ONE = 1.0E0 )
      PARAMETER          ( ZERO = 0.0E0, ONE = 1.0E0 )
*     ..
*     ..
*     .. Local Scalars ..
*     .. Local Scalars ..
      LOGICAL            LQUERY, SCALEA, WANTVL, WANTVR, WNTSNB, WNTSNE,
      LOGICAL            SCALEA, WANTVL, WANTVR, WNTSNB, WNTSNE, WNTSNN,
     $                   WNTSNN, WNTSNV
     $                   WNTSNV
      CHARACTER          JOB, SIDE
      CHARACTER          JOB, SIDE
      INTEGER            HSWORK, I, ICOND, IERR, ITAU, IWRK, K, MAXB,
      INTEGER            HSWORK, I, ICOND, IERR, ITAU, IWRK, K, MAXB,
     $                   MAXWRK, MINWRK, NOUT
     $                   MAXWRK, MINWRK, NOUT
 Lines 219-225    Link Here 
*     Test the input arguments
*     Test the input arguments
*
*
      INFO = 0
      INFO = 0
      LQUERY = ( LWORK.EQ.-1 )
      WANTVL = LSAME( JOBVL, 'V' )
      WANTVL = LSAME( JOBVL, 'V' )
      WANTVR = LSAME( JOBVR, 'V' )
      WANTVR = LSAME( JOBVR, 'V' )
      WNTSNN = LSAME( SENSE, 'N' )
      WNTSNN = LSAME( SENSE, 'N' )
 Lines 259-265    Link Here 
*       the worst case.)
*       the worst case.)
*
*
      MINWRK = 1
      MINWRK = 1
      IF( INFO.EQ.0 .AND. ( LWORK.GE.1 .OR. LQUERY ) ) THEN
      IF( INFO.EQ.0 ) THEN
         MAXWRK = N + N*ILAENV( 1, 'CGEHRD', ' ', N, 1, N, 0 )
         MAXWRK = N + N*ILAENV( 1, 'CGEHRD', ' ', N, 1, N, 0 )
         IF( ( .NOT.WANTVL ) .AND. ( .NOT.WANTVR ) ) THEN
         IF( ( .NOT.WANTVL ) .AND. ( .NOT.WANTVR ) ) THEN
            MINWRK = MAX( 1, 2*N )
            MINWRK = MAX( 1, 2*N )
 Lines 293-311    Link Here 
            MAXWRK = MAX( MAXWRK, 2*N, 1 )
            MAXWRK = MAX( MAXWRK, 2*N, 1 )
         END IF
         END IF
         WORK( 1 ) = MAXWRK
         WORK( 1 ) = MAXWRK
         IF( LWORK.LT.MINWRK .AND. LWORK.NE.LQUERV )
     $      INFO = -20
      END IF
      END IF
      IF( LWORK.LT.MINWRK .AND. .NOT.LQUERY ) THEN
*
         INFO = -20
*     Quick returns
      END IF
*
      IF( INFO.NE.0 ) THEN
      IF( INFO.NE.0 ) THEN
         CALL XERBLA( 'CGEEVX', -INFO )
         CALL XERBLA( 'CGEEVX', -INFO )
         RETURN
         RETURN
      ELSE IF( LQUERY ) THEN
         RETURN
      END IF
      END IF
*
      IF( LWORK.EQ.LQUERV ) RETURN
*     Quick return if possible
*
      IF( N.EQ.0 )
      IF( N.EQ.0 )
     $   RETURN
     $   RETURN
*
*
(-) LAPACK/SRC/cgegs.f (-53 / +39 lines)
 Lines 5-11    Link Here 
*  -- LAPACK driver routine (version 3.0) --
*  -- LAPACK driver routine (version 3.0) --
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Courant Institute, Argonne National Lab, and Rice University
*     Courant Institute, Argonne National Lab, and Rice University
*     June 30, 1999
*     April 26, 2001
*
*
*     .. Scalar Arguments ..
*     .. Scalar Arguments ..
      CHARACTER          JOBVSL, JOBVSR
      CHARACTER          JOBVSL, JOBVSR
 Lines 23-105    Link Here 
*
*
*  This routine is deprecated and has been replaced by routine CGGES.
*  This routine is deprecated and has been replaced by routine CGGES.
*
*
*  CGEGS computes for a pair of N-by-N complex nonsymmetric matrices A,
*  CGEGS computes the eigenvalues, Schur form, and, optionally, the
*  B:  the generalized eigenvalues (alpha, beta), the complex Schur
*  left and or/right Schur vectors of a complex matrix pair (A,B).
*  form (A, B), and optionally left and/or right Schur vectors
*  Given two square matrices A and B, the generalized Schur
*  (VSL and VSR).
*  factorization has the form
*
*  
*  (If only the generalized eigenvalues are needed, use the driver CGEGV
*     A = Q*S*Z**H,  B = Q*T*Z**H
*  instead.)
*  
*
*  where Q and Z are unitary matrices and S and T are upper triangular.
*  A generalized eigenvalue for a pair of matrices (A,B) is, roughly
*  The columns of Q are the left Schur vectors
*  speaking, a scalar w or a ratio  alpha/beta = w, such that  A - w*B
*  and the columns of Z are the right Schur vectors.
*  is singular.  It is usually represented as the pair (alpha,beta),
*  
*  as there is a reasonable interpretation for beta=0, and even for
*  If only the eigenvalues of (A,B) are needed, the driver routine
*  both being zero.  A good beginning reference is the book, "Matrix
*  CGEGV should be used instead.  See CGEGV for a description of the
*  Computations", by G. Golub & C. van Loan (Johns Hopkins U. Press)
*  eigenvalues of the generalized nonsymmetric eigenvalue problem
*
*  (GNEP).
*  The (generalized) Schur form of a pair of matrices is the result of
*  multiplying both matrices on the left by one unitary matrix and
*  both on the right by another unitary matrix, these two unitary
*  matrices being chosen so as to bring the pair of matrices into
*  upper triangular form with the diagonal elements of B being
*  non-negative real numbers (this is also called complex Schur form.)
*
*  The left and right Schur vectors are the columns of VSL and VSR,
*  respectively, where VSL and VSR are the unitary matrices
*  which reduce A and B to Schur form:
*
*  Schur form of (A,B) = ( (VSL)**H A (VSR), (VSL)**H B (VSR) )
*
*
*  Arguments
*  Arguments
*  =========
*  =========
*
*
*  JOBVSL   (input) CHARACTER*1
*  JOBVSL   (input) CHARACTER*1
*          = 'N':  do not compute the left Schur vectors;
*          = 'N':  do not compute the left Schur vectors;
*          = 'V':  compute the left Schur vectors.
*          = 'V':  compute the left Schur vectors (returned in VSL).
*
*
*  JOBVSR   (input) CHARACTER*1
*  JOBVSR   (input) CHARACTER*1
*          = 'N':  do not compute the right Schur vectors;
*          = 'N':  do not compute the right Schur vectors;
*          = 'V':  compute the right Schur vectors.
*          = 'V':  compute the right Schur vectors (returned in VSR).
*
*
*  N       (input) INTEGER
*  N       (input) INTEGER
*          The order of the matrices A, B, VSL, and VSR.  N >= 0.
*          The order of the matrices A, B, VSL, and VSR.  N >= 0.
*
*
*  A       (input/output) COMPLEX array, dimension (LDA, N)
*  A       (input/output) COMPLEX array, dimension (LDA, N)
*          On entry, the first of the pair of matrices whose generalized
*          On entry, the matrix A.
*          eigenvalues and (optionally) Schur vectors are to be
*          On exit, the upper triangular matrix S from the generalized
*          computed.
*          Schur factorization.
*          On exit, the generalized Schur form of A.
*
*
*  LDA     (input) INTEGER
*  LDA     (input) INTEGER
*          The leading dimension of A.  LDA >= max(1,N).
*          The leading dimension of A.  LDA >= max(1,N).
*
*
*  B       (input/output) COMPLEX array, dimension (LDB, N)
*  B       (input/output) COMPLEX array, dimension (LDB, N)
*          On entry, the second of the pair of matrices whose
*          On entry, the matrix B.
*          generalized eigenvalues and (optionally) Schur vectors are
*          On exit, the upper triangular matrix T from the generalized
*          to be computed.
*          Schur factorization.
*          On exit, the generalized Schur form of B.
*
*
*  LDB     (input) INTEGER
*  LDB     (input) INTEGER
*          The leading dimension of B.  LDB >= max(1,N).
*          The leading dimension of B.  LDB >= max(1,N).
*
*
*  ALPHA   (output) COMPLEX array, dimension (N)
*  ALPHA   (output) COMPLEX array, dimension (N)
*          The complex scalars alpha that define the eigenvalues of
*          GNEP.  ALPHA(j) = S(j,j), the diagonal element of the Schur
*          form of A.
*
*  BETA    (output) COMPLEX array, dimension (N)
*  BETA    (output) COMPLEX array, dimension (N)
*          On exit,  ALPHA(j)/BETA(j), j=1,...,N, will be the
*          The non-negative real scalars beta that define the
*          generalized eigenvalues.  ALPHA(j), j=1,...,N  and  BETA(j),
*          eigenvalues of GNEP.  BETA(j) = T(j,j), the diagonal element
*          j=1,...,N  are the diagonals of the complex Schur form (A,B)
*          of the triangular factor T.
*          output by CGEGS.  The  BETA(j) will be non-negative real.
*
*
*          Together, the quantities alpha = ALPHA(j) and beta = BETA(j)
*          Note: the quotients ALPHA(j)/BETA(j) may easily over- or
*          represent the j-th eigenvalue of the matrix pair (A,B), in
*          underflow, and BETA(j) may even be zero.  Thus, the user
*          one of the forms lambda = alpha/beta or mu = beta/alpha.
*          should avoid naively computing the ratio alpha/beta.
*          Since either lambda or mu may overflow, they should not,
*          However, ALPHA will be always less than and usually
*          in general, be computed.
*          comparable with norm(A) in magnitude, and BETA always less
*          than and usually comparable with norm(B).
*
*
*  VSL     (output) COMPLEX array, dimension (LDVSL,N)
*  VSL     (output) COMPLEX array, dimension (LDVSL,N)
*          If JOBVSL = 'V', VSL will contain the left Schur vectors.
*          If JOBVSL = 'V', the matrix of left Schur vectors Q.
*          (See "Purpose", above.)
*          Not referenced if JOBVSL = 'N'.
*          Not referenced if JOBVSL = 'N'.
*
*
*  LDVSL   (input) INTEGER
*  LDVSL   (input) INTEGER
 Lines 107-114    Link Here 
*          if JOBVSL = 'V', LDVSL >= N.
*          if JOBVSL = 'V', LDVSL >= N.
*
*
*  VSR     (output) COMPLEX array, dimension (LDVSR,N)
*  VSR     (output) COMPLEX array, dimension (LDVSR,N)
*          If JOBVSR = 'V', VSR will contain the right Schur vectors.
*          If JOBVSR = 'V', the matrix of right Schur vectors Z.
*          (See "Purpose", above.)
*          Not referenced if JOBVSR = 'N'.
*          Not referenced if JOBVSR = 'N'.
*
*
*  LDVSR   (input) INTEGER
*  LDVSR   (input) INTEGER
(-) LAPACK/SRC/cgegv.f (-52 / +64 lines)
 Lines 4-10    Link Here 
*  -- LAPACK driver routine (version 3.0) --
*  -- LAPACK driver routine (version 3.0) --
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Courant Institute, Argonne National Lab, and Rice University
*     Courant Institute, Argonne National Lab, and Rice University
*     June 30, 1999
*     April 26, 2001
*
*
*     .. Scalar Arguments ..
*     .. Scalar Arguments ..
      CHARACTER          JOBVL, JOBVR
      CHARACTER          JOBVL, JOBVR
 Lines 22-43    Link Here 
*
*
*  This routine is deprecated and has been replaced by routine CGGEV.
*  This routine is deprecated and has been replaced by routine CGGEV.
*
*
*  CGEGV computes for a pair of N-by-N complex nonsymmetric matrices A
*  CGEGV computes the eigenvalues and, optionally, the left and/or right
*  and B, the generalized eigenvalues (alpha, beta), and optionally,
*  eigenvectors of a complex matrix pair (A,B).
*  the left and/or right generalized eigenvectors (VL and VR).
*  Given two square matrices A and B,
*
*  the generalized nonsymmetric eigenvalue problem (GNEP) is to find the
*  A generalized eigenvalue for a pair of matrices (A,B) is, roughly
*  eigenvalues lambda and corresponding (non-zero) eigenvectors x such
*  speaking, a scalar w or a ratio  alpha/beta = w, such that  A - w*B
*  that
*  is singular.  It is usually represented as the pair (alpha,beta),
*     A*x = lambda*B*x.
*  as there is a reasonable interpretation for beta=0, and even for
*
*  both being zero.  A good beginning reference is the book, "Matrix
*  An alternate form is to find the eigenvalues mu and corresponding
*  Computations", by G. Golub & C. van Loan (Johns Hopkins U. Press)
*  eigenvectors y such that
*
*     mu*A*y = B*y.
*  A right generalized eigenvector corresponding to a generalized
*
*  eigenvalue  w  for a pair of matrices (A,B) is a vector  r  such
*  These two forms are equivalent with mu = 1/lambda and x = y if
*  that  (A - w B) r = 0 .  A left generalized eigenvector is a vector
*  neither lambda nor mu is zero.  In order to deal with the case that
*  l such that l**H * (A - w B) = 0, where l**H is the
*  lambda or mu is zero or small, two values alpha and beta are returned
*  conjugate-transpose of l.
*  for each eigenvalue, such that lambda = alpha/beta and
*  mu = beta/alpha.
*  
*  The vectors x and y in the above equations are right eigenvectors of
*  the matrix pair (A,B).  Vectors u and v satisfying
*     u**H*A = lambda*u**H*B  or  mu*v**H*A = v**H*B
*  are left eigenvectors of (A,B).
*
*
*  Note: this routine performs "full balancing" on A and B -- see
*  Note: this routine performs "full balancing" on A and B -- see
*  "Further Details", below.
*  "Further Details", below.
 Lines 47-102    Link Here 
*
*
*  JOBVL   (input) CHARACTER*1
*  JOBVL   (input) CHARACTER*1
*          = 'N':  do not compute the left generalized eigenvectors;
*          = 'N':  do not compute the left generalized eigenvectors;
*          = 'V':  compute the left generalized eigenvectors.
*          = 'V':  compute the left generalized eigenvectors (returned
*                  in VL).
*
*
*  JOBVR   (input) CHARACTER*1
*  JOBVR   (input) CHARACTER*1
*          = 'N':  do not compute the right generalized eigenvectors;
*          = 'N':  do not compute the right generalized eigenvectors;
*          = 'V':  compute the right generalized eigenvectors.
*          = 'V':  compute the right generalized eigenvectors (returned
*                  in VR).
*
*
*  N       (input) INTEGER
*  N       (input) INTEGER
*          The order of the matrices A, B, VL, and VR.  N >= 0.
*          The order of the matrices A, B, VL, and VR.  N >= 0.
*
*
*  A       (input/output) COMPLEX array, dimension (LDA, N)
*  A       (input/output) COMPLEX array, dimension (LDA, N)
*          On entry, the first of the pair of matrices whose
*          On entry, the matrix A.
*          generalized eigenvalues and (optionally) generalized
*          If JOBVL = 'V' or JOBVR = 'V', then on exit A
*          eigenvectors are to be computed.
*          contains the Schur form of A from the generalized Schur
*          On exit, the contents will have been destroyed.  (For a
*          factorization of the pair (A,B) after balancing.  If no
*          description of the contents of A on exit, see "Further
*          eigenvectors were computed, then only the diagonal elements
*          Details", below.)
*          of the Schur form will be correct.  See CGGHRD and CHGEQZ
*          for details.
*
*
*  LDA     (input) INTEGER
*  LDA     (input) INTEGER
*          The leading dimension of A.  LDA >= max(1,N).
*          The leading dimension of A.  LDA >= max(1,N).
*
*
*  B       (input/output) COMPLEX array, dimension (LDB, N)
*  B       (input/output) COMPLEX array, dimension (LDB, N)
*          On entry, the second of the pair of matrices whose
*          On entry, the matrix B.
*          generalized eigenvalues and (optionally) generalized
*          If JOBVL = 'V' or JOBVR = 'V', then on exit B contains the
*          eigenvectors are to be computed.
*          upper triangular matrix obtained from B in the generalized
*          On exit, the contents will have been destroyed.  (For a
*          Schur factorization of the pair (A,B) after balancing.
*          description of the contents of B on exit, see "Further
*          If no eigenvectors were computed, then only the diagonal
*          Details", below.)
*          elements of B will be correct.  See CGGHRD and CHGEQZ for
*          details.
*
*
*  LDB     (input) INTEGER
*  LDB     (input) INTEGER
*          The leading dimension of B.  LDB >= max(1,N).
*          The leading dimension of B.  LDB >= max(1,N).
*
*
*  ALPHA   (output) COMPLEX array, dimension (N)
*  ALPHA   (output) COMPLEX array, dimension (N)
*  BETA    (output) COMPLEX array, dimension (N)
*          The complex scalars alpha that define the eigenvalues of
*          On exit, ALPHA(j)/BETA(j), j=1,...,N, will be the
*          GNEP.
*          generalized eigenvalues.
*
*
*          Note: the quotients ALPHA(j)/BETA(j) may easily over- or
*  BETA    (output) COMPLEX array, dimension (N)
*          underflow, and BETA(j) may even be zero.  Thus, the user
*          The complex scalars beta that define the eigenvalues of GNEP.
*          should avoid naively computing the ratio alpha/beta.
*          
*          However, ALPHA will be always less than and usually
*          Together, the quantities alpha = ALPHA(j) and beta = BETA(j)
*          comparable with norm(A) in magnitude, and BETA always less
*          represent the j-th eigenvalue of the matrix pair (A,B), in
*          than and usually comparable with norm(B).
*          one of the forms lambda = alpha/beta or mu = beta/alpha.
*          Since either lambda or mu may overflow, they should not,
*          in general, be computed.
*
*
*  VL      (output) COMPLEX array, dimension (LDVL,N)
*  VL      (output) COMPLEX array, dimension (LDVL,N)
*          If JOBVL = 'V', the left generalized eigenvectors.  (See
*          If JOBVL = 'V', the left eigenvectors u(j) are stored
*          "Purpose", above.)
*          in the columns of VL, in the same order as their eigenvalues.
*          Each eigenvector will be scaled so the largest component
*          Each eigenvector is scaled so that its largest component has
*          will have abs(real part) + abs(imag. part) = 1, *except*
*          abs(real part) + abs(imag. part) = 1, except for eigenvectors
*          that for eigenvalues with alpha=beta=0, a zero vector will
*          corresponding to an eigenvalue with alpha = beta = 0, which
*          be returned as the corresponding eigenvector.
*          are set to zero.
*          Not referenced if JOBVL = 'N'.
*          Not referenced if JOBVL = 'N'.
*
*
*  LDVL    (input) INTEGER
*  LDVL    (input) INTEGER
 Lines 104-115    Link Here 
*          if JOBVL = 'V', LDVL >= N.
*          if JOBVL = 'V', LDVL >= N.
*
*
*  VR      (output) COMPLEX array, dimension (LDVR,N)
*  VR      (output) COMPLEX array, dimension (LDVR,N)
*          If JOBVR = 'V', the right generalized eigenvectors.  (See
*          If JOBVR = 'V', the right eigenvectors x(j) are stored
*          "Purpose", above.)
*          in the columns of VR, in the same order as their eigenvalues.
*          Each eigenvector will be scaled so the largest component
*          Each eigenvector is scaled so that its largest component has
*          will have abs(real part) + abs(imag. part) = 1, *except*
*          abs(real part) + abs(imag. part) = 1, except for eigenvectors
*          that for eigenvalues with alpha=beta=0, a zero vector will
*          corresponding to an eigenvalue with alpha = beta = 0, which
*          be returned as the corresponding eigenvector.
*          are set to zero.
*          Not referenced if JOBVR = 'N'.
*          Not referenced if JOBVR = 'N'.
*
*
*  LDVR    (input) INTEGER
*  LDVR    (input) INTEGER
(-) LAPACK/SRC/cgelsd.f (-32 / +23 lines)
 Lines 4-10    Link Here 
*  -- LAPACK driver routine (version 3.0) --
*  -- LAPACK driver routine (version 3.0) --
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Courant Institute, Argonne National Lab, and Rice University
*     Courant Institute, Argonne National Lab, and Rice University
*     October 31, 1999
*     June 30, 1999
*     8-15-00:  Improve consistency of WS calculations (eca)
*
*
*     .. Scalar Arguments ..
*     .. Scalar Arguments ..
      INTEGER            INFO, LDA, LDB, LWORK, M, N, NRHS, RANK
      INTEGER            INFO, LDA, LDB, LWORK, M, N, NRHS, RANK
 Lines 64-70    Link Here 
*
*
*  A       (input/output) COMPLEX array, dimension (LDA,N)
*  A       (input/output) COMPLEX array, dimension (LDA,N)
*          On entry, the M-by-N matrix A.
*          On entry, the M-by-N matrix A.
*          On exit, A has been destroyed.
*          On exit, the first min(m,n) rows of A are overwritten with
*          its right singular vectors, stored rowwise.
*
*
*  LDA     (input) INTEGER
*  LDA     (input) INTEGER
*          The leading dimension of the array A. LDA >= max(1,M).
*          The leading dimension of the array A. LDA >= max(1,M).
 Lines 96-127    Link Here 
*          On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
*          On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
*
*
*  LWORK   (input) INTEGER
*  LWORK   (input) INTEGER
*          The dimension of the array WORK. LWORK must be at least 1.
*          The dimension of the array WORK. LWORK >= 1.
*          The exact minimum amount of workspace needed depends on M,
*          The exact minimum amount of workspace needed depends on M,
*          N and NRHS. As long as LWORK is at least
*          N and NRHS.
*              2 * N + N * NRHS
*          If M >= N, LWORK >= 2*N + N*NRHS.
*          if M is greater than or equal to N or
*          If M < N, LWORK >= 2*M + M*NRHS.
*              2 * M + M * NRHS
*          if M is less than N, the code will execute correctly.
*          For good performance, LWORK should generally be larger.
*          For good performance, LWORK should generally be larger.
*
*
*          If LWORK = -1, then a workspace query is assumed; the routine
*          If LWORK = -1, a workspace query is assumed.  The optimal
*          only calculates the optimal size of the WORK array, returns
*          size for the WORK array is calculated and stored in WORK(1),
*          this value as the first entry of the WORK array, and no error
*          and no other work except argument checking is performed.
*          message related to LWORK is issued by XERBLA.
*
*
*  RWORK   (workspace) REAL array, dimension (LRWORK)
*
*          If M >= N, LRWORK >= 8*N + 2*N*SMLSIZ + 8*N*NLVL + N*NRHS.
*  RWORK   (workspace) REAL array, dimension at least
*          If M < N, LRWORK >= 8*M + 2*M*SMLSIZ + 8*M*NLVL + M*NRHS.
*             10*N + 2*N*SMLSIZ + 8*N*NLVL + 3*SMLSIZ*NRHS +
*             (SMLSIZ+1)**2
*          if M is greater than or equal to N or
*             10*M + 2*M*SMLSIZ + 8*M*NLVL + 3*SMLSIZ*NRHS +
*             (SMLSIZ+1)**2
*          if M is less than N, the code will execute correctly.
*          SMLSIZ is returned by ILAENV and is equal to the maximum
*          SMLSIZ is returned by ILAENV and is equal to the maximum
*          size of the subproblems at the bottom of the computation
*          size of the subproblems at the bottom of the computation
*          tree (usually about 25), and
*          tree (usually about 25), and
*             NLVL = MAX( 0, INT( LOG_2( MIN( M,N )/(SMLSIZ+1) ) ) + 1 )
*              NLVL = INT( LOG_2( MIN( M,N )/(SMLSIZ+1) ) ) + 1
*
*
*  IWORK   (workspace) INTEGER array, dimension (LIWORK)
*  IWORK   (workspace) INTEGER array, dimension (LIWORK)
*          LIWORK >= 3 * MINMN * NLVL + 11 * MINMN,
*          LIWORK >= 3 * MINMN * NLVL + 11 * MINMN,
 Lines 145-157    Link Here 
*  =====================================================================
*  =====================================================================
*
*
*     .. Parameters ..
*     .. Parameters ..
      INTEGER            LQUERV
      PARAMETER          ( LQUERV = -1 )
      REAL               ZERO, ONE
      REAL               ZERO, ONE
      PARAMETER          ( ZERO = 0.0E+0, ONE = 1.0E+0 )
      PARAMETER          ( ZERO = 0.0E+0, ONE = 1.0E+0 )
      COMPLEX            CZERO
      COMPLEX            CZERO
      PARAMETER          ( CZERO = ( 0.0E+0, 0.0E+0 ) )
      PARAMETER          ( CZERO = ( 0.0E+0, 0.0E+0 ) )
*     ..
*     ..
*     .. Local Scalars ..
*     .. Local Scalars ..
      LOGICAL            LQUERY
      INTEGER            IASCL, IBSCL, IE, IL, ITAU, ITAUP, ITAUQ,
      INTEGER            IASCL, IBSCL, IE, IL, ITAU, ITAUP, ITAUQ,
     $                   LDWORK, MAXMN, MAXWRK, MINMN, MINWRK, MM,
     $                   LDWORK, MAXMN, MAXWRK, MINMN, MINWRK, MM,
     $                   MNTHR, NRWORK, NWORK, SMLSIZ
     $                   MNTHR, NRWORK, NWORK, SMLSIZ
 Lines 179-185    Link Here 
      MINMN = MIN( M, N )
      MINMN = MIN( M, N )
      MAXMN = MAX( M, N )
      MAXMN = MAX( M, N )
      MNTHR = ILAENV( 6, 'CGELSD', ' ', M, N, NRHS, -1 )
      MNTHR = ILAENV( 6, 'CGELSD', ' ', M, N, NRHS, -1 )
      LQUERY = ( LWORK.EQ.-1 )
      IF( M.LT.0 ) THEN
      IF( M.LT.0 ) THEN
         INFO = -1
         INFO = -1
      ELSE IF( N.LT.0 ) THEN
      ELSE IF( N.LT.0 ) THEN
 Lines 263-282    Link Here 
         END IF
         END IF
         MINWRK = MIN( MINWRK, MAXWRK )
         MINWRK = MIN( MINWRK, MAXWRK )
         WORK( 1 ) = CMPLX( MAXWRK, 0 )
         WORK( 1 ) = CMPLX( MAXWRK, 0 )
         IF( LWORK.LT.MINWRK .AND. .NOT.LQUERY ) THEN
         IF( LWORK.LT.MINWRK .AND. LWORK.NE.LQUERV )
            INFO = -12
     $      INFO = -12
         END IF
      END IF
      END IF
*
*
*     Quick returns
*
      IF( INFO.NE.0 ) THEN
      IF( INFO.NE.0 ) THEN
         CALL XERBLA( 'CGELSD', -INFO )
         CALL XERBLA( 'CGELSD', -INFO )
         RETURN
         RETURN
      ELSE IF( LQUERY ) THEN
         GO TO 10
      END IF
      END IF
*
      IF( LWORK.EQ.LQUERV ) RETURN
*     Quick return if possible.
*
      IF( M.EQ.0 .OR. N.EQ.0 ) THEN
      IF( M.EQ.0 .OR. N.EQ.0 ) THEN
         RANK = 0
         RANK = 0
         RETURN
         RETURN
(-) LAPACK/SRC/cgelss.f (-13 / +11 lines)
 Lines 4-10    Link Here 
*  -- LAPACK driver routine (version 3.0) --
*  -- LAPACK driver routine (version 3.0) --
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Courant Institute, Argonne National Lab, and Rice University
*     Courant Institute, Argonne National Lab, and Rice University
*     October 31, 1999
*     April 25, 2001 
*
*
*     .. Scalar Arguments ..
*     .. Scalar Arguments ..
      INTEGER            INFO, LDA, LDB, LWORK, M, N, NRHS, RANK
      INTEGER            INFO, LDA, LDB, LWORK, M, N, NRHS, RANK
 Lines 87-96    Link Here 
*          LWORK >=  2*min(M,N) + max(M,N,NRHS)
*          LWORK >=  2*min(M,N) + max(M,N,NRHS)
*          For good performance, LWORK should generally be larger.
*          For good performance, LWORK should generally be larger.
*
*
*          If LWORK = -1, then a workspace query is assumed; the routine
*          If LWORK = -1, a workspace query is assumed.  The optimal
*          only calculates the optimal size of the WORK array, returns
*          size for the WORK array is calculated and stored in WORK(1),
*          this value as the first entry of the WORK array, and no error
*          and no other work except argument checking is performed.
*          message related to LWORK is issued by XERBLA.
*
*
*  RWORK   (workspace) REAL array, dimension (5*min(M,N))
*  RWORK   (workspace) REAL array, dimension (5*min(M,N))
*
*
 Lines 164-170    Link Here 
*       immediately following subroutine, as returned by ILAENV.)
*       immediately following subroutine, as returned by ILAENV.)
*
*
      MINWRK = 1
      MINWRK = 1
      IF( INFO.EQ.0 .AND. ( LWORK.GE.1 .OR. LQUERY ) ) THEN
      IF( INFO.EQ.0 ) THEN
         MAXWRK = 0
         MAXWRK = 0
         MM = M
         MM = M
         IF( M.GE.N .AND. M.GE.MNTHR ) THEN
         IF( M.GE.N .AND. M.GE.MNTHR ) THEN
 Lines 235-253    Link Here 
         MINWRK = MAX( MINWRK, 1 )
         MINWRK = MAX( MINWRK, 1 )
         MAXWRK = MAX( MINWRK, MAXWRK )
         MAXWRK = MAX( MINWRK, MAXWRK )
         WORK( 1 ) = MAXWRK
         WORK( 1 ) = MAXWRK
         IF( LWORK.LT.MINWRK .AND. .NOT.LQUERY )
     $      INFO = -12
      END IF
      END IF
*
*
      IF( LWORK.LT.MINWRK .AND. .NOT.LQUERY )
*     Quick returns
     $   INFO = -12
*
      IF( INFO.NE.0 ) THEN
      IF( INFO.NE.0 ) THEN
         CALL XERBLA( 'CGELSS', -INFO )
         CALL XERBLA( 'CGELSS', -INFO )
         RETURN
         RETURN
      ELSE IF( LQUERY ) THEN
      ELSE IF( LQUERY ) THEN
         RETURN
         RETURN
      END IF
      END IF
*
*     Quick return if possible
*
      IF( M.EQ.0 .OR. N.EQ.0 ) THEN
      IF( M.EQ.0 .OR. N.EQ.0 ) THEN
         RANK = 0
         RANK = 0
         RETURN
         RETURN
 Lines 512-519    Link Here 
            DO 40 I = 1, NRHS, CHUNK
            DO 40 I = 1, NRHS, CHUNK
               BL = MIN( NRHS-I+1, CHUNK )
               BL = MIN( NRHS-I+1, CHUNK )
               CALL CGEMM( 'C', 'N', M, BL, M, CONE, WORK( IL ), LDWORK,
               CALL CGEMM( 'C', 'N', M, BL, M, CONE, WORK( IL ), LDWORK,
     $                     B( 1, I ), LDB, CZERO, WORK( IWORK ), N )
     $                     B( 1, I ), LDB, CZERO, WORK( IWORK ), M )
               CALL CLACPY( 'G', M, BL, WORK( IWORK ), N, B( 1, I ),
               CALL CLACPY( 'G', M, BL, WORK( IWORK ), M, B( 1, I ),
     $                      LDB )
     $                      LDB )
   40       CONTINUE
   40       CONTINUE
         ELSE
         ELSE
(-) LAPACK/SRC/cgesdd.f (-47 / +61 lines)
 Lines 1-10    Link Here 
      SUBROUTINE CGESDD( JOBZ, M, N, A, LDA, S, U, LDU, VT, LDVT, WORK,
      SUBROUTINE CGESDD( JOBZ, M, N, A, LDA, S, U, LDU, VT, LDVT,
     $                   LWORK, RWORK, IWORK, INFO )
     $                   WORK, LWORK, RWORK, IWORK, INFO )
*
*
*  -- LAPACK driver routine (version 3.0) --
*  -- LAPACK driver routine (version 3.0) --
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Courant Institute, Argonne National Lab, and Rice University
*     Courant Institute, Argonne National Lab, and Rice University
*     October 31, 1999
*     June 30, 1999
*     8-15-00:  Improve consistency of WS calculations (eca)
*
*
*     .. Scalar Arguments ..
*     .. Scalar Arguments ..
      CHARACTER          JOBZ
      CHARACTER          JOBZ
 Lines 119-130    Link Here 
*          if JOBZ = 'S' or 'A',
*          if JOBZ = 'S' or 'A',
*                LWORK >= min(M,N)*min(M,N)+2*min(M,N)+max(M,N).
*                LWORK >= min(M,N)*min(M,N)+2*min(M,N)+max(M,N).
*          For good performance, LWORK should generally be larger.
*          For good performance, LWORK should generally be larger.
*          If LWORK < 0 but other input arguments are legal, WORK(1)
*
*          returns the optimal LWORK.
*          If LWORK = -1, a workspace query is assumed.  The optimal
*          size for the WORK array is calculated and stored in WORK(1),
*          and no other work except argument checking is performed.
*
*
*  RWORK   (workspace) REAL array, dimension (LRWORK)
*  RWORK   (workspace) REAL array, dimension (LRWORK)
*          If JOBZ = 'N', LRWORK >= 7*min(M,N).
*          If JOBZ = 'N', LRWORK >= 5*min(M,N).
*          Otherwise, LRWORK >= 5*min(M,N)*min(M,N) + 5*min(M,N)
*          Otherwise, LRWORK >= 5*min(M,N)*min(M,N) + 7*min(M,N)
*
*
*  IWORK   (workspace) INTEGER array, dimension (8*min(M,N))
*  IWORK   (workspace) INTEGER array, dimension (8*min(M,N))
*
*
 Lines 143-156    Link Here 
*  =====================================================================
*  =====================================================================
*
*
*     .. Parameters ..
*     .. Parameters ..
      INTEGER            LQUERV
      PARAMETER          ( LQUERV = -1 )
      COMPLEX            CZERO, CONE
      COMPLEX            CZERO, CONE
      PARAMETER          ( CZERO = ( 0.0E0, 0.0E0 ),
      PARAMETER          ( CZERO = ( 0.0E+0, 0.0E+0 ),
     $                   CONE = ( 1.0E0, 0.0E0 ) )
     $                   CONE = ( 1.0E+0, 0.0E+0 ) )
      REAL               ZERO, ONE
      REAL               ZERO, ONE
      PARAMETER          ( ZERO = 0.0E0, ONE = 1.0E0 )
      PARAMETER          ( ZERO = 0.0E+0, ONE = 1.0E+0 )
*     ..
*     ..
*     .. Local Scalars ..
*     .. Local Scalars ..
      LOGICAL            LQUERY, WNTQA, WNTQAS, WNTQN, WNTQO, WNTQS
      LOGICAL            WNTQA, WNTQAS, WNTQN, WNTQO, WNTQS
      INTEGER            BLK, CHUNK, I, IE, IERR, IL, IR, IRU, IRVT,
      INTEGER            BLK, CHUNK, I, IE, IERR, IL, IR, IRU, IRVT,
     $                   ISCL, ITAU, ITAUP, ITAUQ, IU, IVT, LDWKVT,
     $                   ISCL, ITAU, ITAUP, ITAUQ, IU, IVT, LDWKVT,
     $                   LDWRKL, LDWRKR, LDWRKU, MAXWRK, MINMN, MINWRK,
     $                   LDWRKL, LDWRKR, LDWRKU, MAXWRK, MINMN, MINWRK,
 Lines 162-176    Link Here 
      REAL               DUM( 1 )
      REAL               DUM( 1 )
*     ..
*     ..
*     .. External Subroutines ..
*     .. External Subroutines ..
      EXTERNAL           CGEBRD, CGELQF, CGEMM, CGEQRF, CLACP2, CLACPY, 
      EXTERNAL           CGEBRD, CGELQF, CGEMM, CGEQRF,
     $                   CLACRM, CLARCM, CLASCL, CLASET, CUNGBR, CUNGLQ, 
     $                   CLACP2, CLACPY, CLACRM, CLARCM,
     $                   CUNGQR, CUNMBR, SBDSDC, SLASCL, XERBLA
     $                   CLASCL, CLASET, CUNGBR, CUNGLQ,
     $                   CUNGQR, CUNMBR, SBDSDC, SLASCL,
     $                   XERBLA
*     ..
*     ..
*     .. External Functions ..
*     .. External Functions ..
      LOGICAL            LSAME
      LOGICAL            LSAME
      INTEGER            ILAENV
      INTEGER            ILAENV
      REAL               CLANGE, SLAMCH
      REAL               CLANGE, SLAMCH
      EXTERNAL           CLANGE, ILAENV, LSAME, SLAMCH
      EXTERNAL           CLANGE, SLAMCH, ILAENV, LSAME
*     ..
*     ..
*     .. Intrinsic Functions ..
*     .. Intrinsic Functions ..
      INTRINSIC          INT, MAX, MIN, SQRT
      INTRINSIC          INT, MAX, MIN, SQRT
 Lines 181-188    Link Here 
*
*
      INFO = 0
      INFO = 0
      MINMN = MIN( M, N )
      MINMN = MIN( M, N )
      MNTHR1 = INT( MINMN*17.0E0 / 9.0E0 )
      MNTHR1 = INT( MINMN*17.0 / 9.0 )
      MNTHR2 = INT( MINMN*5.0E0 / 3.0E0 )
      MNTHR2 = INT( MINMN*5.0 / 3.0 )
      WNTQA = LSAME( JOBZ, 'A' )
      WNTQA = LSAME( JOBZ, 'A' )
      WNTQS = LSAME( JOBZ, 'S' )
      WNTQS = LSAME( JOBZ, 'S' )
      WNTQAS = WNTQA .OR. WNTQS
      WNTQAS = WNTQA .OR. WNTQS
 Lines 190-196    Link Here 
      WNTQN = LSAME( JOBZ, 'N' )
      WNTQN = LSAME( JOBZ, 'N' )
      MINWRK = 1
      MINWRK = 1
      MAXWRK = 1
      MAXWRK = 1
      LQUERY = ( LWORK.EQ.-1 )
*
*
      IF( .NOT.( WNTQA .OR. WNTQS .OR. WNTQO .OR. WNTQN ) ) THEN
      IF( .NOT.( WNTQA .OR. WNTQS .OR. WNTQO .OR. WNTQN ) ) THEN
         INFO = -1
         INFO = -1
 Lines 221-239    Link Here 
         IF( M.GE.N ) THEN
         IF( M.GE.N ) THEN
*
*
*           There is no complex work space needed for bidiagonal SVD
*           There is no complex work space needed for bidiagonal SVD
*           The real work space needed for bidiagonal SVD is BDSPAC,
*           The real work space needed for bidiagonal SVD is BDSPAC
*           BDSPAC = 3*N*N + 4*N
*           for computing singular values and singular vectors; BDSPAN
*           for computing singular values only.
*           BDSPAC = 5*N*N + 7*N
*           BDSPAN = MAX(7*N+4, 3*N+2+SMLSIZ*(SMLSIZ+8))
*
*
            IF( M.GE.MNTHR1 ) THEN
            IF( M.GE.MNTHR1 ) THEN
               IF( WNTQN ) THEN
               IF( WNTQN ) THEN
*
*
*                 Path 1 (M much larger than N, JOBZ='N')
*                 Path 1 (M much larger than N, JOBZ='N')
*
*
                  WRKBL = N + N*ILAENV( 1, 'CGEQRF', ' ', M, N, -1,
                  MAXWRK = N + N*ILAENV( 1, 'CGEQRF', ' ', M, N, -1,
     $                    -1 )
     $                     -1 )
                  WRKBL = MAX( WRKBL, 2*N+2*N*
                  MAXWRK = MAX( MAXWRK, 2*N+2*N*
     $                    ILAENV( 1, 'CGEBRD', ' ', N, N, -1, -1 ) )
     $                     ILAENV( 1, 'CGEBRD', ' ', N, N, -1, -1 ) )
                  MAXWRK = WRKBL
                  MINWRK = 3*N
                  MINWRK = 3*N
               ELSE IF( WNTQO ) THEN
               ELSE IF( WNTQO ) THEN
*
*
 Lines 335-342    Link Here 
         ELSE
         ELSE
*
*
*           There is no complex work space needed for bidiagonal SVD
*           There is no complex work space needed for bidiagonal SVD
*           The real work space needed for bidiagonal SVD is BDSPAC,
*           The real work space needed for bidiagonal SVD is BDSPAC
*           BDSPAC = 3*M*M + 4*M
*           for computing singular values and singular vectors; BDSPAN
*           for computing singular values only.
*           BDSPAC = 5*M*M + 7*M
*           BDSPAN = MAX(7*M+4, 3*M+2+SMLSIZ*(SMLSIZ+8))
*
*
            IF( N.GE.MNTHR1 ) THEN
            IF( N.GE.MNTHR1 ) THEN
               IF( WNTQN ) THEN
               IF( WNTQN ) THEN
 Lines 447-470    Link Here 
            END IF
            END IF
         END IF
         END IF
         MAXWRK = MAX( MAXWRK, MINWRK )
         MAXWRK = MAX( MAXWRK, MINWRK )
      END IF
      IF( INFO.EQ.0 ) THEN
         WORK( 1 ) = MAXWRK
         WORK( 1 ) = MAXWRK
         IF( LWORK.LT.MINWRK .AND. LWORK.NE.LQUERV )
     $      INFO = -13
      END IF
      END IF
*
*
      IF( LWORK.LT.MINWRK .AND. .NOT.LQUERY ) THEN
*     Quick returns
         INFO = -13
*
      END IF
      IF( INFO.NE.0 ) THEN
      IF( INFO.NE.0 ) THEN
         CALL XERBLA( 'CGESDD', -INFO )
         CALL XERBLA( 'CGESDD', -INFO )
         RETURN
         RETURN
      ELSE IF( LQUERY ) THEN
         RETURN
      END IF
      END IF
*
      IF( LWORK.EQ.LQUERV ) RETURN
*     Quick return if possible
*
      IF( M.EQ.0 .OR. N.EQ.0 ) THEN
      IF( M.EQ.0 .OR. N.EQ.0 ) THEN
         IF( LWORK.GE.1 )
     $      WORK( 1 ) = ONE
         RETURN
         RETURN
      END IF
      END IF
*
*
 Lines 529-535    Link Here 
*
*
*              Perform bidiagonal SVD, compute singular values only
*              Perform bidiagonal SVD, compute singular values only
*              (CWorkspace: 0)
*              (CWorkspace: 0)
*              (RWorkspace: need BDSPAC)
*              (RWorkspace: need BDSPAN)
*
*
               CALL SBDSDC( 'U', 'N', N, S, RWORK( IE ), DUM, 1, DUM, 1,
               CALL SBDSDC( 'U', 'N', N, S, RWORK( IE ), DUM, 1, DUM, 1,
     $                      DUM, IDUM, RWORK( NRWORK ), IWORK, INFO )
     $                      DUM, IDUM, RWORK( NRWORK ), IWORK, INFO )
 Lines 844-850    Link Here 
*
*
*              Compute singular values only
*              Compute singular values only
*              (Cworkspace: 0)
*              (Cworkspace: 0)
*              (Rworkspace: need BDSPAC)
*              (Rworkspace: need BDSPAN)
*
*
               CALL SBDSDC( 'U', 'N', N, S, RWORK( IE ), DUM, 1, DUM, 1,
               CALL SBDSDC( 'U', 'N', N, S, RWORK( IE ), DUM, 1, DUM, 1,
     $                      DUM, IDUM, RWORK( NRWORK ), IWORK, INFO )
     $                      DUM, IDUM, RWORK( NRWORK ), IWORK, INFO )
 Lines 1040-1046    Link Here 
*
*
*              Compute singular values only
*              Compute singular values only
*              (Cworkspace: 0)
*              (Cworkspace: 0)
*              (Rworkspace: need BDSPAC)
*              (Rworkspace: need BDSPAN)
*
*
               CALL SBDSDC( 'U', 'N', N, S, RWORK( IE ), DUM, 1, DUM, 1,
               CALL SBDSDC( 'U', 'N', N, S, RWORK( IE ), DUM, 1, DUM, 1,
     $                      DUM, IDUM, RWORK( NRWORK ), IWORK, INFO )
     $                      DUM, IDUM, RWORK( NRWORK ), IWORK, INFO )
 Lines 1205-1212    Link Here 
      ELSE
      ELSE
*
*
*        A has more columns than rows. If A has sufficiently more
*        A has more columns than rows. If A has sufficiently more
*        columns than rows, first reduce using the LQ decomposition
*        columns than rows, first reduce using the LQ decomposition (if
*        (if sufficient workspace available)
*        sufficient workspace available)
*
*
         IF( N.GE.MNTHR1 ) THEN
         IF( N.GE.MNTHR1 ) THEN
*
*
 Lines 1245-1251    Link Here 
*
*
*              Perform bidiagonal SVD, compute singular values only
*              Perform bidiagonal SVD, compute singular values only
*              (CWorkspace: 0)
*              (CWorkspace: 0)
*              (RWorkspace: need BDSPAC)
*              (RWorkspace: need BDSPAN)
*
*
               CALL SBDSDC( 'U', 'N', M, S, RWORK( IE ), DUM, 1, DUM, 1,
               CALL SBDSDC( 'U', 'N', M, S, RWORK( IE ), DUM, 1, DUM, 1,
     $                      DUM, IDUM, RWORK( NRWORK ), IWORK, INFO )
     $                      DUM, IDUM, RWORK( NRWORK ), IWORK, INFO )
 Lines 1531-1538    Link Here 
*              (CWorkspace: need M*M)
*              (CWorkspace: need M*M)
*              (RWorkspace: 0)
*              (RWorkspace: 0)
*
*
               CALL CGEMM( 'N', 'N', M, N, M, CONE, WORK( IVT ), LDWKVT,
               CALL CGEMM( 'N', 'N', M, N, M, CONE, WORK( IVT ),
     $                     VT, LDVT, CZERO, A, LDA )
     $                     LDWKVT, VT, LDVT, CZERO, A, LDA )
*
*
*              Copy right singular vectors of A from A to VT
*              Copy right singular vectors of A from A to VT
*
*
 Lines 1567-1573    Link Here 
*
*
*              Compute singular values only
*              Compute singular values only
*              (Cworkspace: 0)
*              (Cworkspace: 0)
*              (Rworkspace: need BDSPAC)
*              (Rworkspace: need BDSPAN)
*
*
               CALL SBDSDC( 'L', 'N', M, S, RWORK( IE ), DUM, 1, DUM, 1,
               CALL SBDSDC( 'L', 'N', M, S, RWORK( IE ), DUM, 1, DUM, 1,
     $                      DUM, IDUM, RWORK( NRWORK ), IWORK, INFO )
     $                      DUM, IDUM, RWORK( NRWORK ), IWORK, INFO )
 Lines 1763-1769    Link Here 
*
*
*              Compute singular values only
*              Compute singular values only
*              (Cworkspace: 0)
*              (Cworkspace: 0)
*              (Rworkspace: need BDSPAC)
*              (Rworkspace: need BDSPAN)
*
*
               CALL SBDSDC( 'L', 'N', M, S, RWORK( IE ), DUM, 1, DUM, 1,
               CALL SBDSDC( 'L', 'N', M, S, RWORK( IE ), DUM, 1, DUM, 1,
     $                      DUM, IDUM, RWORK( NRWORK ), IWORK, INFO )
     $                      DUM, IDUM, RWORK( NRWORK ), IWORK, INFO )
 Lines 1934-1942    Link Here 
         IF( ANRM.GT.BIGNUM )
         IF( ANRM.GT.BIGNUM )
     $      CALL SLASCL( 'G', 0, 0, BIGNUM, ANRM, MINMN, 1, S, MINMN,
     $      CALL SLASCL( 'G', 0, 0, BIGNUM, ANRM, MINMN, 1, S, MINMN,
     $                   IERR )
     $                   IERR )
         IF( INFO.NE.0 .AND. ANRM.GT.BIGNUM )
     $      CALL SLASCL( 'G', 0, 0, BIGNUM, ANRM, MINMN-1, 1,
     $                   RWORK( IE ), MINMN, IERR )
         IF( ANRM.LT.SMLNUM )
         IF( ANRM.LT.SMLNUM )
     $      CALL SLASCL( 'G', 0, 0, SMLNUM, ANRM, MINMN, 1, S, MINMN,
     $      CALL SLASCL( 'G', 0, 0, SMLNUM, ANRM, MINMN, 1, S, MINMN,
     $                   IERR )
     $                   IERR )
         IF( INFO.NE.0 .AND. ANRM.LT.SMLNUM )
     $      CALL SLASCL( 'G', 0, 0, SMLNUM, ANRM, MINMN-1, 1,
     $                   RWORK( IE ), MINMN, IERR )
      END IF
      END IF
*
*
*     Return optimal workspace in WORK(1)
*     Return optimal workspace in WORK(1)
(-) LAPACK/SRC/cgesvd.f (-21 / +20 lines)
 Lines 4-10    Link Here 
*  -- LAPACK driver routine (version 3.0) --
*  -- LAPACK driver routine (version 3.0) --
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Courant Institute, Argonne National Lab, and Rice University
*     Courant Institute, Argonne National Lab, and Rice University
*     October 31, 1999
*     June 30, 1999
*     8-15-00:  Improve consistency of WS calculations (eca)
*
*
*     .. Scalar Arguments ..
*     .. Scalar Arguments ..
      CHARACTER          JOBU, JOBVT
      CHARACTER          JOBU, JOBVT
 Lines 114-125    Link Here 
*          LWORK >=  2*MIN(M,N)+MAX(M,N).
*          LWORK >=  2*MIN(M,N)+MAX(M,N).
*          For good performance, LWORK should generally be larger.
*          For good performance, LWORK should generally be larger.
*
*
*          If LWORK = -1, then a workspace query is assumed; the routine
*          If LWORK = -1, a workspace query is assumed.  The optimal
*          only calculates the optimal size of the WORK array, returns
*          size for the WORK array is calculated and stored in WORK(1),
*          this value as the first entry of the WORK array, and no error
*          and no other work except argument checking is performed.
*          message related to LWORK is issued by XERBLA.
*
*
*  RWORK   (workspace) REAL array, dimension (5*min(M,N))
*  RWORK   (workspace) REAL array, dimension
*                                  (5*min(M,N))
*          On exit, if INFO > 0, RWORK(1:MIN(M,N)-1) contains the
*          On exit, if INFO > 0, RWORK(1:MIN(M,N)-1) contains the
*          unconverged superdiagonal elements of an upper bidiagonal
*          unconverged superdiagonal elements of an upper bidiagonal
*          matrix B whose diagonal is in S (not necessarily sorted).
*          matrix B whose diagonal is in S (not necessarily sorted).
 Lines 137-142    Link Here 
*  =====================================================================
*  =====================================================================
*
*
*     .. Parameters ..
*     .. Parameters ..
      INTEGER            LQUERV
      PARAMETER          ( LQUERV = -1 )
      COMPLEX            CZERO, CONE
      COMPLEX            CZERO, CONE
      PARAMETER          ( CZERO = ( 0.0E0, 0.0E0 ),
      PARAMETER          ( CZERO = ( 0.0E0, 0.0E0 ),
     $                   CONE = ( 1.0E0, 0.0E0 ) )
     $                   CONE = ( 1.0E0, 0.0E0 ) )
 Lines 144-151    Link Here 
      PARAMETER          ( ZERO = 0.0E0, ONE = 1.0E0 )
      PARAMETER          ( ZERO = 0.0E0, ONE = 1.0E0 )
*     ..
*     ..
*     .. Local Scalars ..
*     .. Local Scalars ..
      LOGICAL            LQUERY, WNTUA, WNTUAS, WNTUN, WNTUO, WNTUS,
      LOGICAL            WNTUA, WNTUAS, WNTUN, WNTUO, WNTUS, WNTVA,
     $                   WNTVA, WNTVAS, WNTVN, WNTVO, WNTVS
     $                   WNTVAS, WNTVN, WNTVO, WNTVS
      INTEGER            BLK, CHUNK, I, IE, IERR, IR, IRWORK, ISCL,
      INTEGER            BLK, CHUNK, I, IE, IERR, IR, IRWORK, ISCL,
     $                   ITAU, ITAUP, ITAUQ, IU, IWORK, LDWRKR, LDWRKU,
     $                   ITAU, ITAUP, ITAUQ, IU, IWORK, LDWRKR, LDWRKU,
     $                   MAXWRK, MINMN, MINWRK, MNTHR, NCU, NCVT, NRU,
     $                   MAXWRK, MINMN, MINWRK, MNTHR, NCU, NCVT, NRU,
 Lines 188-194    Link Here 
      WNTVO = LSAME( JOBVT, 'O' )
      WNTVO = LSAME( JOBVT, 'O' )
      WNTVN = LSAME( JOBVT, 'N' )
      WNTVN = LSAME( JOBVT, 'N' )
      MINWRK = 1
      MINWRK = 1
      LQUERY = ( LWORK.EQ.-1 )
      MAXWRK = 1
*
*
      IF( .NOT.( WNTUA .OR. WNTUS .OR. WNTUO .OR. WNTUN ) ) THEN
      IF( .NOT.( WNTUA .OR. WNTUS .OR. WNTUO .OR. WNTUN ) ) THEN
         INFO = -1
         INFO = -1
 Lines 216-223    Link Here 
*       real workspace. NB refers to the optimal block size for the
*       real workspace. NB refers to the optimal block size for the
*       immediately following subroutine, as returned by ILAENV.)
*       immediately following subroutine, as returned by ILAENV.)
*
*
      IF( INFO.EQ.0 .AND. ( LWORK.GE.1 .OR. LQUERY ) .AND. M.GT.0 .AND.
      IF( INFO.EQ.0 .AND. M.GT.0 .AND. N.GT.0 ) THEN
     $   N.GT.0 ) THEN
         IF( M.GE.N ) THEN
         IF( M.GE.N ) THEN
*
*
*           Space needed for CBDSQR is BDSPAC = 5*N
*           Space needed for CBDSQR is BDSPAC = 5*N
 Lines 543-566    Link Here 
               MAXWRK = MAX( MINWRK, MAXWRK )
               MAXWRK = MAX( MINWRK, MAXWRK )
            END IF
            END IF
         END IF
         END IF
      END IF
      IF( INFO.EQ.0 ) THEN
         WORK( 1 ) = MAXWRK
         WORK( 1 ) = MAXWRK
         IF( LWORK.LT.MINWRK .AND. LWORK.NE.LQUERV )
     $      INFO = -13
      END IF
      END IF
*
*
      IF( LWORK.LT.MINWRK .AND. .NOT.LQUERY ) THEN
*     Quick returns
         INFO = -13
*
      END IF
      IF( INFO.NE.0 ) THEN
      IF( INFO.NE.0 ) THEN
         CALL XERBLA( 'CGESVD', -INFO )
         CALL XERBLA( 'CGESVD', -INFO )
         RETURN
         RETURN
      ELSE IF( LQUERY ) THEN
         RETURN
      END IF
      END IF
*
      IF( LWORK.EQ.LQUERV ) RETURN
*     Quick return if possible
*
      IF( M.EQ.0 .OR. N.EQ.0 ) THEN
      IF( M.EQ.0 .OR. N.EQ.0 ) THEN
         IF( LWORK.GE.1 )
     $      WORK( 1 ) = ONE
         RETURN
         RETURN
      END IF
      END IF
*
*
(-) LAPACK/SRC/cggbak.f (-3 / +8 lines)
 Lines 4-10    Link Here 
*  -- LAPACK routine (version 3.0) --
*  -- LAPACK routine (version 3.0) --
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Courant Institute, Argonne National Lab, and Rice University
*     Courant Institute, Argonne National Lab, and Rice University
*     September 30, 1994
*     February 1, 2001
*
*
*     .. Scalar Arguments ..
*     .. Scalar Arguments ..
      CHARACTER          JOB, SIDE
      CHARACTER          JOB, SIDE
 Lines 109-118    Link Here 
         INFO = -3
         INFO = -3
      ELSE IF( ILO.LT.1 ) THEN
      ELSE IF( ILO.LT.1 ) THEN
         INFO = -4
         INFO = -4
      ELSE IF( IHI.LT.ILO .OR. IHI.GT.MAX( 1, N ) ) THEN
      ELSE IF( N.EQ.0 .AND. IHI.EQ.0 .AND. ILO.NE.1 ) THEN
         INFO = -4
      ELSE IF( N.GT.0 .AND. ( IHI.LT.ILO .OR. IHI.GT.MAX( 1, N ) ) )
     $   THEN
         INFO = -5
      ELSE IF( N.EQ.0 .AND. ILO.EQ.1 .AND. IHI.NE.0 ) THEN
         INFO = -5
         INFO = -5
      ELSE IF( M.LT.0 ) THEN
      ELSE IF( M.LT.0 ) THEN
         INFO = -6
         INFO = -8
      ELSE IF( LDV.LT.MAX( 1, N ) ) THEN
      ELSE IF( LDV.LT.MAX( 1, N ) ) THEN
         INFO = -10
         INFO = -10
      END IF
      END IF
(-) LAPACK/SRC/cggbal.f (-7 / +7 lines)
 Lines 4-10    Link Here 
*  -- LAPACK routine (version 3.0) --
*  -- LAPACK routine (version 3.0) --
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Courant Institute, Argonne National Lab, and Rice University
*     Courant Institute, Argonne National Lab, and Rice University
*     September 30, 1994
*     April 12, 2001
*
*
*     .. Scalar Arguments ..
*     .. Scalar Arguments ..
      CHARACTER          JOB
      CHARACTER          JOB
 Lines 150-156    Link Here 
      ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
      ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
         INFO = -4
         INFO = -4
      ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
      ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
         INFO = -5
         INFO = -6
      END IF
      END IF
      IF( INFO.NE.0 ) THEN
      IF( INFO.NE.0 ) THEN
         CALL XERBLA( 'CGGBAL', -INFO )
         CALL XERBLA( 'CGGBAL', -INFO )
 Lines 197-204    Link Here 
      IF( L.NE.1 )
      IF( L.NE.1 )
     $   GO TO 30
     $   GO TO 30
*
*
      RSCALE( 1 ) = 1
      RSCALE( 1 ) = ONE
      LSCALE( 1 ) = 1
      LSCALE( 1 ) = ONE
      GO TO 190
      GO TO 190
*
*
   30 CONTINUE
   30 CONTINUE
 Lines 256-262    Link Here 
*     Permute rows M and I
*     Permute rows M and I
*
*
  160 CONTINUE
  160 CONTINUE
      LSCALE( M ) = I
      LSCALE( M ) = REAL( I )
      IF( I.EQ.M )
      IF( I.EQ.M )
     $   GO TO 170
     $   GO TO 170
      CALL CSWAP( N-K+1, A( I, K ), LDA, A( M, K ), LDA )
      CALL CSWAP( N-K+1, A( I, K ), LDA, A( M, K ), LDA )
 Lines 265-271    Link Here 
*     Permute columns M and J
*     Permute columns M and J
*
*
  170 CONTINUE
  170 CONTINUE
      RSCALE( M ) = J
      RSCALE( M ) = REAL( J )
      IF( J.EQ.M )
      IF( J.EQ.M )
     $   GO TO 180
     $   GO TO 180
      CALL CSWAP( L, A( 1, J ), 1, A( 1, M ), 1 )
      CALL CSWAP( L, A( 1, J ), 1, A( 1, M ), 1 )
 Lines 437-443    Link Here 
      DO 360 I = ILO, IHI
      DO 360 I = ILO, IHI
         IRAB = ICAMAX( N-ILO+1, A( I, ILO ), LDA )
         IRAB = ICAMAX( N-ILO+1, A( I, ILO ), LDA )
         RAB = ABS( A( I, IRAB+ILO-1 ) )
         RAB = ABS( A( I, IRAB+ILO-1 ) )
         IRAB = ICAMAX( N-ILO+1, B( I, ILO ), LDA )
         IRAB = ICAMAX( N-ILO+1, B( I, ILO ), LDB )
         RAB = MAX( RAB, ABS( B( I, IRAB+ILO-1 ) ) )
         RAB = MAX( RAB, ABS( B( I, IRAB+ILO-1 ) ) )
         LRAB = INT( LOG10( RAB+SFMIN ) / BASL+ONE )
         LRAB = INT( LOG10( RAB+SFMIN ) / BASL+ONE )
         IR = LSCALE( I ) + SIGN( HALF, LSCALE( I ) )
         IR = LSCALE( I ) + SIGN( HALF, LSCALE( I ) )
(-) LAPACK/SRC/cgges.f (-15 / +12 lines)
 Lines 6-11    Link Here 
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Courant Institute, Argonne National Lab, and Rice University
*     Courant Institute, Argonne National Lab, and Rice University
*     June 30, 1999
*     June 30, 1999
*     8-15-00:  Improve consistency of WS calculations (eca)
*
*
*     .. Scalar Arguments ..
*     .. Scalar Arguments ..
      CHARACTER          JOBVSL, JOBVSR, SORT
      CHARACTER          JOBVSL, JOBVSR, SORT
 Lines 145-154    Link Here 
*          The dimension of the array WORK.  LWORK >= max(1,2*N).
*          The dimension of the array WORK.  LWORK >= max(1,2*N).
*          For good performance, LWORK must generally be larger.
*          For good performance, LWORK must generally be larger.
*
*
*          If LWORK = -1, then a workspace query is assumed; the routine
*          If LWORK = -1, a workspace query is assumed.  The optimal
*          only calculates the optimal size of the WORK array, returns
*          size for the WORK array is calculated and stored in WORK(1),
*          this value as the first entry of the WORK array, and no error
*          and no other work except argument checking is performed.
*          message related to LWORK is issued by XERBLA.
*
*
*  RWORK   (workspace) REAL array, dimension (8*N)
*  RWORK   (workspace) REAL array, dimension (8*N)
*
*
 Lines 173-178    Link Here 
*  =====================================================================
*  =====================================================================
*
*
*     .. Parameters ..
*     .. Parameters ..
      INTEGER            LQUERV
      PARAMETER          ( LQUERV = -1 )
      REAL               ZERO, ONE
      REAL               ZERO, ONE
      PARAMETER          ( ZERO = 0.0E0, ONE = 1.0E0 )
      PARAMETER          ( ZERO = 0.0E0, ONE = 1.0E0 )
      COMPLEX            CZERO, CONE
      COMPLEX            CZERO, CONE
 Lines 181-187    Link Here 
*     ..
*     ..
*     .. Local Scalars ..
*     .. Local Scalars ..
      LOGICAL            CURSL, ILASCL, ILBSCL, ILVSL, ILVSR, LASTSL,
      LOGICAL            CURSL, ILASCL, ILBSCL, ILVSL, ILVSR, LASTSL,
     $                   LQUERY, WANTST
     $                   WANTST
      INTEGER            I, ICOLS, IERR, IHI, IJOBVL, IJOBVR, ILEFT,
      INTEGER            I, ICOLS, IERR, IHI, IJOBVL, IJOBVR, ILEFT,
     $                   ILO, IRIGHT, IROWS, IRWRK, ITAU, IWRK, LWKMIN,
     $                   ILO, IRIGHT, IROWS, IRWRK, ITAU, IWRK, LWKMIN,
     $                   LWKOPT
     $                   LWKOPT
 Lines 237-243    Link Here 
*     Test the input arguments
*     Test the input arguments
*
*
      INFO = 0
      INFO = 0
      LQUERY = ( LWORK.EQ.-1 )
      IF( IJOBVL.LE.0 ) THEN
      IF( IJOBVL.LE.0 ) THEN
         INFO = -1
         INFO = -1
      ELSE IF( IJOBVR.LE.0 ) THEN
      ELSE IF( IJOBVR.LE.0 ) THEN
 Lines 264-270    Link Here 
*       following subroutine, as returned by ILAENV.)
*       following subroutine, as returned by ILAENV.)
*
*
      LWKMIN = 1
      LWKMIN = 1
      IF( INFO.EQ.0 .AND. ( LWORK.GE.1 .OR. LQUERY ) ) THEN
      IF( INFO.EQ.0 ) THEN
         LWKMIN = MAX( 1, 2*N )
         LWKMIN = MAX( 1, 2*N )
         LWKOPT = N + N*ILAENV( 1, 'CGEQRF', ' ', N, 1, N, 0 )
         LWKOPT = N + N*ILAENV( 1, 'CGEQRF', ' ', N, 1, N, 0 )
         IF( ILVSL ) THEN
         IF( ILVSL ) THEN
 Lines 272-292    Link Here 
     $               -1 ) )
     $               -1 ) )
         END IF
         END IF
         WORK( 1 ) = LWKOPT
         WORK( 1 ) = LWKOPT
         IF( LWORK.LT.LWKMIN .AND. LWORK.NE.LQUERV )
     $      INFO = -18
      END IF
      END IF
*
*
      IF( LWORK.LT.LWKMIN .AND. .NOT.LQUERY )
*     Quick return if possible
     $   INFO = -18
*
*
      IF( INFO.NE.0 ) THEN
      IF( INFO.NE.0 ) THEN
         CALL XERBLA( 'CGGES ', -INFO )
         CALL XERBLA( 'CGGES ', -INFO )
         RETURN
         RETURN
      ELSE IF( LQUERY ) THEN
         RETURN
      END IF
      END IF
*
      IF( LWORK.EQ.LQUERV ) RETURN
*     Quick return if possible
*
      WORK( 1 ) = LWKOPT
      IF( N.EQ.0 ) THEN
      IF( N.EQ.0 ) THEN
         SDIM = 0
         SDIM = 0
         RETURN
         RETURN
(-) LAPACK/SRC/cggesx.f (-8 / +20 lines)
 Lines 7-12    Link Here 
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Courant Institute, Argonne National Lab, and Rice University
*     Courant Institute, Argonne National Lab, and Rice University
*     June 30, 1999
*     June 30, 1999
*     8-15-00:  Do WS calculations if LWORK = -1 (eca)
*
*
*     .. Scalar Arguments ..
*     .. Scalar Arguments ..
      CHARACTER          JOBVSL, JOBVSR, SENSE, SORT
      CHARACTER          JOBVSL, JOBVSR, SENSE, SORT
 Lines 167-172    Link Here 
*          If SENSE = 'E', 'V', or 'B',
*          If SENSE = 'E', 'V', or 'B',
*          LWORK >= MAX(2*N, 2*SDIM*(N-SDIM)).
*          LWORK >= MAX(2*N, 2*SDIM*(N-SDIM)).
*
*
*          If LWORK = -1, a workspace query is assumed.  The optimal
*          size for the WORK array is calculated and stored in WORK(1),
*          and no other work except argument checking is performed.
*
*  RWORK   (workspace) REAL array, dimension ( 8*N )
*  RWORK   (workspace) REAL array, dimension ( 8*N )
*          Real workspace.
*          Real workspace.
*
*
 Lines 198-203    Link Here 
*  =====================================================================
*  =====================================================================
*
*
*     .. Parameters ..
*     .. Parameters ..
      INTEGER            LQUERV
      PARAMETER          ( LQUERV = -1 )
      REAL               ZERO, ONE
      REAL               ZERO, ONE
      PARAMETER          ( ZERO = 0.0E+0, ONE = 1.0E+0 )
      PARAMETER          ( ZERO = 0.0E+0, ONE = 1.0E+0 )
      COMPLEX            CZERO, CONE
      COMPLEX            CZERO, CONE
 Lines 304-317    Link Here 
*       following subroutine, as returned by ILAENV.)
*       following subroutine, as returned by ILAENV.)
*
*
      MINWRK = 1
      MINWRK = 1
      IF( INFO.EQ.0 .AND. LWORK.GE.1 ) THEN
      IF( INFO.EQ.0 ) THEN
         MINWRK = MAX( 1, 2*N )
         MINWRK = MAX( 1, 2*N )
         MAXWRK = N + N*ILAENV( 1, 'CGEQRF', ' ', N, 1, N, 0 )
         MAXWRK = N + N*ILAENV( 1, 'CGEQRF', ' ', N, 1, N, 0 )
         IF( ILVSL ) THEN
         IF( ILVSL ) THEN
            MAXWRK = MAX( MAXWRK, N+N*ILAENV( 1, 'CUNGQR', ' ', N, 1, N,
            MAXWRK = MAX( MAXWRK, N+N*ILAENV( 1, 'CUNGQR', ' ', N, 1, N,
     $               -1 ) )
     $               -1 ) )
         END IF
         END IF
*
*        Estimate the workspace needed by CTGSEN.
*
         IF( WANTST ) THEN
            MAXWRK = MAX( MAXWRK, (N*N+1)/2 )
         END IF
         WORK( 1 ) = MAXWRK
         WORK( 1 ) = MAXWRK
         IF( LWORK.LT.MINWRK .AND. LWORK.NE.LQUERV )
     $      INFO = -21
      END IF
      END IF
      IF( .NOT.WANTSN ) THEN
      IF( .NOT.WANTSN ) THEN
         LIWMIN = N+2
         LIWMIN = N+2
 Lines 319-339    Link Here 
         LIWMIN = 1
         LIWMIN = 1
      END IF
      END IF
      IWORK( 1 ) = LIWMIN
      IWORK( 1 ) = LIWMIN
*
      IF( INFO.EQ.0 .AND. IJOB.GE.1 ) THEN
      IF( INFO.EQ.0 .AND. LWORK.LT.MINWRK ) THEN
         INFO = -21
      ELSE IF( INFO.EQ.0 .AND. IJOB.GE.1 ) THEN
         IF( LIWORK.LT.LIWMIN )
         IF( LIWORK.LT.LIWMIN )
     $      INFO = -24
     $      INFO = -24
      END IF
      END IF
*
*
*     Quick returns
*
      IF( INFO.NE.0 ) THEN
      IF( INFO.NE.0 ) THEN
         CALL XERBLA( 'CGGESX', -INFO )
         CALL XERBLA( 'CGGESX', -INFO )
         RETURN
         RETURN
      END IF
      END IF
*
      IF( LWORK.EQ.LQUERV ) RETURN
*     Quick return if possible
*
      IF( N.EQ.0 ) THEN
      IF( N.EQ.0 ) THEN
         SDIM = 0
         SDIM = 0
         RETURN
         RETURN
(-) LAPACK/SRC/cggev.f (-15 / +12 lines)
 Lines 5-10    Link Here 
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Courant Institute, Argonne National Lab, and Rice University
*     Courant Institute, Argonne National Lab, and Rice University
*     June 30, 1999
*     June 30, 1999
*     8-15-00:  Improve consistency of WS calculations (eca)
*
*
*     .. Scalar Arguments ..
*     .. Scalar Arguments ..
      CHARACTER          JOBVL, JOBVR
      CHARACTER          JOBVL, JOBVR
 Lines 113-122    Link Here 
*          The dimension of the array WORK.  LWORK >= max(1,2*N).
*          The dimension of the array WORK.  LWORK >= max(1,2*N).
*          For good performance, LWORK must generally be larger.
*          For good performance, LWORK must generally be larger.
*
*
*          If LWORK = -1, then a workspace query is assumed; the routine
*          If LWORK = -1, a workspace query is assumed.  The optimal
*          only calculates the optimal size of the WORK array, returns
*          size for the WORK array is calculated and stored in WORK(1),
*          this value as the first entry of the WORK array, and no error
*          and no other work except argument checking is performed.
*          message related to LWORK is issued by XERBLA.
*
*
*  RWORK   (workspace/output) REAL array, dimension (8*N)
*  RWORK   (workspace/output) REAL array, dimension (8*N)
*
*
 Lines 133-138    Link Here 
*  =====================================================================
*  =====================================================================
*
*
*     .. Parameters ..
*     .. Parameters ..
      INTEGER            LQUERV
      PARAMETER          ( LQUERV = -1 )
      REAL               ZERO, ONE
      REAL               ZERO, ONE
      PARAMETER          ( ZERO = 0.0E0, ONE = 1.0E0 )
      PARAMETER          ( ZERO = 0.0E0, ONE = 1.0E0 )
      COMPLEX            CZERO, CONE
      COMPLEX            CZERO, CONE
 Lines 140-146    Link Here 
     $                   CONE = ( 1.0E0, 0.0E0 ) )
     $                   CONE = ( 1.0E0, 0.0E0 ) )
*     ..
*     ..
*     .. Local Scalars ..
*     .. Local Scalars ..
      LOGICAL            ILASCL, ILBSCL, ILV, ILVL, ILVR, LQUERY
      LOGICAL            ILASCL, ILBSCL, ILV, ILVL, ILVR
      CHARACTER          CHTEMP
      CHARACTER          CHTEMP
      INTEGER            ICOLS, IERR, IHI, IJOBVL, IJOBVR, ILEFT, ILO,
      INTEGER            ICOLS, IERR, IHI, IJOBVL, IJOBVR, ILEFT, ILO,
     $                   IN, IRIGHT, IROWS, IRWRK, ITAU, IWRK, JC, JR,
     $                   IN, IRIGHT, IROWS, IRWRK, ITAU, IWRK, JC, JR,
 Lines 202-208    Link Here 
*     Test the input arguments
*     Test the input arguments
*
*
      INFO = 0
      INFO = 0
      LQUERY = ( LWORK.EQ.-1 )
      IF( IJOBVL.LE.0 ) THEN
      IF( IJOBVL.LE.0 ) THEN
         INFO = -1
         INFO = -1
      ELSE IF( IJOBVR.LE.0 ) THEN
      ELSE IF( IJOBVR.LE.0 ) THEN
 Lines 228-252    Link Here 
*       computed assuming ILO = 1 and IHI = N, the worst case.)
*       computed assuming ILO = 1 and IHI = N, the worst case.)
*
*
      LWKMIN = 1
      LWKMIN = 1
      IF( INFO.EQ.0 .AND. ( LWORK.GE.1 .OR. LQUERY ) ) THEN
      IF( INFO.EQ.0 ) THEN
         LWKOPT = N + N*ILAENV( 1, 'CGEQRF', ' ', N, 1, N, 0 )
         LWKOPT = N + N*ILAENV( 1, 'CGEQRF', ' ', N, 1, N, 0 )
         LWKMIN = MAX( 1, 2*N )
         LWKMIN = MAX( 1, 2*N )
         WORK( 1 ) = LWKOPT
         WORK( 1 ) = LWKOPT
         IF( LWORK.LT.LWKMIN .AND. LWORK.NE.LQUERV )
     $      INFO = -15
      END IF
      END IF
*
*
      IF( LWORK.LT.LWKMIN .AND. .NOT.LQUERY )
*     Quick returns
     $   INFO = -15
*
*
      IF( INFO.NE.0 ) THEN
      IF( INFO.NE.0 ) THEN
         CALL XERBLA( 'CGGEV ', -INFO )
         CALL XERBLA( 'CGGEV ', -INFO )
         RETURN
         RETURN
      ELSE IF( LQUERY ) THEN
         RETURN
      END IF
      END IF
*
      IF( LWORK.EQ.LQUERV ) RETURN
*     Quick return if possible
*
      WORK( 1 ) = LWKOPT
      IF( N.EQ.0 )
      IF( N.EQ.0 )
     $   RETURN
     $   RETURN
*
*
(-) LAPACK/SRC/cggevx.f (-16 / +13 lines)
 Lines 7-12    Link Here 
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Courant Institute, Argonne National Lab, and Rice University
*     Courant Institute, Argonne National Lab, and Rice University
*     June 30, 1999
*     June 30, 1999
*     8-15-00:  Improve consistency of WS calculations (eca)
*
*
*     .. Scalar Arguments ..
*     .. Scalar Arguments ..
      CHARACTER          BALANC, JOBVL, JOBVR, SENSE
      CHARACTER          BALANC, JOBVL, JOBVR, SENSE
 Lines 194-203    Link Here 
*          If SENSE = 'N' or 'E', LWORK >= 2*N.
*          If SENSE = 'N' or 'E', LWORK >= 2*N.
*          If SENSE = 'V' or 'B', LWORK >= 2*N*N+2*N.
*          If SENSE = 'V' or 'B', LWORK >= 2*N*N+2*N.
*
*
*          If LWORK = -1, then a workspace query is assumed; the routine
*          If LWORK = -1, a workspace query is assumed.  The optimal
*          only calculates the optimal size of the WORK array, returns
*          size for the WORK array is calculated and stored in WORK(1),
*          this value as the first entry of the WORK array, and no error
*          and no other work except argument checking is performed.
*          message related to LWORK is issued by XERBLA.
*
*
*  RWORK   (workspace) REAL array, dimension (6*N)
*  RWORK   (workspace) REAL array, dimension (6*N)
*          Real workspace.
*          Real workspace.
 Lines 247-252    Link Here 
*  =====================================================================
*  =====================================================================
*
*
*     .. Parameters ..
*     .. Parameters ..
      INTEGER            LQUERV
      PARAMETER          ( LQUERV = -1 )
      REAL               ZERO, ONE
      REAL               ZERO, ONE
      PARAMETER          ( ZERO = 0.0E+0, ONE = 1.0E+0 )
      PARAMETER          ( ZERO = 0.0E+0, ONE = 1.0E+0 )
      COMPLEX            CZERO, CONE
      COMPLEX            CZERO, CONE
 Lines 254-261    Link Here 
     $                   CONE = ( 1.0E+0, 0.0E+0 ) )
     $                   CONE = ( 1.0E+0, 0.0E+0 ) )
*     ..
*     ..
*     .. Local Scalars ..
*     .. Local Scalars ..
      LOGICAL            ILASCL, ILBSCL, ILV, ILVL, ILVR, LQUERY,
      LOGICAL            ILASCL, ILBSCL, ILV, ILVL, ILVR, WANTSB,
     $                   WANTSB, WANTSE, WANTSN, WANTSV
     $                   WANTSE, WANTSN, WANTSV
      CHARACTER          CHTEMP
      CHARACTER          CHTEMP
      INTEGER            I, ICOLS, IERR, IJOBVL, IJOBVR, IN, IROWS,
      INTEGER            I, ICOLS, IERR, IJOBVL, IJOBVR, IN, IROWS,
     $                   ITAU, IWRK, IWRK1, J, JC, JR, M, MAXWRK, MINWRK
     $                   ITAU, IWRK, IWRK1, J, JC, JR, M, MAXWRK, MINWRK
 Lines 321-327    Link Here 
*     Test the input arguments
*     Test the input arguments
*
*
      INFO = 0
      INFO = 0
      LQUERY = ( LWORK.EQ.-1 )
      IF( .NOT.( LSAME( BALANC, 'N' ) .OR. LSAME( BALANC,
      IF( .NOT.( LSAME( BALANC, 'N' ) .OR. LSAME( BALANC,
     $    'S' ) .OR. LSAME( BALANC, 'P' ) .OR. LSAME( BALANC, 'B' ) ) )
     $    'S' ) .OR. LSAME( BALANC, 'P' ) .OR. LSAME( BALANC, 'B' ) ) )
     $     THEN
     $     THEN
 Lines 354-360    Link Here 
*       computed assuming ILO = 1 and IHI = N, the worst case.)
*       computed assuming ILO = 1 and IHI = N, the worst case.)
*
*
      MINWRK = 1
      MINWRK = 1
      IF( INFO.EQ.0 .AND. ( LWORK.GE.1 .OR. LQUERY ) ) THEN
      IF( INFO.EQ.0 ) THEN
         MAXWRK = N + N*ILAENV( 1, 'CGEQRF', ' ', N, 1, N, 0 )
         MAXWRK = N + N*ILAENV( 1, 'CGEQRF', ' ', N, 1, N, 0 )
         IF( WANTSE ) THEN
         IF( WANTSE ) THEN
            MINWRK = MAX( 1, 2*N )
            MINWRK = MAX( 1, 2*N )
 Lines 363-383    Link Here 
            MAXWRK = MAX( MAXWRK, 2*N*N+2*N )
            MAXWRK = MAX( MAXWRK, 2*N*N+2*N )
         END IF
         END IF
         WORK( 1 ) = MAXWRK
         WORK( 1 ) = MAXWRK
         IF( LWORK.LT.MINWRK .AND. LWORK.NE.LQUERV )
     $      INFO = -25
      END IF
      END IF
*
*
      IF( LWORK.LT.MINWRK .AND. .NOT.LQUERY ) THEN
*     Quick returns
         INFO = -25
      END IF
*
*
      IF( INFO.NE.0 ) THEN
      IF( INFO.NE.0 ) THEN
         CALL XERBLA( 'CGGEVX', -INFO )
         CALL XERBLA( 'CGGEVX', -INFO )
         RETURN
         RETURN
      ELSE IF( LQUERY ) THEN
         RETURN
      END IF
      END IF
*
      IF( LWORK.EQ.LQUERV ) RETURN
*     Quick return if possible
*
      IF( N.EQ.0 )
      IF( N.EQ.0 )
     $   RETURN
     $   RETURN
*
*
(-) LAPACK/SRC/cgghrd.f (-26 / +35 lines)
 Lines 4-10    Link Here 
*  -- LAPACK routine (version 3.0) --
*  -- LAPACK routine (version 3.0) --
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Courant Institute, Argonne National Lab, and Rice University
*     Courant Institute, Argonne National Lab, and Rice University
*     September 30, 1994
*     April 26, 2001
*
*
*     .. Scalar Arguments ..
*     .. Scalar Arguments ..
      CHARACTER          COMPQ, COMPZ
      CHARACTER          COMPQ, COMPZ
 Lines 20-35    Link Here 
*
*
*  CGGHRD reduces a pair of complex matrices (A,B) to generalized upper
*  CGGHRD reduces a pair of complex matrices (A,B) to generalized upper
*  Hessenberg form using unitary transformations, where A is a
*  Hessenberg form using unitary transformations, where A is a
*  general matrix and B is upper triangular:  Q' * A * Z = H and
*  general matrix and B is upper triangular.  The form of the generalized
*  Q' * B * Z = T, where H is upper Hessenberg, T is upper triangular,
*  eigenvalue problem is
*  and Q and Z are unitary, and ' means conjugate transpose.
*     A*x = lambda*B*x,
*  and B is typically made upper triangular by computing its QR
*  factorization and moving the unitary matrix Q to the left side
*  of the equation.
*
*  This subroutine simultaneously reduces A to a Hessenberg matrix H:
*     Q**H*A*Z = H
*  and transforms B to another upper triangular matrix T:
*     Q**H*B*Z = T
*  in order to reduce the problem to its standard form
*     H*y = lambda*T*y
*  where y = Z**H*x.
*
*
*  The unitary matrices Q and Z are determined as products of Givens
*  The unitary matrices Q and Z are determined as products of Givens
*  rotations.  They may either be formed explicitly, or they may be
*  rotations.  They may either be formed explicitly, or they may be
*  postmultiplied into input matrices Q1 and Z1, so that
*  postmultiplied into input matrices Q1 and Z1, so that
*
*       Q1 * A * Z1**H = (Q1*Q) * H * (Z1*Z)**H
*       Q1 * A * Z1' = (Q1*Q) * H * (Z1*Z)'
*       Q1 * B * Z1**H = (Q1*Q) * T * (Z1*Z)**H
*       Q1 * B * Z1' = (Q1*Q) * T * (Z1*Z)'
*  If Q1 is the unitary matrix from the QR factorization of B in the
*  original equation A*x = lambda*B*x, then CGGHRD reduces the original
*  problem to generalized Hessenberg form.
*
*
*  Arguments
*  Arguments
*  =========
*  =========
 Lines 53-62    Link Here 
*
*
*  ILO     (input) INTEGER
*  ILO     (input) INTEGER
*  IHI     (input) INTEGER
*  IHI     (input) INTEGER
*          It is assumed that A is already upper triangular in rows and
*          ILO and IHI mark the rows and columns of A which are to be
*          columns 1:ILO-1 and IHI+1:N.  ILO and IHI are normally set
*          reduced.  It is assumed that A is already upper triangular
*          by a previous call to CGGBAL; otherwise they should be set
*          in rows and columns 1:ILO-1 and IHI+1:N.  ILO and IHI are
*          to 1 and N respectively.
*          normally set by a previous call to CGGBAL; otherwise they
*          should be set to 1 and N respectively.
*          1 <= ILO <= IHI <= N, if N > 0; ILO=1 and IHI=0, if N=0.
*          1 <= ILO <= IHI <= N, if N > 0; ILO=1 and IHI=0, if N=0.
*
*
*  A       (input/output) COMPLEX array, dimension (LDA, N)
*  A       (input/output) COMPLEX array, dimension (LDA, N)
 Lines 70-102    Link Here 
*
*
*  B       (input/output) COMPLEX array, dimension (LDB, N)
*  B       (input/output) COMPLEX array, dimension (LDB, N)
*          On entry, the N-by-N upper triangular matrix B.
*          On entry, the N-by-N upper triangular matrix B.
*          On exit, the upper triangular matrix T = Q' B Z.  The
*          On exit, the upper triangular matrix T = Q**H B Z.  The
*          elements below the diagonal are set to zero.
*          elements below the diagonal are set to zero.
*
*
*  LDB     (input) INTEGER
*  LDB     (input) INTEGER
*          The leading dimension of the array B.  LDB >= max(1,N).
*          The leading dimension of the array B.  LDB >= max(1,N).
*
*
*  Q       (input/output) COMPLEX array, dimension (LDQ, N)
*  Q       (input/output) COMPLEX array, dimension (LDQ, N)
*          If COMPQ='N':  Q is not referenced.
*          On entry, if COMPQ = 'V', the unitary matrix Q1, typically
*          If COMPQ='I':  on entry, Q need not be set, and on exit it
*          from the QR factorization of B.
*                         contains the unitary matrix Q, where Q'
*          On exit, if COMPQ='I', the unitary matrix Q, and if
*                         is the product of the Givens transformations
*          COMPQ = 'V', the product Q1*Q.
*                         which are applied to A and B on the left.
*          Not referenced if COMPQ='N'.
*          If COMPQ='V':  on entry, Q must contain a unitary matrix
*                         Q1, and on exit this is overwritten by Q1*Q.
*
*
*  LDQ     (input) INTEGER
*  LDQ     (input) INTEGER
*          The leading dimension of the array Q.
*          The leading dimension of the array Q.
*          LDQ >= N if COMPQ='V' or 'I'; LDQ >= 1 otherwise.
*          LDQ >= N if COMPQ='V' or 'I'; LDQ >= 1 otherwise.
*
*
*  Z       (input/output) COMPLEX array, dimension (LDZ, N)
*  Z       (input/output) COMPLEX array, dimension (LDZ, N)
*          If COMPZ='N':  Z is not referenced.
*          On entry, if COMPZ = 'V', the unitary matrix Z1.
*          If COMPZ='I':  on entry, Z need not be set, and on exit it
*          On exit, if COMPZ='I', the unitary matrix Z, and if
*                         contains the unitary matrix Z, which is
*          COMPZ = 'V', the product Z1*Z.
*                         the product of the Givens transformations
*          Not referenced if COMPZ='N'.
*                         which are applied to A and B on the right.
*          If COMPZ='V':  on entry, Z must contain a unitary matrix
*                         Z1, and on exit this is overwritten by Z1*Z.
*
*
*  LDZ     (input) INTEGER
*  LDZ     (input) INTEGER
*          The leading dimension of the array Z.
*          The leading dimension of the array Z.
(-) LAPACK/SRC/chbgst.f (-2 / +2 lines)
 Lines 4-10    Link Here 
*  -- LAPACK routine (version 3.0) --
*  -- LAPACK routine (version 3.0) --
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Courant Institute, Argonne National Lab, and Rice University
*     Courant Institute, Argonne National Lab, and Rice University
*     June 30, 1999
*     January 9, 2001
*
*
*     .. Scalar Arguments ..
*     .. Scalar Arguments ..
      CHARACTER          UPLO, VECT
      CHARACTER          UPLO, VECT
 Lines 131-137    Link Here 
         INFO = -3
         INFO = -3
      ELSE IF( KA.LT.0 ) THEN
      ELSE IF( KA.LT.0 ) THEN
         INFO = -4
         INFO = -4
      ELSE IF( KB.LT.0 ) THEN
      ELSE IF( KB.LT.0 .OR. KB.GT.KA ) THEN
         INFO = -5
         INFO = -5
      ELSE IF( LDAB.LT.KA+1 ) THEN
      ELSE IF( LDAB.LT.KA+1 ) THEN
         INFO = -7
         INFO = -7
(-) LAPACK/SRC/chgeqz.f (-209 / +234 lines)
 Lines 1-43    Link Here 
      SUBROUTINE CHGEQZ( JOB, COMPQ, COMPZ, N, ILO, IHI, A, LDA, B, LDB,
      SUBROUTINE CHGEQZ( JOB, COMPQ, COMPZ, N, ILO, IHI, H, LDH, T, LDT,
     $                   ALPHA, BETA, Q, LDQ, Z, LDZ, WORK, LWORK,
     $                   ALPHA, BETA, Q, LDQ, Z, LDZ, WORK, LWORK,
     $                   RWORK, INFO )
     $                   RWORK, INFO )
*
*
*  -- LAPACK routine (version 3.0) --
*  -- LAPACK routine (version 3.0) --
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Courant Institute, Argonne National Lab, and Rice University
*     Courant Institute, Argonne National Lab, and Rice University
*     June 30, 1999
*     May 3, 2001
*
*
*     .. Scalar Arguments ..
*     .. Scalar Arguments ..
      CHARACTER          COMPQ, COMPZ, JOB
      CHARACTER          COMPQ, COMPZ, JOB
      INTEGER            IHI, ILO, INFO, LDA, LDB, LDQ, LDZ, LWORK, N
      INTEGER            IHI, ILO, INFO, LDH, LDQ, LDT, LDZ, LWORK, N
*     ..
*     ..
*     .. Array Arguments ..
*     .. Array Arguments ..
      REAL               RWORK( * )
      REAL               RWORK( * )
      COMPLEX            A( LDA, * ), ALPHA( * ), B( LDB, * ),
      COMPLEX            ALPHA( * ), BETA( * ), H( LDH, * ),
     $                   BETA( * ), Q( LDQ, * ), WORK( * ), Z( LDZ, * )
     $                   Q( LDQ, * ), T( LDT, * ), WORK( * ),
     $                   Z( LDZ, * )
*     ..
*     ..
*
*
*  Purpose
*  Purpose
*  =======
*  =======
*
*
*  CHGEQZ implements a single-shift version of the QZ
*  CHGEQZ computes the eigenvalues of a complex matrix pair (H,T),
*  method for finding the generalized eigenvalues w(i)=ALPHA(i)/BETA(i)
*  where H is an upper Hessenberg matrix and T is upper triangular,
*  of the equation
*  using the single-shift QZ method.
*
*  Matrix pairs of this type are produced by the reduction to
*       det( A - w(i) B ) = 0
*  generalized upper Hessenberg form of a complex matrix pair (A,B):
*
*  
*  If JOB='S', then the pair (A,B) is simultaneously
*     A = Q1*H*Z1**H,  B = Q1*T*Z1**H,
*  reduced to Schur form (i.e., A and B are both upper triangular) by
*  
*  applying one unitary tranformation (usually called Q) on the left and
*  as computed by CGGHRD.
*  another (usually called Z) on the right.  The diagonal elements of
*  
*  A are then ALPHA(1),...,ALPHA(N), and of B are BETA(1),...,BETA(N).
*  If JOB='S', then the Hessenberg-triangular pair (H,T) is
*
*  also reduced to generalized Schur form,
*  If JOB='S' and COMPQ and COMPZ are 'V' or 'I', then the unitary
*  
*  transformations used to reduce (A,B) are accumulated into the arrays
*     H = Q*S*Z**H,  T = Q*P*Z**H,
*  Q and Z s.t.:
*  
*
*  where Q and Z are unitary matrices and S and P are upper triangular.
*       Q(in) A(in) Z(in)* = Q(out) A(out) Z(out)*
*  
*       Q(in) B(in) Z(in)* = Q(out) B(out) Z(out)*
*  Optionally, the unitary matrix Q from the generalized Schur
*  factorization may be postmultiplied into an input matrix Q1, and the
*  unitary matrix Z may be postmultiplied into an input matrix Z1.
*  If Q1 and Z1 are the unitary matrices from CGGHRD that reduced
*  the matrix pair (A,B) to generalized Hessenberg form, then the output
*  matrices Q1*Q and Z1*Z are the unitary factors from the generalized
*  Schur factorization of (A,B):
*  
*     A = (Q1*Q)*S*(Z1*Z)**H,  B = (Q1*Q)*P*(Z1*Z)**H.
*  
*  To avoid overflow, eigenvalues of the matrix pair (H,T)
*  (equivalently, of (A,B)) are computed as a pair of complex values
*  (alpha,beta).  If beta is nonzero, lambda = alpha / beta is an
*  eigenvalue of the generalized nonsymmetric eigenvalue problem (GNEP)
*     A*x = lambda*B*x
*  and if alpha is nonzero, mu = beta / alpha is an eigenvalue of the
*  alternate form of the GNEP
*     mu*A*y = B*y.
*  The values of alpha and beta for the i-th eigenvalue can be read
*  directly from the generalized Schur form:  alpha = S(i,i),
*  beta = P(i,i).
*
*
*  Ref: C.B. Moler & G.W. Stewart, "An Algorithm for Generalized Matrix
*  Ref: C.B. Moler & G.W. Stewart, "An Algorithm for Generalized Matrix
*       Eigenvalue Problems", SIAM J. Numer. Anal., 10(1973),
*       Eigenvalue Problems", SIAM J. Numer. Anal., 10(1973),
 Lines 47-129    Link Here 
*  =========
*  =========
*
*
*  JOB     (input) CHARACTER*1
*  JOB     (input) CHARACTER*1
*          = 'E': compute only ALPHA and BETA.  A and B will not
*          = 'E': Compute eigenvalues only;
*                 necessarily be put into generalized Schur form.
*          = 'S': Computer eigenvalues and the Schur form.
*          = 'S': put A and B into generalized Schur form, as well
*                 as computing ALPHA and BETA.
*
*
*  COMPQ   (input) CHARACTER*1
*  COMPQ   (input) CHARACTER*1
*          = 'N': do not modify Q.
*          = 'N': Left Schur vectors (Q) are not computed;
*          = 'V': multiply the array Q on the right by the conjugate
*          = 'I': Q is initialized to the unit matrix and the matrix Q
*                 transpose of the unitary tranformation that is
*                 of left Schur vectors of (H,T) is returned;
*                 applied to the left side of A and B to reduce them
*          = 'V': Q must contain a unitary matrix Q1 on entry and
*                 to Schur form.
*                 the product Q1*Q is returned.
*          = 'I': like COMPQ='V', except that Q will be initialized to
*                 the identity first.
*
*
*  COMPZ   (input) CHARACTER*1
*  COMPZ   (input) CHARACTER*1
*          = 'N': do not modify Z.
*          = 'N': Right Schur vectors (Z) are not computed;
*          = 'V': multiply the array Z on the right by the unitary
*          = 'I': Q is initialized to the unit matrix and the matrix Z
*                 tranformation that is applied to the right side of
*                 of right Schur vectors of (H,T) is returned;
*                 A and B to reduce them to Schur form.
*          = 'V': Z must contain a unitary matrix Z1 on entry and
*          = 'I': like COMPZ='V', except that Z will be initialized to
*                 the product Z1*Z is returned.
*                 the identity first.
*
*
*  N       (input) INTEGER
*  N       (input) INTEGER
*          The order of the matrices A, B, Q, and Z.  N >= 0.
*          The order of the matrices H, T, Q, and Z.  N >= 0.
*
*
*  ILO     (input) INTEGER
*  ILO     (input) INTEGER
*  IHI     (input) INTEGER
*  IHI     (input) INTEGER
*          It is assumed that A is already upper triangular in rows and
*          ILO and IHI mark the rows and columns of H which are in
*          columns 1:ILO-1 and IHI+1:N.
*          Hessenberg form.  It is assumed that A is already upper
*          1 <= ILO <= IHI <= N, if N > 0; ILO=1 and IHI=0, if N=0.
*          triangular in rows and columns 1:ILO-1 and IHI+1:N.
*
*          If N > 0, 1 <= ILO <= IHI <= N; if N = 0, ILO=1 and IHI=0.
*  A       (input/output) COMPLEX array, dimension (LDA, N)
*
*          On entry, the N-by-N upper Hessenberg matrix A.  Elements
*  H       (input/output) COMPLEX array, dimension (LDH, N)
*          below the subdiagonal must be zero.
*          On entry, the N-by-N upper Hessenberg matrix H.
*          If JOB='S', then on exit A and B will have been
*          On exit, if JOB = 'S', H contains the upper triangular
*             simultaneously reduced to upper triangular form.
*          matrix S from the generalized Schur factorization.
*          If JOB='E', then on exit A will have been destroyed.
*          If JOB = 'E', the diagonal of H matches that of S, but
*
*          the rest of H is unspecified.
*  LDA     (input) INTEGER
*
*          The leading dimension of the array A.  LDA >= max( 1, N ).
*  LDH     (input) INTEGER
*
*          The leading dimension of the array H.  LDH >= max( 1, N ).
*  B       (input/output) COMPLEX array, dimension (LDB, N)
*
*          On entry, the N-by-N upper triangular matrix B.  Elements
*  T       (input/output) COMPLEX array, dimension (LDT, N)
*          below the diagonal must be zero.
*          On entry, the N-by-N upper triangular matrix T.
*          If JOB='S', then on exit A and B will have been
*          On exit, if JOB = 'S', T contains the upper triangular
*             simultaneously reduced to upper triangular form.
*          matrix P from the generalized Schur factorization.
*          If JOB='E', then on exit B will have been destroyed.
*          If JOB = 'E', the diagonal of T matches that of P, but
*          the rest of T is unspecified.
*
*
*  LDB     (input) INTEGER
*  LDT     (input) INTEGER
*          The leading dimension of the array B.  LDB >= max( 1, N ).
*          The leading dimension of the array T.  LDT >= max( 1, N ).
*
*
*  ALPHA   (output) COMPLEX array, dimension (N)
*  ALPHA   (output) COMPLEX array, dimension (N)
*          The diagonal elements of A when the pair (A,B) has been
*          The complex scalars alpha that define the eigenvalues of
*          reduced to Schur form.  ALPHA(i)/BETA(i) i=1,...,N
*          GNEP.  ALPHA(i) = S(i,i) in the generalized Schur
*          are the generalized eigenvalues.
*          factorization.
*
*
*  BETA    (output) COMPLEX array, dimension (N)
*  BETA    (output) COMPLEX array, dimension (N)
*          The diagonal elements of B when the pair (A,B) has been
*          The real non-negative scalars beta that define the
*          reduced to Schur form.  ALPHA(i)/BETA(i) i=1,...,N
*          eigenvalues of GNEP.  BETA(i) = P(i,i) in the generalized
*          are the generalized eigenvalues.  A and B are normalized
*          Schur factorization.
*          so that BETA(1),...,BETA(N) are non-negative real numbers.
*
*          Together, the quantities alpha = ALPHA(j) and beta = BETA(j)
*          represent the j-th eigenvalue of the matrix pair (A,B), in
*          one of the forms lambda = alpha/beta or mu = beta/alpha.
*          Since either lambda or mu may overflow, they should not,
*          in general, be computed.
*
*
*  Q       (input/output) COMPLEX array, dimension (LDQ, N)
*  Q       (input/output) COMPLEX array, dimension (LDQ, N)
*          If COMPQ='N', then Q will not be referenced.
*          On entry, if COMPZ = 'V', the unitary matrix Q1 used in the
*          If COMPQ='V' or 'I', then the conjugate transpose of the
*          reduction of (A,B) to generalized Hessenberg form.
*             unitary transformations which are applied to A and B on
*          On exit, if COMPZ = 'I', the unitary matrix of left Schur
*             the left will be applied to the array Q on the right.
*          vectors of (H,T), and if COMPZ = 'V', the unitary matrix of
*          left Schur vectors of (A,B).
*          Not referenced if COMPZ = 'N'.
*
*
*  LDQ     (input) INTEGER
*  LDQ     (input) INTEGER
*          The leading dimension of the array Q.  LDQ >= 1.
*          The leading dimension of the array Q.  LDQ >= 1.
*          If COMPQ='V' or 'I', then LDQ >= N.
*          If COMPQ='V' or 'I', then LDQ >= N.
*
*
*  Z       (input/output) COMPLEX array, dimension (LDZ, N)
*  Z       (input/output) COMPLEX array, dimension (LDZ, N)
*          If COMPZ='N', then Z will not be referenced.
*          On entry, if COMPZ = 'V', the unitary matrix Z1 used in the
*          If COMPZ='V' or 'I', then the unitary transformations which
*          reduction of (A,B) to generalized Hessenberg form.
*             are applied to A and B on the right will be applied to the
*          On exit, if COMPZ = 'I', the unitary matrix of right Schur
*             array Z on the right.
*          vectors of (H,T), and if COMPZ = 'V', the unitary matrix of
*          right Schur vectors of (A,B).
*          Not referenced if COMPZ = 'N'.
*
*
*  LDZ     (input) INTEGER
*  LDZ     (input) INTEGER
*          The leading dimension of the array Z.  LDZ >= 1.
*          The leading dimension of the array Z.  LDZ >= 1.
 Lines 145-157    Link Here 
*  INFO    (output) INTEGER
*  INFO    (output) INTEGER
*          = 0: successful exit
*          = 0: successful exit
*          < 0: if INFO = -i, the i-th argument had an illegal value
*          < 0: if INFO = -i, the i-th argument had an illegal value
*          = 1,...,N: the QZ iteration did not converge.  (A,B) is not
*          = 1,...,N: the QZ iteration did not converge.  (H,T) is not
*                     in Schur form, but ALPHA(i) and BETA(i),
*                     in Schur form, but ALPHA(i) and BETA(i),
*                     i=INFO+1,...,N should be correct.
*                     i=INFO+1,...,N should be correct.
*          = N+1,...,2*N: the shift calculation failed.  (A,B) is not
*          = N+1,...,2*N: the shift calculation failed.  (H,T) is not
*                     in Schur form, but ALPHA(i) and BETA(i),
*                     in Schur form, but ALPHA(i) and BETA(i),
*                     i=INFO-N+1,...,N should be correct.
*                     i=INFO-N+1,...,N should be correct.
*          > 2*N:     various "impossible" errors.
*
*
*  Further Details
*  Further Details
*  ===============
*  ===============
 Lines 178-184    Link Here 
      REAL               ABSB, ANORM, ASCALE, ATOL, BNORM, BSCALE, BTOL,
      REAL               ABSB, ANORM, ASCALE, ATOL, BNORM, BSCALE, BTOL,
     $                   C, SAFMIN, TEMP, TEMP2, TEMPR, ULP
     $                   C, SAFMIN, TEMP, TEMP2, TEMPR, ULP
      COMPLEX            ABI22, AD11, AD12, AD21, AD22, CTEMP, CTEMP2,
      COMPLEX            ABI22, AD11, AD12, AD21, AD22, CTEMP, CTEMP2,
     $                   CTEMP3, ESHIFT, RTDISC, S, SHIFT, SIGNBC, T,
     $                   CTEMP3, ESHIFT, RTDISC, S, SHIFT, SIGNBC, T1,
     $                   U12, X
     $                   U12, X
*     ..
*     ..
*     .. External Functions ..
*     .. External Functions ..
 Lines 255-263    Link Here 
         INFO = -5
         INFO = -5
      ELSE IF( IHI.GT.N .OR. IHI.LT.ILO-1 ) THEN
      ELSE IF( IHI.GT.N .OR. IHI.LT.ILO-1 ) THEN
         INFO = -6
         INFO = -6
      ELSE IF( LDA.LT.N ) THEN
      ELSE IF( LDH.LT.N ) THEN
         INFO = -8
         INFO = -8
      ELSE IF( LDB.LT.N ) THEN
      ELSE IF( LDT.LT.N ) THEN
         INFO = -10
         INFO = -10
      ELSE IF( LDQ.LT.1 .OR. ( ILQ .AND. LDQ.LT.N ) ) THEN
      ELSE IF( LDQ.LT.1 .OR. ( ILQ .AND. LDQ.LT.N ) ) THEN
         INFO = -14
         INFO = -14
 Lines 293-300    Link Here 
      IN = IHI + 1 - ILO
      IN = IHI + 1 - ILO
      SAFMIN = SLAMCH( 'S' )
      SAFMIN = SLAMCH( 'S' )
      ULP = SLAMCH( 'E' )*SLAMCH( 'B' )
      ULP = SLAMCH( 'E' )*SLAMCH( 'B' )
      ANORM = CLANHS( 'F', IN, A( ILO, ILO ), LDA, RWORK )
      ANORM = CLANHS( 'F', IN, H( ILO, ILO ), LDH, RWORK )
      BNORM = CLANHS( 'F', IN, B( ILO, ILO ), LDB, RWORK )
      BNORM = CLANHS( 'F', IN, T( ILO, ILO ), LDT, RWORK )
      ATOL = MAX( SAFMIN, ULP*ANORM )
      ATOL = MAX( SAFMIN, ULP*ANORM )
      BTOL = MAX( SAFMIN, ULP*BNORM )
      BTOL = MAX( SAFMIN, ULP*BNORM )
      ASCALE = ONE / MAX( SAFMIN, ANORM )
      ASCALE = ONE / MAX( SAFMIN, ANORM )
 Lines 304-326    Link Here 
*     Set Eigenvalues IHI+1:N
*     Set Eigenvalues IHI+1:N
*
*
      DO 10 J = IHI + 1, N
      DO 10 J = IHI + 1, N
         ABSB = ABS( B( J, J ) )
         ABSB = ABS( T( J, J ) )
         IF( ABSB.GT.SAFMIN ) THEN
         IF( ABSB.GT.SAFMIN ) THEN
            SIGNBC = CONJG( B( J, J ) / ABSB )
            SIGNBC = CONJG( T( J, J ) / ABSB )
            B( J, J ) = ABSB
            T( J, J ) = ABSB
            IF( ILSCHR ) THEN
            IF( ILSCHR ) THEN
               CALL CSCAL( J-1, SIGNBC, B( 1, J ), 1 )
               CALL CSCAL( J-1, SIGNBC, T( 1, J ), 1 )
               CALL CSCAL( J, SIGNBC, A( 1, J ), 1 )
               CALL CSCAL( J, SIGNBC, H( 1, J ), 1 )
            ELSE
            ELSE
               A( J, J ) = A( J, J )*SIGNBC
               H( J, J ) = H( J, J )*SIGNBC
            END IF
            END IF
            IF( ILZ )
            IF( ILZ )
     $         CALL CSCAL( N, SIGNBC, Z( 1, J ), 1 )
     $         CALL CSCAL( N, SIGNBC, Z( 1, J ), 1 )
         ELSE
         ELSE
            B( J, J ) = CZERO
            T( J, J ) = CZERO
         END IF
         END IF
         ALPHA( J ) = A( J, J )
         ALPHA( J ) = H( J, J )
         BETA( J ) = B( J, J )
         BETA( J ) = T( J, J )
   10 CONTINUE
   10 CONTINUE
*
*
*     If IHI < ILO, skip QZ steps
*     If IHI < ILO, skip QZ steps
 Lines 365-386    Link Here 
*        Split the matrix if possible.
*        Split the matrix if possible.
*
*
*        Two tests:
*        Two tests:
*           1: A(j,j-1)=0  or  j=ILO
*           1: H(j,j-1)=0  or  j=ILO
*           2: B(j,j)=0
*           2: T(j,j)=0
*
*
*        Special case: j=ILAST
*        Special case: j=ILAST
*
*
         IF( ILAST.EQ.ILO ) THEN
         IF( ILAST.EQ.ILO ) THEN
            GO TO 60
            GO TO 60
         ELSE
         ELSE
            IF( ABS1( A( ILAST, ILAST-1 ) ).LE.ATOL ) THEN
            IF( ABS1( H( ILAST, ILAST-1 ) ).LE.ATOL ) THEN
               A( ILAST, ILAST-1 ) = CZERO
               H( ILAST, ILAST-1 ) = CZERO
               GO TO 60
               GO TO 60
            END IF
            END IF
         END IF
         END IF
*
*
         IF( ABS( B( ILAST, ILAST ) ).LE.BTOL ) THEN
         IF( ABS( T( ILAST, ILAST ) ).LE.BTOL ) THEN
            B( ILAST, ILAST ) = CZERO
            T( ILAST, ILAST ) = CZERO
            GO TO 50
            GO TO 50
         END IF
         END IF
*
*
 Lines 388-417    Link Here 
*
*
         DO 40 J = ILAST - 1, ILO, -1
         DO 40 J = ILAST - 1, ILO, -1
*
*
*           Test 1: for A(j,j-1)=0 or j=ILO
*           Test 1: for H(j,j-1)=0 or j=ILO
*
*
            IF( J.EQ.ILO ) THEN
            IF( J.EQ.ILO ) THEN
               ILAZRO = .TRUE.
               ILAZRO = .TRUE.
            ELSE
            ELSE
               IF( ABS1( A( J, J-1 ) ).LE.ATOL ) THEN
               IF( ABS1( H( J, J-1 ) ).LE.ATOL ) THEN
                  A( J, J-1 ) = CZERO
                  H( J, J-1 ) = CZERO
                  ILAZRO = .TRUE.
                  ILAZRO = .TRUE.
               ELSE
               ELSE
                  ILAZRO = .FALSE.
                  ILAZRO = .FALSE.
               END IF
               END IF
            END IF
            END IF
*
*
*           Test 2: for B(j,j)=0
*           Test 2: for T(j,j)=0
*
*
            IF( ABS( B( J, J ) ).LT.BTOL ) THEN
            IF( ABS( T( J, J ) ).LT.BTOL ) THEN
               B( J, J ) = CZERO
               T( J, J ) = CZERO
*
*
*              Test 1a: Check for 2 consecutive small subdiagonals in A
*              Test 1a: Check for 2 consecutive small subdiagonals in A
*
*
               ILAZR2 = .FALSE.
               ILAZR2 = .FALSE.
               IF( .NOT.ILAZRO ) THEN
               IF( .NOT.ILAZRO ) THEN
                  IF( ABS1( A( J, J-1 ) )*( ASCALE*ABS1( A( J+1,
                  IF( ABS1( H( J, J-1 ) )*( ASCALE*ABS1( H( J+1,
     $                J ) ) ).LE.ABS1( A( J, J ) )*( ASCALE*ATOL ) )
     $                J ) ) ).LE.ABS1( H( J, J ) )*( ASCALE*ATOL ) )
     $                ILAZR2 = .TRUE.
     $                ILAZR2 = .TRUE.
               END IF
               END IF
*
*
 Lines 423-443    Link Here 
*
*
               IF( ILAZRO .OR. ILAZR2 ) THEN
               IF( ILAZRO .OR. ILAZR2 ) THEN
                  DO 20 JCH = J, ILAST - 1
                  DO 20 JCH = J, ILAST - 1
                     CTEMP = A( JCH, JCH )
                     CTEMP = H( JCH, JCH )
                     CALL CLARTG( CTEMP, A( JCH+1, JCH ), C, S,
                     CALL CLARTG( CTEMP, H( JCH+1, JCH ), C, S,
     $                            A( JCH, JCH ) )
     $                            H( JCH, JCH ) )
                     A( JCH+1, JCH ) = CZERO
                     H( JCH+1, JCH ) = CZERO
                     CALL CROT( ILASTM-JCH, A( JCH, JCH+1 ), LDA,
                     CALL CROT( ILASTM-JCH, H( JCH, JCH+1 ), LDH,
     $                          A( JCH+1, JCH+1 ), LDA, C, S )
     $                          H( JCH+1, JCH+1 ), LDH, C, S )
                     CALL CROT( ILASTM-JCH, B( JCH, JCH+1 ), LDB,
                     CALL CROT( ILASTM-JCH, T( JCH, JCH+1 ), LDT,
     $                          B( JCH+1, JCH+1 ), LDB, C, S )
     $                          T( JCH+1, JCH+1 ), LDT, C, S )
                     IF( ILQ )
                     IF( ILQ )
     $                  CALL CROT( N, Q( 1, JCH ), 1, Q( 1, JCH+1 ), 1,
     $                  CALL CROT( N, Q( 1, JCH ), 1, Q( 1, JCH+1 ), 1,
     $                             C, CONJG( S ) )
     $                             C, CONJG( S ) )
                     IF( ILAZR2 )
                     IF( ILAZR2 )
     $                  A( JCH, JCH-1 ) = A( JCH, JCH-1 )*C
     $                  H( JCH, JCH-1 ) = H( JCH, JCH-1 )*C
                     ILAZR2 = .FALSE.
                     ILAZR2 = .FALSE.
                     IF( ABS1( B( JCH+1, JCH+1 ) ).GE.BTOL ) THEN
                     IF( ABS1( T( JCH+1, JCH+1 ) ).GE.BTOL ) THEN
                        IF( JCH+1.GE.ILAST ) THEN
                        IF( JCH+1.GE.ILAST ) THEN
                           GO TO 60
                           GO TO 60
                        ELSE
                        ELSE
 Lines 445-479    Link Here 
                           GO TO 70
                           GO TO 70
                        END IF
                        END IF
                     END IF
                     END IF
                     B( JCH+1, JCH+1 ) = CZERO
                     T( JCH+1, JCH+1 ) = CZERO
   20             CONTINUE
   20             CONTINUE
                  GO TO 50
                  GO TO 50
               ELSE
               ELSE
*
*
*                 Only test 2 passed -- chase the zero to B(ILAST,ILAST)
*                 Only test 2 passed -- chase the zero to T(ILAST,ILAST)
*                 Then process as in the case B(ILAST,ILAST)=0
*                 Then process as in the case T(ILAST,ILAST)=0
*
*
                  DO 30 JCH = J, ILAST - 1
                  DO 30 JCH = J, ILAST - 1
                     CTEMP = B( JCH, JCH+1 )
                     CTEMP = T( JCH, JCH+1 )
                     CALL CLARTG( CTEMP, B( JCH+1, JCH+1 ), C, S,
                     CALL CLARTG( CTEMP, T( JCH+1, JCH+1 ), C, S,
     $                            B( JCH, JCH+1 ) )
     $                            T( JCH, JCH+1 ) )
                     B( JCH+1, JCH+1 ) = CZERO
                     T( JCH+1, JCH+1 ) = CZERO
                     IF( JCH.LT.ILASTM-1 )
                     IF( JCH.LT.ILASTM-1 )
     $                  CALL CROT( ILASTM-JCH-1, B( JCH, JCH+2 ), LDB,
     $                  CALL CROT( ILASTM-JCH-1, T( JCH, JCH+2 ), LDT,
     $                             B( JCH+1, JCH+2 ), LDB, C, S )
     $                             T( JCH+1, JCH+2 ), LDT, C, S )
                     CALL CROT( ILASTM-JCH+2, A( JCH, JCH-1 ), LDA,
                     CALL CROT( ILASTM-JCH+2, H( JCH, JCH-1 ), LDH,
     $                          A( JCH+1, JCH-1 ), LDA, C, S )
     $                          H( JCH+1, JCH-1 ), LDH, C, S )
                     IF( ILQ )
                     IF( ILQ )
     $                  CALL CROT( N, Q( 1, JCH ), 1, Q( 1, JCH+1 ), 1,
     $                  CALL CROT( N, Q( 1, JCH ), 1, Q( 1, JCH+1 ), 1,
     $                             C, CONJG( S ) )
     $                             C, CONJG( S ) )
                     CTEMP = A( JCH+1, JCH )
                     CTEMP = H( JCH+1, JCH )
                     CALL CLARTG( CTEMP, A( JCH+1, JCH-1 ), C, S,
                     CALL CLARTG( CTEMP, H( JCH+1, JCH-1 ), C, S,
     $                            A( JCH+1, JCH ) )
     $                            H( JCH+1, JCH ) )
                     A( JCH+1, JCH-1 ) = CZERO
                     H( JCH+1, JCH-1 ) = CZERO
                     CALL CROT( JCH+1-IFRSTM, A( IFRSTM, JCH ), 1,
                     CALL CROT( JCH+1-IFRSTM, H( IFRSTM, JCH ), 1,
     $                          A( IFRSTM, JCH-1 ), 1, C, S )
     $                          H( IFRSTM, JCH-1 ), 1, C, S )
                     CALL CROT( JCH-IFRSTM, B( IFRSTM, JCH ), 1,
                     CALL CROT( JCH-IFRSTM, T( IFRSTM, JCH ), 1,
     $                          B( IFRSTM, JCH-1 ), 1, C, S )
     $                          T( IFRSTM, JCH-1 ), 1, C, S )
                     IF( ILZ )
                     IF( ILZ )
     $                  CALL CROT( N, Z( 1, JCH ), 1, Z( 1, JCH-1 ), 1,
     $                  CALL CROT( N, Z( 1, JCH ), 1, Z( 1, JCH-1 ), 1,
     $                             C, S )
     $                             C, S )
 Lines 497-538    Link Here 
         INFO = 2*N + 1
         INFO = 2*N + 1
         GO TO 210
         GO TO 210
*
*
*        B(ILAST,ILAST)=0 -- clear A(ILAST,ILAST-1) to split off a
*        T(ILAST,ILAST)=0 -- clear H(ILAST,ILAST-1) to split off a
*        1x1 block.
*        1x1 block.
*
*
   50    CONTINUE
   50    CONTINUE
         CTEMP = A( ILAST, ILAST )
         CTEMP = H( ILAST, ILAST )
         CALL CLARTG( CTEMP, A( ILAST, ILAST-1 ), C, S,
         CALL CLARTG( CTEMP, H( ILAST, ILAST-1 ), C, S,
     $                A( ILAST, ILAST ) )
     $                H( ILAST, ILAST ) )
         A( ILAST, ILAST-1 ) = CZERO
         H( ILAST, ILAST-1 ) = CZERO
         CALL CROT( ILAST-IFRSTM, A( IFRSTM, ILAST ), 1,
         CALL CROT( ILAST-IFRSTM, H( IFRSTM, ILAST ), 1,
     $              A( IFRSTM, ILAST-1 ), 1, C, S )
     $              H( IFRSTM, ILAST-1 ), 1, C, S )
         CALL CROT( ILAST-IFRSTM, B( IFRSTM, ILAST ), 1,
         CALL CROT( ILAST-IFRSTM, T( IFRSTM, ILAST ), 1,
     $              B( IFRSTM, ILAST-1 ), 1, C, S )
     $              T( IFRSTM, ILAST-1 ), 1, C, S )
         IF( ILZ )
         IF( ILZ )
     $      CALL CROT( N, Z( 1, ILAST ), 1, Z( 1, ILAST-1 ), 1, C, S )
     $      CALL CROT( N, Z( 1, ILAST ), 1, Z( 1, ILAST-1 ), 1, C, S )
*
*
*        A(ILAST,ILAST-1)=0 -- Standardize B, set ALPHA and BETA
*        H(ILAST,ILAST-1)=0 -- Standardize B, set ALPHA and BETA
*
*
   60    CONTINUE
   60    CONTINUE
         ABSB = ABS( B( ILAST, ILAST ) )
         ABSB = ABS( T( ILAST, ILAST ) )
         IF( ABSB.GT.SAFMIN ) THEN
         IF( ABSB.GT.SAFMIN ) THEN
            SIGNBC = CONJG( B( ILAST, ILAST ) / ABSB )
            SIGNBC = CONJG( T( ILAST, ILAST ) / ABSB )
            B( ILAST, ILAST ) = ABSB
            T( ILAST, ILAST ) = ABSB
            IF( ILSCHR ) THEN
            IF( ILSCHR ) THEN
               CALL CSCAL( ILAST-IFRSTM, SIGNBC, B( IFRSTM, ILAST ), 1 )
               CALL CSCAL( ILAST-IFRSTM, SIGNBC, T( IFRSTM, ILAST ), 1 )
               CALL CSCAL( ILAST+1-IFRSTM, SIGNBC, A( IFRSTM, ILAST ),
               CALL CSCAL( ILAST+1-IFRSTM, SIGNBC, H( IFRSTM, ILAST ),
     $                     1 )
     $                     1 )
            ELSE
            ELSE
               A( ILAST, ILAST ) = A( ILAST, ILAST )*SIGNBC
               H( ILAST, ILAST ) = H( ILAST, ILAST )*SIGNBC
            END IF
            END IF
            IF( ILZ )
            IF( ILZ )
     $         CALL CSCAL( N, SIGNBC, Z( 1, ILAST ), 1 )
     $         CALL CSCAL( N, SIGNBC, Z( 1, ILAST ), 1 )
         ELSE
         ELSE
            B( ILAST, ILAST ) = CZERO
            T( ILAST, ILAST ) = CZERO
         END IF
         END IF
         ALPHA( ILAST ) = A( ILAST, ILAST )
         ALPHA( ILAST ) = H( ILAST, ILAST )
         BETA( ILAST ) = B( ILAST, ILAST )
         BETA( ILAST ) = T( ILAST, ILAST )
*
*
*        Go to next block -- exit if finished.
*        Go to next block -- exit if finished.
*
*
 Lines 565-571    Link Here 
*        Compute the Shift.
*        Compute the Shift.
*
*
*        At this point, IFIRST < ILAST, and the diagonal elements of
*        At this point, IFIRST < ILAST, and the diagonal elements of
*        B(IFIRST:ILAST,IFIRST,ILAST) are larger than BTOL (in
*        T(IFIRST:ILAST,IFIRST,ILAST) are larger than BTOL (in
*        magnitude)
*        magnitude)
*
*
         IF( ( IITER / 10 )*10.NE.IITER ) THEN
         IF( ( IITER / 10 )*10.NE.IITER ) THEN
 Lines 577-609    Link Here 
*           We factor B as U*D, where U has unit diagonals, and
*           We factor B as U*D, where U has unit diagonals, and
*           compute (A*inv(D))*inv(U).
*           compute (A*inv(D))*inv(U).
*
*
            U12 = ( BSCALE*B( ILAST-1, ILAST ) ) /
            U12 = ( BSCALE*T( ILAST-1, ILAST ) ) /
     $            ( BSCALE*B( ILAST, ILAST ) )
     $            ( BSCALE*T( ILAST, ILAST ) )
            AD11 = ( ASCALE*A( ILAST-1, ILAST-1 ) ) /
            AD11 = ( ASCALE*H( ILAST-1, ILAST-1 ) ) /
     $             ( BSCALE*B( ILAST-1, ILAST-1 ) )
     $             ( BSCALE*T( ILAST-1, ILAST-1 ) )
            AD21 = ( ASCALE*A( ILAST, ILAST-1 ) ) /
            AD21 = ( ASCALE*H( ILAST, ILAST-1 ) ) /
     $             ( BSCALE*B( ILAST-1, ILAST-1 ) )
     $             ( BSCALE*T( ILAST-1, ILAST-1 ) )
            AD12 = ( ASCALE*A( ILAST-1, ILAST ) ) /
            AD12 = ( ASCALE*H( ILAST-1, ILAST ) ) /
     $             ( BSCALE*B( ILAST, ILAST ) )
     $             ( BSCALE*T( ILAST, ILAST ) )
            AD22 = ( ASCALE*A( ILAST, ILAST ) ) /
            AD22 = ( ASCALE*H( ILAST, ILAST ) ) /
     $             ( BSCALE*B( ILAST, ILAST ) )
     $             ( BSCALE*T( ILAST, ILAST ) )
            ABI22 = AD22 - U12*AD21
            ABI22 = AD22 - U12*AD21
*
*
            T = HALF*( AD11+ABI22 )
            T1 = HALF*( AD11+ABI22 )
            RTDISC = SQRT( T**2+AD12*AD21-AD11*AD22 )
            RTDISC = SQRT( T1**2+AD12*AD21-AD11*AD22 )
            TEMP = REAL( T-ABI22 )*REAL( RTDISC ) +
            TEMP = REAL( T1-ABI22 )*REAL( RTDISC ) +
     $             AIMAG( T-ABI22 )*AIMAG( RTDISC )
     $             AIMAG( T1-ABI22 )*AIMAG( RTDISC )
            IF( TEMP.LE.ZERO ) THEN
            IF( TEMP.LE.ZERO ) THEN
               SHIFT = T + RTDISC
               SHIFT = T1 + RTDISC
            ELSE
            ELSE
               SHIFT = T - RTDISC
               SHIFT = T1 - RTDISC
            END IF
            END IF
         ELSE
         ELSE
*
*
*           Exceptional shift.  Chosen for no particularly good reason.
*           Exceptional shift.  Chosen for no particularly good reason.
*
*
            ESHIFT = ESHIFT + CONJG( ( ASCALE*A( ILAST-1, ILAST ) ) /
            ESHIFT = ESHIFT + CONJG( ( ASCALE*H( ILAST-1, ILAST ) ) /
     $               ( BSCALE*B( ILAST-1, ILAST-1 ) ) )
     $               ( BSCALE*T( ILAST-1, ILAST-1 ) ) )
            SHIFT = ESHIFT
            SHIFT = ESHIFT
         END IF
         END IF
*
*
 Lines 611-656    Link Here 
*
*
         DO 80 J = ILAST - 1, IFIRST + 1, -1
         DO 80 J = ILAST - 1, IFIRST + 1, -1
            ISTART = J
            ISTART = J
            CTEMP = ASCALE*A( J, J ) - SHIFT*( BSCALE*B( J, J ) )
            CTEMP = ASCALE*H( J, J ) - SHIFT*( BSCALE*T( J, J ) )
            TEMP = ABS1( CTEMP )
            TEMP = ABS1( CTEMP )
            TEMP2 = ASCALE*ABS1( A( J+1, J ) )
            TEMP2 = ASCALE*ABS1( H( J+1, J ) )
            TEMPR = MAX( TEMP, TEMP2 )
            TEMPR = MAX( TEMP, TEMP2 )
            IF( TEMPR.LT.ONE .AND. TEMPR.NE.ZERO ) THEN
            IF( TEMPR.LT.ONE .AND. TEMPR.NE.ZERO ) THEN
               TEMP = TEMP / TEMPR
               TEMP = TEMP / TEMPR
               TEMP2 = TEMP2 / TEMPR
               TEMP2 = TEMP2 / TEMPR
            END IF
            END IF
            IF( ABS1( A( J, J-1 ) )*TEMP2.LE.TEMP*ATOL )
            IF( ABS1( H( J, J-1 ) )*TEMP2.LE.TEMP*ATOL )
     $         GO TO 90
     $         GO TO 90
   80    CONTINUE
   80    CONTINUE
*
*
         ISTART = IFIRST
         ISTART = IFIRST
         CTEMP = ASCALE*A( IFIRST, IFIRST ) -
         CTEMP = ASCALE*H( IFIRST, IFIRST ) -
     $           SHIFT*( BSCALE*B( IFIRST, IFIRST ) )
     $           SHIFT*( BSCALE*T( IFIRST, IFIRST ) )
   90    CONTINUE
   90    CONTINUE
*
*
*        Do an implicit-shift QZ sweep.
*        Do an implicit-shift QZ sweep.
*
*
*        Initial Q
*        Initial Q
*
*
         CTEMP2 = ASCALE*A( ISTART+1, ISTART )
         CTEMP2 = ASCALE*H( ISTART+1, ISTART )
         CALL CLARTG( CTEMP, CTEMP2, C, S, CTEMP3 )
         CALL CLARTG( CTEMP, CTEMP2, C, S, CTEMP3 )
*
*
*        Sweep
*        Sweep
*
*
         DO 150 J = ISTART, ILAST - 1
         DO 150 J = ISTART, ILAST - 1
            IF( J.GT.ISTART ) THEN
            IF( J.GT.ISTART ) THEN
               CTEMP = A( J, J-1 )
               CTEMP = H( J, J-1 )
               CALL CLARTG( CTEMP, A( J+1, J-1 ), C, S, A( J, J-1 ) )
               CALL CLARTG( CTEMP, H( J+1, J-1 ), C, S, H( J, J-1 ) )
               A( J+1, J-1 ) = CZERO
               H( J+1, J-1 ) = CZERO
            END IF
            END IF
*
*
            DO 100 JC = J, ILASTM
            DO 100 JC = J, ILASTM
               CTEMP = C*A( J, JC ) + S*A( J+1, JC )
               CTEMP = C*H( J, JC ) + S*H( J+1, JC )
               A( J+1, JC ) = -CONJG( S )*A( J, JC ) + C*A( J+1, JC )
               H( J+1, JC ) = -CONJG( S )*H( J, JC ) + C*H( J+1, JC )
               A( J, JC ) = CTEMP
               H( J, JC ) = CTEMP
               CTEMP2 = C*B( J, JC ) + S*B( J+1, JC )
               CTEMP2 = C*T( J, JC ) + S*T( J+1, JC )
               B( J+1, JC ) = -CONJG( S )*B( J, JC ) + C*B( J+1, JC )
               T( J+1, JC ) = -CONJG( S )*T( J, JC ) + C*T( J+1, JC )
               B( J, JC ) = CTEMP2
               T( J, JC ) = CTEMP2
  100       CONTINUE
  100       CONTINUE
            IF( ILQ ) THEN
            IF( ILQ ) THEN
               DO 110 JR = 1, N
               DO 110 JR = 1, N
 Lines 660-678    Link Here 
  110          CONTINUE
  110          CONTINUE
            END IF
            END IF
*
*
            CTEMP = B( J+1, J+1 )
            CTEMP = T( J+1, J+1 )
            CALL CLARTG( CTEMP, B( J+1, J ), C, S, B( J+1, J+1 ) )
            CALL CLARTG( CTEMP, T( J+1, J ), C, S, T( J+1, J+1 ) )
            B( J+1, J ) = CZERO
            T( J+1, J ) = CZERO
*
*
            DO 120 JR = IFRSTM, MIN( J+2, ILAST )
            DO 120 JR = IFRSTM, MIN( J+2, ILAST )
               CTEMP = C*A( JR, J+1 ) + S*A( JR, J )
               CTEMP = C*H( JR, J+1 ) + S*H( JR, J )
               A( JR, J ) = -CONJG( S )*A( JR, J+1 ) + C*A( JR, J )
               H( JR, J ) = -CONJG( S )*H( JR, J+1 ) + C*H( JR, J )
               A( JR, J+1 ) = CTEMP
               H( JR, J+1 ) = CTEMP
  120       CONTINUE
  120       CONTINUE
            DO 130 JR = IFRSTM, J
            DO 130 JR = IFRSTM, J
               CTEMP = C*B( JR, J+1 ) + S*B( JR, J )
               CTEMP = C*T( JR, J+1 ) + S*T( JR, J )
               B( JR, J ) = -CONJG( S )*B( JR, J+1 ) + C*B( JR, J )
               T( JR, J ) = -CONJG( S )*T( JR, J+1 ) + C*T( JR, J )
               B( JR, J+1 ) = CTEMP
               T( JR, J+1 ) = CTEMP
  130       CONTINUE
  130       CONTINUE
            IF( ILZ ) THEN
            IF( ILZ ) THEN
               DO 140 JR = 1, N
               DO 140 JR = 1, N
 Lines 700-722    Link Here 
*     Set Eigenvalues 1:ILO-1
*     Set Eigenvalues 1:ILO-1
*
*
      DO 200 J = 1, ILO - 1
      DO 200 J = 1, ILO - 1
         ABSB = ABS( B( J, J ) )
         ABSB = ABS( T( J, J ) )
         IF( ABSB.GT.SAFMIN ) THEN
         IF( ABSB.GT.SAFMIN ) THEN
            SIGNBC = CONJG( B( J, J ) / ABSB )
            SIGNBC = CONJG( T( J, J ) / ABSB )
            B( J, J ) = ABSB
            T( J, J ) = ABSB
            IF( ILSCHR ) THEN
            IF( ILSCHR ) THEN
               CALL CSCAL( J-1, SIGNBC, B( 1, J ), 1 )
               CALL CSCAL( J-1, SIGNBC, T( 1, J ), 1 )
               CALL CSCAL( J, SIGNBC, A( 1, J ), 1 )
               CALL CSCAL( J, SIGNBC, H( 1, J ), 1 )
            ELSE
            ELSE
               A( J, J ) = A( J, J )*SIGNBC
               H( J, J ) = H( J, J )*SIGNBC
            END IF
            END IF
            IF( ILZ )
            IF( ILZ )
     $         CALL CSCAL( N, SIGNBC, Z( 1, J ), 1 )
     $         CALL CSCAL( N, SIGNBC, Z( 1, J ), 1 )
         ELSE
         ELSE
            B( J, J ) = CZERO
            T( J, J ) = CZERO
         END IF
         END IF
         ALPHA( J ) = A( J, J )
         ALPHA( J ) = H( J, J )
         BETA( J ) = B( J, J )
         BETA( J ) = T( J, J )
  200 CONTINUE
  200 CONTINUE
*
*
*     Normal Termination
*     Normal Termination
(-) LAPACK/SRC/clasr.f (-44 / +83 lines)
 Lines 3-9    Link Here 
*  -- LAPACK auxiliary routine (version 3.0) --
*  -- LAPACK auxiliary routine (version 3.0) --
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Courant Institute, Argonne National Lab, and Rice University
*     Courant Institute, Argonne National Lab, and Rice University
*     October 31, 1992
*     May 3, 2001
*
*
*     .. Scalar Arguments ..
*     .. Scalar Arguments ..
      CHARACTER          DIRECT, PIVOT, SIDE
      CHARACTER          DIRECT, PIVOT, SIDE
 Lines 17-58    Link Here 
*  Purpose
*  Purpose
*  =======
*  =======
*
*
*  CLASR   performs the transformation
*  CLASR applies a sequence of real plane rotations to a complex matrix
*  A, from either the left or the right.
*
*
*     A := P*A,   when SIDE = 'L' or 'l'  (  Left-hand side )
*  When SIDE = 'L', the transformation takes the form
*
*
*     A := A*P',  when SIDE = 'R' or 'r'  ( Right-hand side )
*     A := P*A
*
*
*  where A is an m by n complex matrix and P is an orthogonal matrix,
*  and when SIDE = 'R', the transformation takes the form
*  consisting of a sequence of plane rotations determined by the
*  parameters PIVOT and DIRECT as follows ( z = m when SIDE = 'L' or 'l'
*  and z = n when SIDE = 'R' or 'r' ):
*
*
*  When  DIRECT = 'F' or 'f'  ( Forward sequence ) then
*     A := A*P**T
*
*
*     P = P( z - 1 )*...*P( 2 )*P( 1 ),
*  where P is an orthogonal matrix consisting of a sequence of z plane
*
*  rotations, with z = M when SIDE = 'L' and z = N when SIDE = 'R',
*  and when DIRECT = 'B' or 'b'  ( Backward sequence ) then
*  and P**T is the transpose of P.
*
*  
*     P = P( 1 )*P( 2 )*...*P( z - 1 ),
*  When DIRECT = 'F' (Forward sequence), then
*
*  
*  where  P( k ) is a plane rotation matrix for the following planes:
*     P = P(z-1) * ... * P(2) * P(1)
*
*  
*     when  PIVOT = 'V' or 'v'  ( Variable pivot ),
*  and when DIRECT = 'B' (Backward sequence), then
*        the plane ( k, k + 1 )
*  
*
*     P = P(1) * P(2) * ... * P(z-1)
*     when  PIVOT = 'T' or 't'  ( Top pivot ),
*  
*        the plane ( 1, k + 1 )
*  where P(k) is a plane rotation matrix defined by the 2-by-2 rotation
*
*  
*     when  PIVOT = 'B' or 'b'  ( Bottom pivot ),
*     R(k) = (  c(k)  s(k) )
*        the plane ( k, z )
*          = ( -s(k)  c(k) ).
*
*  
*  c( k ) and s( k )  must contain the  cosine and sine that define the
*  When PIVOT = 'V' (Variable pivot), the rotation is performed
*  matrix  P( k ).  The two by two plane rotation part of the matrix
*  for the plane (k,k+1), i.e., P(k) has the form
*  P( k ), R( k ), is assumed to be of the form
*  
*
*     P(k) = (  1                                            )
*     R( k ) = (  c( k )  s( k ) ).
*            (       ...                                     )
*              ( -s( k )  c( k ) )
*            (              1                                )
*            (                   c(k)  s(k)                  )
*            (                  -s(k)  c(k)                  )
*            (                                1              )
*            (                                     ...       )
*            (                                            1  )
*  
*  where R(k) appears as a rank-2 modification to the identity matrix in
*  rows and columns k and k+1.
*  
*  When PIVOT = 'T' (Top pivot), the rotation is performed for the
*  plane (1,k+1), so P(k) has the form
*  
*     P(k) = (  c(k)                    s(k)                 )
*            (         1                                     )
*            (              ...                              )
*            (                     1                         )
*            ( -s(k)                    c(k)                 )
*            (                                 1             )
*            (                                      ...      )
*            (                                             1 )
*  
*  where R(k) appears in rows and columns 1 and k+1.
*  
*  Similarly, when PIVOT = 'B' (Bottom pivot), the rotation is
*  performed for the plane (k,z), giving P(k) the form
*  
*     P(k) = ( 1                                             )
*            (      ...                                      )
*            (             1                                 )
*            (                  c(k)                    s(k) )
*            (                         1                     )
*            (                              ...              )
*            (                                     1         )
*            (                 -s(k)                    c(k) )
*  
*  where R(k) appears in rows and columns k and z.  The rotations are
*  performed without ever forming P(k) explicitly.
*
*
*  Arguments
*  Arguments
*  =========
*  =========
 Lines 61-73    Link Here 
*          Specifies whether the plane rotation matrix P is applied to
*          Specifies whether the plane rotation matrix P is applied to
*          A on the left or the right.
*          A on the left or the right.
*          = 'L':  Left, compute A := P*A
*          = 'L':  Left, compute A := P*A
*          = 'R':  Right, compute A:= A*P'
*          = 'R':  Right, compute A:= A*P**T
*
*
*  DIRECT  (input) CHARACTER*1
*  DIRECT  (input) CHARACTER*1
*          Specifies whether P is a forward or backward sequence of
*          Specifies whether P is a forward or backward sequence of
*          plane rotations.
*          plane rotations.
*          = 'F':  Forward, P = P( z - 1 )*...*P( 2 )*P( 1 )
*          = 'F':  Forward, P = P(z-1)*...*P(2)*P(1)
*          = 'B':  Backward, P = P( 1 )*P( 2 )*...*P( z - 1 )
*          = 'B':  Backward, P = P(1)*P(2)*...*P(z-1)
*
*
*  PIVOT   (input) CHARACTER*1
*  PIVOT   (input) CHARACTER*1
*          Specifies the plane for which P(k) is a plane rotation
*          Specifies the plane for which P(k) is a plane rotation
 Lines 84-101    Link Here 
*          The number of columns of the matrix A.  If n <= 1, an
*          The number of columns of the matrix A.  If n <= 1, an
*          immediate return is effected.
*          immediate return is effected.
*
*
*  C, S    (input) REAL arrays, dimension
*  C       (input) REAL array, dimension
*                  (M-1) if SIDE = 'L'
*                  (N-1) if SIDE = 'R'
*          The cosines c(k) of the plane rotations.
*
*  S       (input) REAL array, dimension
*                  (M-1) if SIDE = 'L'
*                  (M-1) if SIDE = 'L'
*                  (N-1) if SIDE = 'R'
*                  (N-1) if SIDE = 'R'
*          c(k) and s(k) contain the cosine and sine that define the
*          The sines s(k) of the plane rotations.  The 2-by-2 plane
*          matrix P(k).  The two by two plane rotation part of the
*          rotation part of the matrix P(k), R(k), has the form
*          matrix P(k), R(k), is assumed to be of the form
*          R(k) = (  c(k)  s(k) )
*          R( k ) = (  c( k )  s( k ) ).
*                 ( -s(k)  c(k) ).
*                   ( -s( k )  c( k ) )
*
*
*  A       (input/output) COMPLEX array, dimension (LDA,N)
*  A       (input/output) COMPLEX array, dimension (LDA,N)
*          The m by n matrix A.  On exit, A is overwritten by P*A if
*          The M-by-N matrix A.  On exit, A is overwritten by P*A if
*          SIDE = 'R' or by A*P' if SIDE = 'L'.
*          SIDE = 'R' or by A*P**T if SIDE = 'L'.
*
*
*  LDA     (input) INTEGER
*  LDA     (input) INTEGER
*          The leading dimension of the array A.  LDA >= max(1,M).
*          The leading dimension of the array A.  LDA >= max(1,M).
(-) LAPACK/SRC/ctgevc.f (-86 / +88 lines)
 Lines 1-19    Link Here 
      SUBROUTINE CTGEVC( SIDE, HOWMNY, SELECT, N, A, LDA, B, LDB, VL,
      SUBROUTINE CTGEVC( SIDE, HOWMNY, SELECT, N, S, LDS, P, LDP, VL,
     $                   LDVL, VR, LDVR, MM, M, WORK, RWORK, INFO )
     $                   LDVL, VR, LDVR, MM, M, WORK, RWORK, INFO )
*
*
*  -- LAPACK routine (version 3.0) --
*  -- LAPACK routine (version 3.0) --
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Courant Institute, Argonne National Lab, and Rice University
*     Courant Institute, Argonne National Lab, and Rice University
*     June 30, 1999
*     May 4, 2001
*
*
*     .. Scalar Arguments ..
*     .. Scalar Arguments ..
      CHARACTER          HOWMNY, SIDE
      CHARACTER          HOWMNY, SIDE
      INTEGER            INFO, LDA, LDB, LDVL, LDVR, M, MM, N
      INTEGER            INFO, LDP, LDS, LDVL, LDVR, M, MM, N
*     ..
*     ..
*     .. Array Arguments ..
*     .. Array Arguments ..
      LOGICAL            SELECT( * )
      LOGICAL            SELECT( * )
      REAL               RWORK( * )
      REAL               RWORK( * )
      COMPLEX            A( LDA, * ), B( LDB, * ), VL( LDVL, * ),
      COMPLEX            P( LDP, * ), S( LDS, * ), VL( LDVL, * ),
     $                   VR( LDVR, * ), WORK( * )
     $                   VR( LDVR, * ), WORK( * )
*     ..
*     ..
*
*
 Lines 21-48    Link Here 
*  Purpose
*  Purpose
*  =======
*  =======
*
*
*  CTGEVC computes some or all of the right and/or left generalized
*  CTGEVC computes some or all of the right and/or left eigenvectors of
*  eigenvectors of a pair of complex upper triangular matrices (A,B).
*  a pair of complex matrices (S,P), where S and P are upper triangular.
*
*  Matrix pairs of this type are produced by the generalized Schur
*  The right generalized eigenvector x and the left generalized
*  factorization of a complex matrix pair (A,B):
*  eigenvector y of (A,B) corresponding to a generalized eigenvalue
*  
*  w are defined by:
*     A = Q*S*Z**H,  B = Q*P*Z**H
*
*  
*          (A - wB) * x = 0  and  y**H * (A - wB) = 0
*  as computed by CGGHRD + CHGEQZ.
*
*  
*  The right eigenvector x and the left eigenvector y of (S,P)
*  corresponding to an eigenvalue w are defined by:
*  
*     S*x = w*P*x,  (y**H)*S = w*(y**H)*P,
*  
*  where y**H denotes the conjugate tranpose of y.
*  where y**H denotes the conjugate tranpose of y.
*
*  The eigenvalues are not input to this routine, but are computed
*  If an eigenvalue w is determined by zero diagonal elements of both A
*  directly from the diagonal elements of S and P.
*  and B, a unit vector is returned as the corresponding eigenvector.
*  
*
*  This routine returns the matrices X and/or Y of right and left
*  If all eigenvectors are requested, the routine may either return
*  eigenvectors of (S,P), or the products Z*X and/or Q*Y,
*  the matrices X and/or Y of right or left eigenvectors of (A,B), or
*  where Z and Q are input matrices.
*  the products Z*X and/or Q*Y, where Z and Q are input unitary
*  If Q and Z are the unitary factors from the generalized Schur
*  matrices.  If (A,B) was obtained from the generalized Schur
*  factorization of a matrix pair (A,B), then Z*X and Q*Y
*  factorization of an original pair of matrices
*  are the matrices of right and left eigenvectors of (A,B).
*     (A0,B0) = (Q*A*Z**H,Q*B*Z**H),
*  then Z*X and Q*Y are the matrices of right or left eigenvectors of
*  A.
*
*
*  Arguments
*  Arguments
*  =========
*  =========
 Lines 54-119    Link Here 
*
*
*  HOWMNY  (input) CHARACTER*1
*  HOWMNY  (input) CHARACTER*1
*          = 'A': compute all right and/or left eigenvectors;
*          = 'A': compute all right and/or left eigenvectors;
*          = 'B': compute all right and/or left eigenvectors, and
*          = 'B': compute all right and/or left eigenvectors,
*                 backtransform them using the input matrices supplied
*                 backtransformed by the matrices in VR and/or VL;
*                 in VR and/or VL;
*          = 'S': compute selected right and/or left eigenvectors,
*          = 'S': compute selected right and/or left eigenvectors,
*                 specified by the logical array SELECT.
*                 specified by the logical array SELECT.
*
*
*  SELECT  (input) LOGICAL array, dimension (N)
*  SELECT  (input) LOGICAL array, dimension (N)
*          If HOWMNY='S', SELECT specifies the eigenvectors to be
*          If HOWMNY='S', SELECT specifies the eigenvectors to be
*          computed.
*          computed.  The eigenvector corresponding to the j-th
*          If HOWMNY='A' or 'B', SELECT is not referenced.
*          eigenvalue is computed if SELECT(j) = .TRUE..
*          To select the eigenvector corresponding to the j-th
*          Not referenced if HOWMNY = 'A' or 'B'.
*          eigenvalue, SELECT(j) must be set to .TRUE..
*
*
*  N       (input) INTEGER
*  N       (input) INTEGER
*          The order of the matrices A and B.  N >= 0.
*          The order of the matrices S and P.  N >= 0.
*
*  A       (input) COMPLEX array, dimension (LDA,N)
*          The upper triangular matrix A.
*
*  LDA     (input) INTEGER
*          The leading dimension of array A.  LDA >= max(1,N).
*
*
*  B       (input) COMPLEX array, dimension (LDB,N)
*  S       (input) COMPLEX array, dimension (LDS,N)
*          The upper triangular matrix B.  B must have real diagonal
*          The upper triangular matrix S from a generalized Schur
*          elements.
*          factorization, as computed by CHGEQZ.
*
*  LDS     (input) INTEGER
*          The leading dimension of array S.  LDS >= max(1,N).
*
*  P       (input) COMPLEX array, dimension (LDP,N)
*          The upper triangular matrix P from a generalized Schur
*          factorization, as computed by CHGEQZ.  P must have real
*          diagonal elements.
*
*
*  LDB     (input) INTEGER
*  LDP     (input) INTEGER
*          The leading dimension of array B.  LDB >= max(1,N).
*          The leading dimension of array P.  LDP >= max(1,N).
*
*
*  VL      (input/output) COMPLEX array, dimension (LDVL,MM)
*  VL      (input/output) COMPLEX array, dimension (LDVL,MM)
*          On entry, if SIDE = 'L' or 'B' and HOWMNY = 'B', VL must
*          On entry, if SIDE = 'L' or 'B' and HOWMNY = 'B', VL must
*          contain an N-by-N matrix Q (usually the unitary matrix Q
*          contain an N-by-N matrix Q (usually the unitary matrix Q
*          of left Schur vectors returned by CHGEQZ).
*          of left Schur vectors returned by CHGEQZ).
*          On exit, if SIDE = 'L' or 'B', VL contains:
*          On exit, if SIDE = 'L' or 'B', VL contains:
*          if HOWMNY = 'A', the matrix Y of left eigenvectors of (A,B);
*          if HOWMNY = 'A', the matrix Y of left eigenvectors of (S,P);
*          if HOWMNY = 'B', the matrix Q*Y;
*          if HOWMNY = 'B', the matrix Q*Y;
*          if HOWMNY = 'S', the left eigenvectors of (A,B) specified by
*          if HOWMNY = 'S', the left eigenvectors of (S,P) specified by
*                      SELECT, stored consecutively in the columns of
*                      SELECT, stored consecutively in the columns of
*                      VL, in the same order as their eigenvalues.
*                      VL, in the same order as their eigenvalues.
*          If SIDE = 'R', VL is not referenced.
*          Not referenced if SIDE = 'R'.
*
*
*  LDVL    (input) INTEGER
*  LDVL    (input) INTEGER
*          The leading dimension of array VL.
*          The leading dimension of array VL.  LDVL >= 1, and if
*          LDVL >= max(1,N) if SIDE = 'L' or 'B'; LDVL >= 1 otherwise.
*          SIDE = 'L' or 'l' or 'B' or 'b', LDVL >= N.
*
*
*  VR      (input/output) COMPLEX array, dimension (LDVR,MM)
*  VR      (input/output) COMPLEX array, dimension (LDVR,MM)
*          On entry, if SIDE = 'R' or 'B' and HOWMNY = 'B', VR must
*          On entry, if SIDE = 'R' or 'B' and HOWMNY = 'B', VR must
*          contain an N-by-N matrix Q (usually the unitary matrix Z
*          contain an N-by-N matrix Q (usually the unitary matrix Z
*          of right Schur vectors returned by CHGEQZ).
*          of right Schur vectors returned by CHGEQZ).
*          On exit, if SIDE = 'R' or 'B', VR contains:
*          On exit, if SIDE = 'R' or 'B', VR contains:
*          if HOWMNY = 'A', the matrix X of right eigenvectors of (A,B);
*          if HOWMNY = 'A', the matrix X of right eigenvectors of (S,P);
*          if HOWMNY = 'B', the matrix Z*X;
*          if HOWMNY = 'B', the matrix Z*X;
*          if HOWMNY = 'S', the right eigenvectors of (A,B) specified by
*          if HOWMNY = 'S', the right eigenvectors of (S,P) specified by
*                      SELECT, stored consecutively in the columns of
*                      SELECT, stored consecutively in the columns of
*                      VR, in the same order as their eigenvalues.
*                      VR, in the same order as their eigenvalues.
*          If SIDE = 'L', VR is not referenced.
*          Not referenced if SIDE = 'L'.
*
*
*  LDVR    (input) INTEGER
*  LDVR    (input) INTEGER
*          The leading dimension of the array VR.
*          The leading dimension of the array VR.  LDVR >= 1, and if
*          LDVR >= max(1,N) if SIDE = 'R' or 'B'; LDVR >= 1 otherwise.
*          SIDE = 'R' or 'B', LDVR >= N.
*
*
*  MM      (input) INTEGER
*  MM      (input) INTEGER
*          The number of columns in the arrays VL and/or VR. MM >= M.
*          The number of columns in the arrays VL and/or VR. MM >= M.
 Lines 180-186    Link Here 
         IHWMNY = 2
         IHWMNY = 2
         ILALL = .FALSE.
         ILALL = .FALSE.
         ILBACK = .FALSE.
         ILBACK = .FALSE.
      ELSE IF( LSAME( HOWMNY, 'B' ) .OR. LSAME( HOWMNY, 'T' ) ) THEN
      ELSE IF( LSAME( HOWMNY, 'B' ) ) THEN
         IHWMNY = 3
         IHWMNY = 3
         ILALL = .TRUE.
         ILALL = .TRUE.
         ILBACK = .TRUE.
         ILBACK = .TRUE.
 Lines 211-219    Link Here 
         INFO = -2
         INFO = -2
      ELSE IF( N.LT.0 ) THEN
      ELSE IF( N.LT.0 ) THEN
         INFO = -4
         INFO = -4
      ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
      ELSE IF( LDS.LT.MAX( 1, N ) ) THEN
         INFO = -6
         INFO = -6
      ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
      ELSE IF( LDP.LT.MAX( 1, N ) ) THEN
         INFO = -8
         INFO = -8
      END IF
      END IF
      IF( INFO.NE.0 ) THEN
      IF( INFO.NE.0 ) THEN
 Lines 237-243    Link Here 
*
*
      ILBBAD = .FALSE.
      ILBBAD = .FALSE.
      DO 20 J = 1, N
      DO 20 J = 1, N
         IF( AIMAG( B( J, J ) ).NE.ZERO )
         IF( AIMAG( P( J, J ) ).NE.ZERO )
     $      ILBBAD = .TRUE.
     $      ILBBAD = .TRUE.
   20 CONTINUE
   20 CONTINUE
*
*
 Lines 275-293    Link Here 
*     part of A and B to check for possible overflow in the triangular
*     part of A and B to check for possible overflow in the triangular
*     solver.
*     solver.
*
*
      ANORM = ABS1( A( 1, 1 ) )
      ANORM = ABS1( S( 1, 1 ) )
      BNORM = ABS1( B( 1, 1 ) )
      BNORM = ABS1( P( 1, 1 ) )
      RWORK( 1 ) = ZERO
      RWORK( 1 ) = ZERO
      RWORK( N+1 ) = ZERO
      RWORK( N+1 ) = ZERO
      DO 40 J = 2, N
      DO 40 J = 2, N
         RWORK( J ) = ZERO
         RWORK( J ) = ZERO
         RWORK( N+J ) = ZERO
         RWORK( N+J ) = ZERO
         DO 30 I = 1, J - 1
         DO 30 I = 1, J - 1
            RWORK( J ) = RWORK( J ) + ABS1( A( I, J ) )
            RWORK( J ) = RWORK( J ) + ABS1( S( I, J ) )
            RWORK( N+J ) = RWORK( N+J ) + ABS1( B( I, J ) )
            RWORK( N+J ) = RWORK( N+J ) + ABS1( P( I, J ) )
   30    CONTINUE
   30    CONTINUE
         ANORM = MAX( ANORM, RWORK( J )+ABS1( A( J, J ) ) )
         ANORM = MAX( ANORM, RWORK( J )+ABS1( S( J, J ) ) )
         BNORM = MAX( BNORM, RWORK( N+J )+ABS1( B( J, J ) ) )
         BNORM = MAX( BNORM, RWORK( N+J )+ABS1( P( J, J ) ) )
   40 CONTINUE
   40 CONTINUE
*
*
      ASCALE = ONE / MAX( ANORM, SAFMIN )
      ASCALE = ONE / MAX( ANORM, SAFMIN )
 Lines 309-316    Link Here 
            IF( ILCOMP ) THEN
            IF( ILCOMP ) THEN
               IEIG = IEIG + 1
               IEIG = IEIG + 1
*
*
               IF( ABS1( A( JE, JE ) ).LE.SAFMIN .AND.
               IF( ABS1( S( JE, JE ) ).LE.SAFMIN .AND.
     $             ABS( REAL( B( JE, JE ) ) ).LE.SAFMIN ) THEN
     $             ABS( REAL( P( JE, JE ) ) ).LE.SAFMIN ) THEN
*
*
*                 Singular matrix pencil -- return unit eigenvector
*                 Singular matrix pencil -- return unit eigenvector
*
*
 Lines 326-335    Link Here 
*                   H
*                   H
*                 y  ( a A - b B ) = 0
*                 y  ( a A - b B ) = 0
*
*
               TEMP = ONE / MAX( ABS1( A( JE, JE ) )*ASCALE,
               TEMP = ONE / MAX( ABS1( S( JE, JE ) )*ASCALE,
     $                ABS( REAL( B( JE, JE ) ) )*BSCALE, SAFMIN )
     $                ABS( REAL( P( JE, JE ) ) )*BSCALE, SAFMIN )
               SALPHA = ( TEMP*A( JE, JE ) )*ASCALE
               SALPHA = ( TEMP*S( JE, JE ) )*ASCALE
               SBETA = ( TEMP*REAL( B( JE, JE ) ) )*BSCALE
               SBETA = ( TEMP*REAL( P( JE, JE ) ) )*BSCALE
               ACOEFF = SBETA*ASCALE
               ACOEFF = SBETA*ASCALE
               BCOEFF = SALPHA*BSCALE
               BCOEFF = SALPHA*BSCALE
*
*
 Lines 380-386    Link Here 
*
*
*                 Compute
*                 Compute
*                       j-1
*                       j-1
*                 SUM = sum  conjg( a*A(k,j) - b*B(k,j) )*x(k)
*                 SUM = sum  conjg( a*S(k,j) - b*P(k,j) )*x(k)
*                       k=je
*                       k=je
*                 (Scale if necessary)
*                 (Scale if necessary)
*
*
 Lines 396-411    Link Here 
                  SUMB = CZERO
                  SUMB = CZERO
*
*
                  DO 80 JR = JE, J - 1
                  DO 80 JR = JE, J - 1
                     SUMA = SUMA + CONJG( A( JR, J ) )*WORK( JR )
                     SUMA = SUMA + CONJG( S( JR, J ) )*WORK( JR )
                     SUMB = SUMB + CONJG( B( JR, J ) )*WORK( JR )
                     SUMB = SUMB + CONJG( P( JR, J ) )*WORK( JR )
   80             CONTINUE
   80             CONTINUE
                  SUM = ACOEFF*SUMA - CONJG( BCOEFF )*SUMB
                  SUM = ACOEFF*SUMA - CONJG( BCOEFF )*SUMB
*
*
*                 Form x(j) = - SUM / conjg( a*A(j,j) - b*B(j,j) )
*                 Form x(j) = - SUM / conjg( a*S(j,j) - b*P(j,j) )
*
*
*                 with scaling and perturbation of the denominator
*                 with scaling and perturbation of the denominator
*
*
                  D = CONJG( ACOEFF*A( J, J )-BCOEFF*B( J, J ) )
                  D = CONJG( ACOEFF*S( J, J )-BCOEFF*P( J, J ) )
                  IF( ABS1( D ).LE.DMIN )
                  IF( ABS1( D ).LE.DMIN )
     $               D = CMPLX( DMIN )
     $               D = CMPLX( DMIN )
*
*
 Lines 475-482    Link Here 
            IF( ILCOMP ) THEN
            IF( ILCOMP ) THEN
               IEIG = IEIG - 1
               IEIG = IEIG - 1
*
*
               IF( ABS1( A( JE, JE ) ).LE.SAFMIN .AND.
               IF( ABS1( S( JE, JE ) ).LE.SAFMIN .AND.
     $             ABS( REAL( B( JE, JE ) ) ).LE.SAFMIN ) THEN
     $             ABS( REAL( P( JE, JE ) ) ).LE.SAFMIN ) THEN
*
*
*                 Singular matrix pencil -- return unit eigenvector
*                 Singular matrix pencil -- return unit eigenvector
*
*
 Lines 492-501    Link Here 
*
*
*              ( a A - b B ) x  = 0
*              ( a A - b B ) x  = 0
*
*
               TEMP = ONE / MAX( ABS1( A( JE, JE ) )*ASCALE,
               TEMP = ONE / MAX( ABS1( S( JE, JE ) )*ASCALE,
     $                ABS( REAL( B( JE, JE ) ) )*BSCALE, SAFMIN )
     $                ABS( REAL( P( JE, JE ) ) )*BSCALE, SAFMIN )
               SALPHA = ( TEMP*A( JE, JE ) )*ASCALE
               SALPHA = ( TEMP*S( JE, JE ) )*ASCALE
               SBETA = ( TEMP*REAL( B( JE, JE ) ) )*BSCALE
               SBETA = ( TEMP*REAL( P( JE, JE ) ) )*BSCALE
               ACOEFF = SBETA*ASCALE
               ACOEFF = SBETA*ASCALE
               BCOEFF = SALPHA*BSCALE
               BCOEFF = SALPHA*BSCALE
*
*
 Lines 542-548    Link Here 
*              WORK(j+1:JE) contains x
*              WORK(j+1:JE) contains x
*
*
               DO 170 JR = 1, JE - 1
               DO 170 JR = 1, JE - 1
                  WORK( JR ) = ACOEFF*A( JR, JE ) - BCOEFF*B( JR, JE )
                  WORK( JR ) = ACOEFF*S( JR, JE ) - BCOEFF*P( JR, JE )
  170          CONTINUE
  170          CONTINUE
               WORK( JE ) = CONE
               WORK( JE ) = CONE
*
*
 Lines 551-557    Link Here 
*                 Form x(j) := - w(j) / d
*                 Form x(j) := - w(j) / d
*                 with scaling and perturbation of the denominator
*                 with scaling and perturbation of the denominator
*
*
                  D = ACOEFF*A( J, J ) - BCOEFF*B( J, J )
                  D = ACOEFF*S( J, J ) - BCOEFF*P( J, J )
                  IF( ABS1( D ).LE.DMIN )
                  IF( ABS1( D ).LE.DMIN )
     $               D = CMPLX( DMIN )
     $               D = CMPLX( DMIN )
*
*
 Lines 568-574    Link Here 
*
*
                  IF( J.GT.1 ) THEN
                  IF( J.GT.1 ) THEN
*
*
*                    w = w + x(j)*(a A(*,j) - b B(*,j) ) with scaling
*                    w = w + x(j)*(a S(*,j) - b P(*,j) ) with scaling
*
*
                     IF( ABS1( WORK( J ) ).GT.ONE ) THEN
                     IF( ABS1( WORK( J ) ).GT.ONE ) THEN
                        TEMP = ONE / ABS1( WORK( J ) )
                        TEMP = ONE / ABS1( WORK( J ) )
 Lines 583-590    Link Here 
                     CA = ACOEFF*WORK( J )
                     CA = ACOEFF*WORK( J )
                     CB = BCOEFF*WORK( J )
                     CB = BCOEFF*WORK( J )
                     DO 200 JR = 1, J - 1
                     DO 200 JR = 1, J - 1
                        WORK( JR ) = WORK( JR ) + CA*A( JR, J ) -
                        WORK( JR ) = WORK( JR ) + CA*S( JR, J ) -
     $                               CB*B( JR, J )
     $                               CB*P( JR, J )
  200                CONTINUE
  200                CONTINUE
                  END IF
                  END IF
  210          CONTINUE
  210          CONTINUE
(-) LAPACK/SRC/ctrevc.f (-31 / +28 lines)
 Lines 4-10    Link Here 
*  -- LAPACK routine (version 3.0) --
*  -- LAPACK routine (version 3.0) --
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Courant Institute, Argonne National Lab, and Rice University
*     Courant Institute, Argonne National Lab, and Rice University
*     June 30, 1999
*     May 7, 2001
*
*
*     .. Scalar Arguments ..
*     .. Scalar Arguments ..
      CHARACTER          HOWMNY, SIDE
      CHARACTER          HOWMNY, SIDE
 Lines 22-41    Link Here 
*
*
*  CTREVC computes some or all of the right and/or left eigenvectors of
*  CTREVC computes some or all of the right and/or left eigenvectors of
*  a complex upper triangular matrix T.
*  a complex upper triangular matrix T.
*
*  Matrices of this type are produced by the Schur factorization of
*  a complex general matrix:  A = Q*T*Q**H, as computed by CHSEQR.
*  
*  The right eigenvector x and the left eigenvector y of T corresponding
*  The right eigenvector x and the left eigenvector y of T corresponding
*  to an eigenvalue w are defined by:
*  to an eigenvalue w are defined by:
*
*  
*               T*x = w*x,     y'*T = w*y'
*               T*x = w*x,     (y**H)*T = w*(y**H)
*
*  
*  where y' denotes the conjugate transpose of the vector y.
*  where y**H denotes the conjugate transpose of the vector y.
*
*  The eigenvalues are not input to this routine, but are read directly
*  If all eigenvectors are requested, the routine may either return the
*  from the diagonal of T.
*  matrices X and/or Y of right or left eigenvectors of T, or the
*  
*  products Q*X and/or Q*Y, where Q is an input unitary
*  This routine returns the matrices X and/or Y of right and left
*  matrix. If T was obtained from the Schur factorization of an
*  eigenvectors of T, or the products Q*X and/or Q*Y, where Q is an
*  original matrix A = Q*T*Q', then Q*X and Q*Y are the matrices of
*  input matrix.  If Q is the unitary factor that reduces a matrix A to
*  right or left eigenvectors of A.
*  Schur form T, then Q*X and Q*Y are the matrices of right and left
*  eigenvectors of A.
*
*
*  Arguments
*  Arguments
*  =========
*  =========
 Lines 48-64    Link Here 
*  HOWMNY  (input) CHARACTER*1
*  HOWMNY  (input) CHARACTER*1
*          = 'A':  compute all right and/or left eigenvectors;
*          = 'A':  compute all right and/or left eigenvectors;
*          = 'B':  compute all right and/or left eigenvectors,
*          = 'B':  compute all right and/or left eigenvectors,
*                  and backtransform them using the input matrices
*                  backtransformed using the matrices supplied in
*                  supplied in VR and/or VL;
*                  VR and/or VL;
*          = 'S':  compute selected right and/or left eigenvectors,
*          = 'S':  compute selected right and/or left eigenvectors,
*                  specified by the logical array SELECT.
*                  as indicated by the logical array SELECT.
*
*
*  SELECT  (input) LOGICAL array, dimension (N)
*  SELECT  (input) LOGICAL array, dimension (N)
*          If HOWMNY = 'S', SELECT specifies the eigenvectors to be
*          If HOWMNY = 'S', SELECT specifies the eigenvectors to be
*          computed.
*          computed.
*          If HOWMNY = 'A' or 'B', SELECT is not referenced.
*          The eigenvector corresponding to the j-th eigenvalue is
*          To select the eigenvector corresponding to the j-th
*          computed if SELECT(j) = .TRUE..
*          eigenvalue, SELECT(j) must be set to .TRUE..
*          Not referenced if HOWMNY = 'A' or 'B'.
*
*
*  N       (input) INTEGER
*  N       (input) INTEGER
*          The order of the matrix T. N >= 0.
*          The order of the matrix T. N >= 0.
 Lines 76-94    Link Here 
*          Schur vectors returned by CHSEQR).
*          Schur vectors returned by CHSEQR).
*          On exit, if SIDE = 'L' or 'B', VL contains:
*          On exit, if SIDE = 'L' or 'B', VL contains:
*          if HOWMNY = 'A', the matrix Y of left eigenvectors of T;
*          if HOWMNY = 'A', the matrix Y of left eigenvectors of T;
*                           VL is lower triangular. The i-th column
*                           VL(i) of VL is the eigenvector corresponding
*                           to T(i,i).
*          if HOWMNY = 'B', the matrix Q*Y;
*          if HOWMNY = 'B', the matrix Q*Y;
*          if HOWMNY = 'S', the left eigenvectors of T specified by
*          if HOWMNY = 'S', the left eigenvectors of T specified by
*                           SELECT, stored consecutively in the columns
*                           SELECT, stored consecutively in the columns
*                           of VL, in the same order as their
*                           of VL, in the same order as their
*                           eigenvalues.
*                           eigenvalues.
*          If SIDE = 'R', VL is not referenced.
*          Not referenced if SIDE = 'R'.
*
*
*  LDVL    (input) INTEGER
*  LDVL    (input) INTEGER
*          The leading dimension of the array VL.  LDVL >= max(1,N) if
*          The leading dimension of the array VL.  LDVL >= 1, and if
*          SIDE = 'L' or 'B'; LDVL >= 1 otherwise.
*          SIDE = 'L' or 'B', LDVL >= N.
*
*
*  VR      (input/output) COMPLEX array, dimension (LDVR,MM)
*  VR      (input/output) COMPLEX array, dimension (LDVR,MM)
*          On entry, if SIDE = 'R' or 'B' and HOWMNY = 'B', VR must
*          On entry, if SIDE = 'R' or 'B' and HOWMNY = 'B', VR must
 Lines 96-114    Link Here 
*          Schur vectors returned by CHSEQR).
*          Schur vectors returned by CHSEQR).
*          On exit, if SIDE = 'R' or 'B', VR contains:
*          On exit, if SIDE = 'R' or 'B', VR contains:
*          if HOWMNY = 'A', the matrix X of right eigenvectors of T;
*          if HOWMNY = 'A', the matrix X of right eigenvectors of T;
*                           VR is upper triangular. The i-th column
*                           VR(i) of VR is the eigenvector corresponding
*                           to T(i,i).
*          if HOWMNY = 'B', the matrix Q*X;
*          if HOWMNY = 'B', the matrix Q*X;
*          if HOWMNY = 'S', the right eigenvectors of T specified by
*          if HOWMNY = 'S', the right eigenvectors of T specified by
*                           SELECT, stored consecutively in the columns
*                           SELECT, stored consecutively in the columns
*                           of VR, in the same order as their
*                           of VR, in the same order as their
*                           eigenvalues.
*                           eigenvalues.
*          If SIDE = 'L', VR is not referenced.
*          Not referenced if SIDE = 'L'.
*
*
*  LDVR    (input) INTEGER
*  LDVR    (input) INTEGER
*          The leading dimension of the array VR.  LDVR >= max(1,N) if
*          The leading dimension of the array VR.  LDVR >= 1, and if
*           SIDE = 'R' or 'B'; LDVR >= 1 otherwise.
*          SIDE = 'R' or 'B'; LDVR >= N.
*
*
*  MM      (input) INTEGER
*  MM      (input) INTEGER
*          The number of columns in the arrays VL and/or VR. MM >= M.
*          The number of columns in the arrays VL and/or VR. MM >= M.
(-) LAPACK/SRC/ctrsen.f (-5 / +4 lines)
 Lines 4-10    Link Here 
*  -- LAPACK routine (version 3.0) --
*  -- LAPACK routine (version 3.0) --
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Courant Institute, Argonne National Lab, and Rice University
*     Courant Institute, Argonne National Lab, and Rice University
*     June 30, 1999
*     January 3, 2001
*
*
*     .. Scalar Arguments ..
*     .. Scalar Arguments ..
      CHARACTER          COMPQ, JOB
      CHARACTER          COMPQ, JOB
 Lines 93-106    Link Here 
*          If JOB = 'N' or 'E', SEP is not referenced.
*          If JOB = 'N' or 'E', SEP is not referenced.
*
*
*  WORK    (workspace/output) COMPLEX array, dimension (LWORK)
*  WORK    (workspace/output) COMPLEX array, dimension (LWORK)
*          If JOB = 'N', WORK is not referenced.  Otherwise,
*          On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
*          on exit, if INFO = 0, WORK(1) returns the optimal LWORK.
*
*
*  LWORK   (input) INTEGER
*  LWORK   (input) INTEGER
*          The dimension of the array WORK.
*          The dimension of the array WORK.
*          If JOB = 'N', LWORK >= 1;
*          If JOB = 'N', LWORK >= 1;
*          if JOB = 'E', LWORK = M*(N-M);
*          if JOB = 'E', LWORK = max(1,M*(N-M));
*          if JOB = 'V' or 'B', LWORK >= 2*M*(N-M).
*          if JOB = 'V' or 'B', LWORK >= max(1,2*M*(N-M)).
*
*
*          If LWORK = -1, then a workspace query is assumed; the routine
*          If LWORK = -1, then a workspace query is assumed; the routine
*          only calculates the optimal size of the WORK array, returns
*          only calculates the optimal size of the WORK array, returns
(-) LAPACK/SRC/ctrsna.f (-2 / +2 lines)
 Lines 5-11    Link Here 
*  -- LAPACK routine (version 3.0) --
*  -- LAPACK routine (version 3.0) --
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Courant Institute, Argonne National Lab, and Rice University
*     Courant Institute, Argonne National Lab, and Rice University
*     September 30, 1994
*     October 26, 2001 
*
*
*     .. Scalar Arguments ..
*     .. Scalar Arguments ..
      CHARACTER          HOWMNY, JOB
      CHARACTER          HOWMNY, JOB
 Lines 102-108    Link Here 
*          used to store the estimated condition numbers.
*          used to store the estimated condition numbers.
*          If HOWMNY = 'A', M is set to N.
*          If HOWMNY = 'A', M is set to N.
*
*
*  WORK    (workspace) COMPLEX array, dimension (LDWORK,N+1)
*  WORK    (workspace) COMPLEX array, dimension (LDWORK,N+6)
*          If JOB = 'E', WORK is not referenced.
*          If JOB = 'E', WORK is not referenced.
*
*
*  LDWORK  (input) INTEGER
*  LDWORK  (input) INTEGER
(-) LAPACK/SRC/ctrsyl.f (-5 / +3 lines)
 Lines 4-10    Link Here 
*  -- LAPACK routine (version 3.0) --
*  -- LAPACK routine (version 3.0) --
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Courant Institute, Argonne National Lab, and Rice University
*     Courant Institute, Argonne National Lab, and Rice University
*     June 30, 1999
*     January 9, 2001
*
*
*     .. Scalar Arguments ..
*     .. Scalar Arguments ..
      CHARACTER          TRANA, TRANB
      CHARACTER          TRANA, TRANB
 Lines 119-129    Link Here 
      NOTRNB = LSAME( TRANB, 'N' )
      NOTRNB = LSAME( TRANB, 'N' )
*
*
      INFO = 0
      INFO = 0
      IF( .NOT.NOTRNA .AND. .NOT.LSAME( TRANA, 'T' ) .AND. .NOT.
      IF( .NOT.NOTRNA .AND. .NOT.LSAME( TRANA, 'C' ) ) THEN
     $    LSAME( TRANA, 'C' ) ) THEN
         INFO = -1
         INFO = -1
      ELSE IF( .NOT.NOTRNB .AND. .NOT.LSAME( TRANB, 'T' ) .AND. .NOT.
      ELSE IF( .NOT.NOTRNB .AND. .NOT.LSAME( TRANB, 'C' ) ) THEN
     $         LSAME( TRANB, 'C' ) ) THEN
         INFO = -2
         INFO = -2
      ELSE IF( ISGN.NE.1 .AND. ISGN.NE.-1 ) THEN
      ELSE IF( ISGN.NE.1 .AND. ISGN.NE.-1 ) THEN
         INFO = -3
         INFO = -3
(-) LAPACK/SRC/dbdsqr.f (-18 / +30 lines)
 Lines 4-10    Link Here 
*  -- LAPACK routine (version 3.0) --
*  -- LAPACK routine (version 3.0) --
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Courant Institute, Argonne National Lab, and Rice University
*     Courant Institute, Argonne National Lab, and Rice University
*     October 31, 1999
*     April 25, 2001
*
*
*     .. Scalar Arguments ..
*     .. Scalar Arguments ..
      CHARACTER          UPLO
      CHARACTER          UPLO
 Lines 18-31    Link Here 
*  Purpose
*  Purpose
*  =======
*  =======
*
*
*  DBDSQR computes the singular value decomposition (SVD) of a real
*  DBDSQR computes the singular values and, optionally, the right and/or
*  N-by-N (upper or lower) bidiagonal matrix B:  B = Q * S * P' (P'
*  left singular vectors from the singular value decomposition (SVD) of
*  denotes the transpose of P), where S is a diagonal matrix with
*  a real N-by-N (upper or lower) bidiagonal matrix B using the implicit
*  non-negative diagonal elements (the singular values of B), and Q
*  zero-shift QR algorithm.  The SVD of B has the form
*  and P are orthogonal matrices.
* 
*     B = Q * S * P**T
* 
*  where S is the diagonal matrix of singular values, Q is an orthogonal
*  matrix of left singular vectors, and P is an orthogonal matrix of
*  right singular vectors.  If left singular vectors are requested, this
*  subroutine actually returns U*Q instead of Q, and, if right singular
*  vectors are requested, this subroutine returns P**T*VT instead of
*  P**T, for given real input matrices U and VT.  When U and VT are the
*  orthogonal matrices that reduce a general matrix A to bidiagonal
*  form:  A = U*B*VT, as computed by DGEBRD, then
*
*
*  The routine computes S, and optionally computes U * Q, P' * VT,
*     A = (U*Q) * S * (P**T*VT)
*  or Q' * C, for given real input matrices U, VT, and C.
*
*  is the SVD of A.  Optionally, the subroutine may also compute Q**T*C
*  for a given real input matrix C.
*
*
*  See "Computing  Small Singular Values of Bidiagonal Matrices With
*  See "Computing  Small Singular Values of Bidiagonal Matrices With
*  Guaranteed High Relative Accuracy," by J. Demmel and W. Kahan,
*  Guaranteed High Relative Accuracy," by J. Demmel and W. Kahan,
 Lines 61-78    Link Here 
*          order.
*          order.
*
*
*  E       (input/output) DOUBLE PRECISION array, dimension (N)
*  E       (input/output) DOUBLE PRECISION array, dimension (N)
*          On entry, the elements of E contain the
*          On entry, the N-1 offdiagonal elements of the bidiagonal
*          offdiagonal elements of the bidiagonal matrix whose SVD
*          matrix B. 
*          is desired. On normal exit (INFO = 0), E is destroyed.
*          On exit, if INFO = 0, E is destroyed; if INFO > 0, D and E
*          If the algorithm does not converge (INFO > 0), D and E
*          will contain the diagonal and superdiagonal elements of a
*          will contain the diagonal and superdiagonal elements of a
*          bidiagonal matrix orthogonally equivalent to the one given
*          bidiagonal matrix orthogonally equivalent to the one given
*          as input. E(N) is used for workspace.
*          as input. E(N) is used for workspace.
*
*
*  VT      (input/output) DOUBLE PRECISION array, dimension (LDVT, NCVT)
*  VT      (input/output) DOUBLE PRECISION array, dimension (LDVT, NCVT)
*          On entry, an N-by-NCVT matrix VT.
*          On entry, an N-by-NCVT matrix VT.
*          On exit, VT is overwritten by P' * VT.
*          On exit, VT is overwritten by P**T * VT.
*          VT is not referenced if NCVT = 0.
*          Not referenced if NCVT = 0.
*
*
*  LDVT    (input) INTEGER
*  LDVT    (input) INTEGER
*          The leading dimension of the array VT.
*          The leading dimension of the array VT.
 Lines 81-101    Link Here 
*  U       (input/output) DOUBLE PRECISION array, dimension (LDU, N)
*  U       (input/output) DOUBLE PRECISION array, dimension (LDU, N)
*          On entry, an NRU-by-N matrix U.
*          On entry, an NRU-by-N matrix U.
*          On exit, U is overwritten by U * Q.
*          On exit, U is overwritten by U * Q.
*          U is not referenced if NRU = 0.
*          Not referenced if NRU = 0.
*
*
*  LDU     (input) INTEGER
*  LDU     (input) INTEGER
*          The leading dimension of the array U.  LDU >= max(1,NRU).
*          The leading dimension of the array U.  LDU >= max(1,NRU).
*
*
*  C       (input/output) DOUBLE PRECISION array, dimension (LDC, NCC)
*  C       (input/output) DOUBLE PRECISION array, dimension (LDC, NCC)
*          On entry, an N-by-NCC matrix C.
*          On entry, an N-by-NCC matrix C.
*          On exit, C is overwritten by Q' * C.
*          On exit, C is overwritten by Q**T * C.
*          C is not referenced if NCC = 0.
*          Not referenced if NCC = 0.
*
*
*  LDC     (input) INTEGER
*  LDC     (input) INTEGER
*          The leading dimension of the array C.
*          The leading dimension of the array C.
*          LDC >= max(1,N) if NCC > 0; LDC >=1 if NCC = 0.
*          LDC >= max(1,N) if NCC > 0; LDC >=1 if NCC = 0.
*
*
*  WORK    (workspace) DOUBLE PRECISION array, dimension (4*N)
*  WORK    (workspace) DOUBLE PRECISION array, dimension (2*N)
*          if NCVT = NRU = NCC = 0, (max(1, 4*N-4)) otherwise
*
*
*  INFO    (output) INTEGER
*  INFO    (output) INTEGER
*          = 0:  successful exit
*          = 0:  successful exit
(-) LAPACK/SRC/dgebd2.f (-5 / +7 lines)
 Lines 3-9    Link Here 
*  -- LAPACK routine (version 3.0) --
*  -- LAPACK routine (version 3.0) --
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Courant Institute, Argonne National Lab, and Rice University
*     Courant Institute, Argonne National Lab, and Rice University
*     February 29, 1992
*     May 7, 2001
*
*
*     .. Scalar Arguments ..
*     .. Scalar Arguments ..
      INTEGER            INFO, LDA, M, N
      INTEGER            INFO, LDA, M, N
 Lines 169-176    Link Here 
*
*
*           Apply H(i) to A(i:m,i+1:n) from the left
*           Apply H(i) to A(i:m,i+1:n) from the left
*
*
            CALL DLARF( 'Left', M-I+1, N-I, A( I, I ), 1, TAUQ( I ),
            IF( I.LT.N )
     $                  A( I, I+1 ), LDA, WORK )
     $         CALL DLARF( 'Left', M-I+1, N-I, A( I, I ), 1, TAUQ( I ),
     $                     A( I, I+1 ), LDA, WORK )
            A( I, I ) = D( I )
            A( I, I ) = D( I )
*
*
            IF( I.LT.N ) THEN
            IF( I.LT.N ) THEN
 Lines 207-214    Link Here 
*
*
*           Apply G(i) to A(i+1:m,i:n) from the right
*           Apply G(i) to A(i+1:m,i:n) from the right
*
*
            CALL DLARF( 'Right', M-I, N-I+1, A( I, I ), LDA, TAUP( I ),
            IF( I.LT.M )
     $                  A( MIN( I+1, M ), I ), LDA, WORK )
     $         CALL DLARF( 'Right', M-I, N-I+1, A( I, I ), LDA,
     $                     TAUP( I ), A( MIN( I+1, M ), I ), LDA, WORK )
            A( I, I ) = D( I )
            A( I, I ) = D( I )
*
*
            IF( I.LT.M ) THEN
            IF( I.LT.M ) THEN
(-) LAPACK/SRC/dgees.f (-18 / +17 lines)
 Lines 5-10    Link Here 
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Courant Institute, Argonne National Lab, and Rice University
*     Courant Institute, Argonne National Lab, and Rice University
*     June 30, 1999
*     June 30, 1999
*     8-15-00:  Improve consistency of WS calculations (eca)
*
*
*     .. Scalar Arguments ..
*     .. Scalar Arguments ..
      CHARACTER          JOBVS, SORT
      CHARACTER          JOBVS, SORT
 Lines 110-119    Link Here 
*          The dimension of the array WORK.  LWORK >= max(1,3*N).
*          The dimension of the array WORK.  LWORK >= max(1,3*N).
*          For good performance, LWORK must generally be larger.
*          For good performance, LWORK must generally be larger.
*
*
*          If LWORK = -1, then a workspace query is assumed; the routine
*          If LWORK = -1, a workspace query is assumed.  The optimal
*          only calculates the optimal size of the WORK array, returns
*          size for the WORK array is calculated and stored in WORK(1),
*          this value as the first entry of the WORK array, and no error
*          and no other work except argument checking is performed.
*          message related to LWORK is issued by XERBLA.
*
*
*  BWORK   (workspace) LOGICAL array, dimension (N)
*  BWORK   (workspace) LOGICAL array, dimension (N)
*          Not referenced if SORT = 'N'.
*          Not referenced if SORT = 'N'.
 Lines 138-149    Link Here 
*  =====================================================================
*  =====================================================================
*
*
*     .. Parameters ..
*     .. Parameters ..
      INTEGER            LQUERV
      PARAMETER          ( LQUERV = -1 )
      DOUBLE PRECISION   ZERO, ONE
      DOUBLE PRECISION   ZERO, ONE
      PARAMETER          ( ZERO = 0.0D0, ONE = 1.0D0 )
      PARAMETER          ( ZERO = 0.0D0, ONE = 1.0D0 )
*     ..
*     ..
*     .. Local Scalars ..
*     .. Local Scalars ..
      LOGICAL            CURSL, LASTSL, LQUERY, LST2SL, SCALEA, WANTST,
      LOGICAL            CURSL, LASTSL, LST2SL, SCALEA, WANTST, WANTVS
     $                   WANTVS
      INTEGER            HSWORK, I, I1, I2, IBAL, ICOND, IERR, IEVAL,
      INTEGER            HSWORK, I, I1, I2, IBAL, ICOND, IERR, IEVAL,
     $                   IHI, ILO, INXT, IP, ITAU, IWRK, K, MAXB,
     $                   IHI, ILO, INXT, IP, ITAU, IWRK, K, MAXB,
     $                   MAXWRK, MINWRK
     $                   MAXWRK, MINWRK
 Lines 154-161    Link Here 
      DOUBLE PRECISION   DUM( 1 )
      DOUBLE PRECISION   DUM( 1 )
*     ..
*     ..
*     .. External Subroutines ..
*     .. External Subroutines ..
      EXTERNAL           DCOPY, DGEBAK, DGEBAL, DGEHRD, DHSEQR, DLACPY,
      EXTERNAL           DCOPY, DGEBAK, DGEBAL, DGEHRD, DHSEQR, DLABAD,
     $                   DLASCL, DORGHR, DSWAP, DTRSEN, XERBLA
     $                   DLACPY, DLASCL, DORGHR, DSWAP, DTRSEN, XERBLA
*     ..
*     ..
*     .. External Functions ..
*     .. External Functions ..
      LOGICAL            LSAME
      LOGICAL            LSAME
 Lines 171-177    Link Here 
*     Test the input arguments
*     Test the input arguments
*
*
      INFO = 0
      INFO = 0
      LQUERY = ( LWORK.EQ.-1 )
      WANTVS = LSAME( JOBVS, 'V' )
      WANTVS = LSAME( JOBVS, 'V' )
      WANTST = LSAME( SORT, 'S' )
      WANTST = LSAME( SORT, 'S' )
      IF( ( .NOT.WANTVS ) .AND. ( .NOT.LSAME( JOBVS, 'N' ) ) ) THEN
      IF( ( .NOT.WANTVS ) .AND. ( .NOT.LSAME( JOBVS, 'N' ) ) ) THEN
 Lines 197-203    Link Here 
*       the worst case.)
*       the worst case.)
*
*
      MINWRK = 1
      MINWRK = 1
      IF( INFO.EQ.0 .AND. ( LWORK.GE.1 .OR. LQUERY ) ) THEN
      IF( INFO.EQ.0 ) THEN
         MAXWRK = 2*N + N*ILAENV( 1, 'DGEHRD', ' ', N, 1, N, 0 )
         MAXWRK = 2*N + N*ILAENV( 1, 'DGEHRD', ' ', N, 1, N, 0 )
         MINWRK = MAX( 1, 3*N )
         MINWRK = MAX( 1, 3*N )
         IF( .NOT.WANTVS ) THEN
         IF( .NOT.WANTVS ) THEN
 Lines 216-234    Link Here 
            MAXWRK = MAX( MAXWRK, N+HSWORK, 1 )
            MAXWRK = MAX( MAXWRK, N+HSWORK, 1 )
         END IF
         END IF
         WORK( 1 ) = MAXWRK
         WORK( 1 ) = MAXWRK
         IF( LWORK.LT.MINWRK .AND. LWORK.NE.LQUERV )
     $      INFO = -13
      END IF
      END IF
      IF( LWORK.LT.MINWRK .AND. .NOT.LQUERY ) THEN
*
         INFO = -13
*     Quick returns
      END IF
*
      IF( INFO.NE.0 ) THEN
      IF( INFO.NE.0 ) THEN
         CALL XERBLA( 'DGEES ', -INFO )
         CALL XERBLA( 'DGEES ', -INFO )
         RETURN
         RETURN
      ELSE IF( LQUERY ) THEN
         RETURN
      END IF
      END IF
*
      IF( LWORK.EQ.LQUERV )
*     Quick return if possible
     $   RETURN
*
      IF( N.EQ.0 ) THEN
      IF( N.EQ.0 ) THEN
         SDIM = 0
         SDIM = 0
         RETURN
         RETURN
(-) LAPACK/SRC/dgeesx.f (-12 / +23 lines)
 Lines 6-11    Link Here 
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Courant Institute, Argonne National Lab, and Rice University
*     Courant Institute, Argonne National Lab, and Rice University
*     June 30, 1999
*     June 30, 1999
*     8-15-00:  Do WS calculations if LWORK = -1 (eca)
*
*
*     .. Scalar Arguments ..
*     .. Scalar Arguments ..
      CHARACTER          JOBVS, SENSE, SORT
      CHARACTER          JOBVS, SENSE, SORT
 Lines 140-145    Link Here 
*          N+2*SDIM*(N-SDIM) <= N+N*N/2.
*          N+2*SDIM*(N-SDIM) <= N+N*N/2.
*          For good performance, LWORK must generally be larger.
*          For good performance, LWORK must generally be larger.
*
*
*          If LWORK = -1, a workspace query is assumed.  The optimal
*          size for the WORK array is calculated and stored in WORK(1),
*          and no other work except argument checking is performed.
*
*  IWORK   (workspace/output) INTEGER array, dimension (LIWORK)
*  IWORK   (workspace/output) INTEGER array, dimension (LIWORK)
*          Not referenced if SENSE = 'N' or 'E'.
*          Not referenced if SENSE = 'N' or 'E'.
*          On exit, if INFO = 0, IWORK(1) returns the optimal LIWORK.
*          On exit, if INFO = 0, IWORK(1) returns the optimal LIWORK.
 Lines 171-176    Link Here 
*  =====================================================================
*  =====================================================================
*
*
*     .. Parameters ..
*     .. Parameters ..
      INTEGER            LQUERV
      PARAMETER          ( LQUERV = -1 )
      DOUBLE PRECISION   ZERO, ONE
      DOUBLE PRECISION   ZERO, ONE
      PARAMETER          ( ZERO = 0.0D0, ONE = 1.0D0 )
      PARAMETER          ( ZERO = 0.0D0, ONE = 1.0D0 )
*     ..
*     ..
 Lines 186-193    Link Here 
      DOUBLE PRECISION   DUM( 1 )
      DOUBLE PRECISION   DUM( 1 )
*     ..
*     ..
*     .. External Subroutines ..
*     .. External Subroutines ..
      EXTERNAL           DCOPY, DGEBAK, DGEBAL, DGEHRD, DHSEQR, DLACPY,
      EXTERNAL           DCOPY, DGEBAK, DGEBAL, DGEHRD, DHSEQR, DLABAD,
     $                   DLASCL, DORGHR, DSWAP, DTRSEN, XERBLA
     $                   DLACPY, DLASCL, DORGHR, DSWAP, DTRSEN, XERBLA
*     ..
*     ..
*     .. External Functions ..
*     .. External Functions ..
      LOGICAL            LSAME
      LOGICAL            LSAME
 Lines 239-245    Link Here 
*       in the code.)
*       in the code.)
*
*
      MINWRK = 1
      MINWRK = 1
      IF( INFO.EQ.0 .AND. LWORK.GE.1 ) THEN
      IF( INFO.EQ.0 ) THEN
         MAXWRK = 2*N + N*ILAENV( 1, 'DGEHRD', ' ', N, 1, N, 0 )
         MAXWRK = 2*N + N*ILAENV( 1, 'DGEHRD', ' ', N, 1, N, 0 )
         MINWRK = MAX( 1, 3*N )
         MINWRK = MAX( 1, 3*N )
         IF( .NOT.WANTVS ) THEN
         IF( .NOT.WANTVS ) THEN
 Lines 257-277    Link Here 
            HSWORK = MAX( K*( K+2 ), 2*N )
            HSWORK = MAX( K*( K+2 ), 2*N )
            MAXWRK = MAX( MAXWRK, N+HSWORK, 1 )
            MAXWRK = MAX( MAXWRK, N+HSWORK, 1 )
         END IF
         END IF
*
*        Estimate the workspace needed by DTRSEN.
*
         IF( WANTST ) THEN
            MAXWRK = MAX( MAXWRK, N+( N*N+1 ) / 2 )
         END IF
         WORK( 1 ) = MAXWRK
         WORK( 1 ) = MAXWRK
         IF( LWORK.LT.MINWRK .AND. LWORK.NE.LQUERV )
     $      INFO = -16
      END IF
      END IF
      IF( LWORK.LT.MINWRK ) THEN
*
         INFO = -16
*     Quick returns
      END IF
*
      IF( LIWORK.LT.1 ) THEN
         INFO = -18
      END IF
      IF( INFO.NE.0 ) THEN
      IF( INFO.NE.0 ) THEN
         CALL XERBLA( 'DGEESX', -INFO )
         CALL XERBLA( 'DGEESX', -INFO )
         RETURN
         RETURN
      END IF
      END IF
*
      IF( LWORK.EQ.LQUERV )
*     Quick return if possible
     $   RETURN
*
      IF( N.EQ.0 ) THEN
      IF( N.EQ.0 ) THEN
         SDIM = 0
         SDIM = 0
         RETURN
         RETURN
(-) LAPACK/SRC/dgeev.f (-18 / +19 lines)
 Lines 4-10    Link Here 
*  -- LAPACK driver routine (version 3.0) --
*  -- LAPACK driver routine (version 3.0) --
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Courant Institute, Argonne National Lab, and Rice University
*     Courant Institute, Argonne National Lab, and Rice University
*     December 8, 1999
*     June 30, 1999
*     8-15-00:  Improve consistency of WS calculations (eca)
*
*
*     .. Scalar Arguments ..
*     .. Scalar Arguments ..
      CHARACTER          JOBVL, JOBVR
      CHARACTER          JOBVL, JOBVR
 Lines 98-107    Link Here 
*          if JOBVL = 'V' or JOBVR = 'V', LWORK >= 4*N.  For good
*          if JOBVL = 'V' or JOBVR = 'V', LWORK >= 4*N.  For good
*          performance, LWORK must generally be larger.
*          performance, LWORK must generally be larger.
*
*
*          If LWORK = -1, then a workspace query is assumed; the routine
*          If LWORK = -1, a workspace query is assumed.  The optimal
*          only calculates the optimal size of the WORK array, returns
*          size for the WORK array is calculated and stored in WORK(1),
*          this value as the first entry of the WORK array, and no error
*          and no other work except argument checking is performed.
*          message related to LWORK is issued by XERBLA.
*
*
*  INFO    (output) INTEGER
*  INFO    (output) INTEGER
*          = 0:  successful exit
*          = 0:  successful exit
 Lines 114-124    Link Here 
*  =====================================================================
*  =====================================================================
*
*
*     .. Parameters ..
*     .. Parameters ..
      INTEGER            LQUERV
      PARAMETER          ( LQUERV = -1 )
      DOUBLE PRECISION   ZERO, ONE
      DOUBLE PRECISION   ZERO, ONE
      PARAMETER          ( ZERO = 0.0D0, ONE = 1.0D0 )
      PARAMETER          ( ZERO = 0.0D0, ONE = 1.0D0 )
*     ..
*     ..
*     .. Local Scalars ..
*     .. Local Scalars ..
      LOGICAL            LQUERY, SCALEA, WANTVL, WANTVR
      LOGICAL            SCALEA, WANTVL, WANTVR
      CHARACTER          SIDE
      CHARACTER          SIDE
      INTEGER            HSWORK, I, IBAL, IERR, IHI, ILO, ITAU, IWRK, K,
      INTEGER            HSWORK, I, IBAL, IERR, IHI, ILO, ITAU, IWRK, K,
     $                   MAXB, MAXWRK, MINWRK, NOUT
     $                   MAXB, MAXWRK, MINWRK, NOUT
 Lines 130-137    Link Here 
      DOUBLE PRECISION   DUM( 1 )
      DOUBLE PRECISION   DUM( 1 )
*     ..
*     ..
*     .. External Subroutines ..
*     .. External Subroutines ..
      EXTERNAL           DGEBAK, DGEBAL, DGEHRD, DHSEQR, DLACPY, DLARTG,
      EXTERNAL           DGEBAK, DGEBAL, DGEHRD, DHSEQR, DLABAD, DLACPY,
     $                   DLASCL, DORGHR, DROT, DSCAL, DTREVC, XERBLA
     $                   DLARTG, DLASCL, DORGHR, DROT, DSCAL, DTREVC,
     $                   XERBLA
*     ..
*     ..
*     .. External Functions ..
*     .. External Functions ..
      LOGICAL            LSAME
      LOGICAL            LSAME
 Lines 148-154    Link Here 
*     Test the input arguments
*     Test the input arguments
*
*
      INFO = 0
      INFO = 0
      LQUERY = ( LWORK.EQ.-1 )
      WANTVL = LSAME( JOBVL, 'V' )
      WANTVL = LSAME( JOBVL, 'V' )
      WANTVR = LSAME( JOBVR, 'V' )
      WANTVR = LSAME( JOBVR, 'V' )
      IF( ( .NOT.WANTVL ) .AND. ( .NOT.LSAME( JOBVL, 'N' ) ) ) THEN
      IF( ( .NOT.WANTVL ) .AND. ( .NOT.LSAME( JOBVL, 'N' ) ) ) THEN
 Lines 176-182    Link Here 
*       the worst case.)
*       the worst case.)
*
*
      MINWRK = 1
      MINWRK = 1
      IF( INFO.EQ.0 .AND. ( LWORK.GE.1 .OR. LQUERY ) ) THEN
      IF( INFO.EQ.0 ) THEN
         MAXWRK = 2*N + N*ILAENV( 1, 'DGEHRD', ' ', N, 1, N, 0 )
         MAXWRK = 2*N + N*ILAENV( 1, 'DGEHRD', ' ', N, 1, N, 0 )
         IF( ( .NOT.WANTVL ) .AND. ( .NOT.WANTVR ) ) THEN
         IF( ( .NOT.WANTVL ) .AND. ( .NOT.WANTVR ) ) THEN
            MINWRK = MAX( 1, 3*N )
            MINWRK = MAX( 1, 3*N )
 Lines 197-215    Link Here 
            MAXWRK = MAX( MAXWRK, 4*N )
            MAXWRK = MAX( MAXWRK, 4*N )
         END IF
         END IF
         WORK( 1 ) = MAXWRK
         WORK( 1 ) = MAXWRK
         IF( LWORK.LT.MINWRK .AND. LWORK.NE.LQUERV )
     $      INFO = -13
      END IF
      END IF
      IF( LWORK.LT.MINWRK .AND. .NOT.LQUERY ) THEN
*
         INFO = -13
*     Quick returns
      END IF
*
      IF( INFO.NE.0 ) THEN
      IF( INFO.NE.0 ) THEN
         CALL XERBLA( 'DGEEV ', -INFO )
         CALL XERBLA( 'DGEEV ', -INFO )
         RETURN
         RETURN
      ELSE IF( LQUERY ) THEN
         RETURN
      END IF
      END IF
*
      IF( LWORK.EQ.LQUERV )
*     Quick return if possible
     $   RETURN
*
      IF( N.EQ.0 )
      IF( N.EQ.0 )
     $   RETURN
     $   RETURN
*
*
(-) LAPACK/SRC/dgeevx.f (-19 / +19 lines)
 Lines 6-11    Link Here 
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Courant Institute, Argonne National Lab, and Rice University
*     Courant Institute, Argonne National Lab, and Rice University
*     June 30, 1999
*     June 30, 1999
*     8-15-00:  Improve consistency of WS calculations (eca)
*
*
*     .. Scalar Arguments ..
*     .. Scalar Arguments ..
      CHARACTER          BALANC, JOBVL, JOBVR, SENSE
      CHARACTER          BALANC, JOBVL, JOBVR, SENSE
 Lines 179-188    Link Here 
*          LWORK >= 3*N.  If SENSE = 'V' or 'B', LWORK >= N*(N+6).
*          LWORK >= 3*N.  If SENSE = 'V' or 'B', LWORK >= N*(N+6).
*          For good performance, LWORK must generally be larger.
*          For good performance, LWORK must generally be larger.
*
*
*          If LWORK = -1, then a workspace query is assumed; the routine
*          If LWORK = -1, a workspace query is assumed.  The optimal
*          only calculates the optimal size of the WORK array, returns
*          size for the WORK array is calculated and stored in WORK(1),
*          this value as the first entry of the WORK array, and no error
*          and no other work except argument checking is performed.
*          message related to LWORK is issued by XERBLA.
*
*
*  IWORK   (workspace) INTEGER array, dimension (2*N-2)
*  IWORK   (workspace) INTEGER array, dimension (2*N-2)
*          If SENSE = 'N' or 'E', not referenced.
*          If SENSE = 'N' or 'E', not referenced.
 Lines 198-209    Link Here 
*  =====================================================================
*  =====================================================================
*
*
*     .. Parameters ..
*     .. Parameters ..
      INTEGER            LQUERV
      PARAMETER          ( LQUERV = -1 )
      DOUBLE PRECISION   ZERO, ONE
      DOUBLE PRECISION   ZERO, ONE
      PARAMETER          ( ZERO = 0.0D0, ONE = 1.0D0 )
      PARAMETER          ( ZERO = 0.0D0, ONE = 1.0D0 )
*     ..
*     ..
*     .. Local Scalars ..
*     .. Local Scalars ..
      LOGICAL            LQUERY, SCALEA, WANTVL, WANTVR, WNTSNB, WNTSNE,
      LOGICAL            SCALEA, WANTVL, WANTVR, WNTSNB, WNTSNE, WNTSNN,
     $                   WNTSNN, WNTSNV
     $                   WNTSNV
      CHARACTER          JOB, SIDE
      CHARACTER          JOB, SIDE
      INTEGER            HSWORK, I, ICOND, IERR, ITAU, IWRK, K, MAXB,
      INTEGER            HSWORK, I, ICOND, IERR, ITAU, IWRK, K, MAXB,
     $                   MAXWRK, MINWRK, NOUT
     $                   MAXWRK, MINWRK, NOUT
 Lines 215-223    Link Here 
      DOUBLE PRECISION   DUM( 1 )
      DOUBLE PRECISION   DUM( 1 )
*     ..
*     ..
*     .. External Subroutines ..
*     .. External Subroutines ..
      EXTERNAL           DGEBAK, DGEBAL, DGEHRD, DHSEQR, DLACPY, DLARTG,
      EXTERNAL           DGEBAK, DGEBAL, DGEHRD, DHSEQR, DLABAD, DLACPY,
     $                   DLASCL, DORGHR, DROT, DSCAL, DTREVC, DTRSNA,
     $                   DLARTG, DLASCL, DORGHR, DROT, DSCAL, DTREVC,
     $                   XERBLA
     $                   DTRSNA, XERBLA
*     ..
*     ..
*     .. External Functions ..
*     .. External Functions ..
      LOGICAL            LSAME
      LOGICAL            LSAME
 Lines 234-240    Link Here 
*     Test the input arguments
*     Test the input arguments
*
*
      INFO = 0
      INFO = 0
      LQUERY = ( LWORK.EQ.-1 )
      WANTVL = LSAME( JOBVL, 'V' )
      WANTVL = LSAME( JOBVL, 'V' )
      WANTVR = LSAME( JOBVR, 'V' )
      WANTVR = LSAME( JOBVR, 'V' )
      WNTSNN = LSAME( SENSE, 'N' )
      WNTSNN = LSAME( SENSE, 'N' )
 Lines 274-280    Link Here 
*       the worst case.)
*       the worst case.)
*
*
      MINWRK = 1
      MINWRK = 1
      IF( INFO.EQ.0 .AND. ( LWORK.GE.1 .OR. LQUERY ) ) THEN
      IF( INFO.EQ.0 ) THEN
         MAXWRK = N + N*ILAENV( 1, 'DGEHRD', ' ', N, 1, N, 0 )
         MAXWRK = N + N*ILAENV( 1, 'DGEHRD', ' ', N, 1, N, 0 )
         IF( ( .NOT.WANTVL ) .AND. ( .NOT.WANTVR ) ) THEN
         IF( ( .NOT.WANTVL ) .AND. ( .NOT.WANTVR ) ) THEN
            MINWRK = MAX( 1, 2*N )
            MINWRK = MAX( 1, 2*N )
 Lines 308-326    Link Here 
            MAXWRK = MAX( MAXWRK, 3*N, 1 )
            MAXWRK = MAX( MAXWRK, 3*N, 1 )
         END IF
         END IF
         WORK( 1 ) = MAXWRK
         WORK( 1 ) = MAXWRK
         IF( LWORK.LT.MINWRK .AND. LWORK.NE.LQUERV )
     $      INFO = -21
      END IF
      END IF
      IF( LWORK.LT.MINWRK .AND. .NOT.LQUERY ) THEN
*
         INFO = -21
*     Quick returns
      END IF
*
      IF( INFO.NE.0 ) THEN
      IF( INFO.NE.0 ) THEN
         CALL XERBLA( 'DGEEVX', -INFO )
         CALL XERBLA( 'DGEEVX', -INFO )
         RETURN
         RETURN
      ELSE IF( LQUERY ) THEN
         RETURN
      END IF
      END IF
*
      IF( LWORK.EQ.LQUERV )
*     Quick return if possible
     $   RETURN
*
      IF( N.EQ.0 )
      IF( N.EQ.0 )
     $   RETURN
     $   RETURN
*
*
(-) LAPACK/SRC/dgegs.f (-73 / +42 lines)
 Lines 5-11    Link Here 
*  -- LAPACK driver routine (version 3.0) --
*  -- LAPACK driver routine (version 3.0) --
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Courant Institute, Argonne National Lab, and Rice University
*     Courant Institute, Argonne National Lab, and Rice University
*     June 30, 1999
*     April 26, 2001
*
*
*     .. Scalar Arguments ..
*     .. Scalar Arguments ..
      CHARACTER          JOBVSL, JOBVSR
      CHARACTER          JOBVSL, JOBVSR
 Lines 22-126    Link Here 
*
*
*  This routine is deprecated and has been replaced by routine DGGES.
*  This routine is deprecated and has been replaced by routine DGGES.
*
*
*  DGEGS computes for a pair of N-by-N real nonsymmetric matrices A, B:
*  DGEGS computes the eigenvalues, real Schur form, and, optionally,
*  the generalized eigenvalues (alphar +/- alphai*i, beta), the real
*  left and or/right Schur vectors of a real matrix pair (A,B).
*  Schur form (A, B), and optionally left and/or right Schur vectors
*  Given two square matrices A and B, the generalized real Schur
*  (VSL and VSR).
*  factorization has the form
*
*
*  (If only the generalized eigenvalues are needed, use the driver DGEGV
*    A = Q*S*Z**T,  B = Q*T*Z**T
*  instead.)
*
*
*  where Q and Z are orthogonal matrices, T is upper triangular, and S
*  A generalized eigenvalue for a pair of matrices (A,B) is, roughly
*  is an upper quasi-triangular matrix with 1-by-1 and 2-by-2 diagonal
*  speaking, a scalar w or a ratio  alpha/beta = w, such that  A - w*B
*  blocks, the 2-by-2 blocks corresponding to complex conjugate pairs
*  is singular.  It is usually represented as the pair (alpha,beta),
*  of eigenvalues of (A,B).  The columns of Q are the left Schur vectors
*  as there is a reasonable interpretation for beta=0, and even for
*  and the columns of Z are the right Schur vectors.
*  both being zero.  A good beginning reference is the book, "Matrix
*
*  Computations", by G. Golub & C. van Loan (Johns Hopkins U. Press)
*  If only the eigenvalues of (A,B) are needed, the driver routine
*
*  DGEGV should be used instead.  See DGEGV for a description of the
*  The (generalized) Schur form of a pair of matrices is the result of
*  eigenvalues of the generalized nonsymmetric eigenvalue problem
*  multiplying both matrices on the left by one orthogonal matrix and
*  (GNEP).
*  both on the right by another orthogonal matrix, these two orthogonal
*  matrices being chosen so as to bring the pair of matrices into
*  (real) Schur form.
*
*  A pair of matrices A, B is in generalized real Schur form if B is
*  upper triangular with non-negative diagonal and A is block upper
*  triangular with 1-by-1 and 2-by-2 blocks.  1-by-1 blocks correspond
*  to real generalized eigenvalues, while 2-by-2 blocks of A will be
*  "standardized" by making the corresponding elements of B have the
*  form:
*          [  a  0  ]
*          [  0  b  ]
*
*  and the pair of corresponding 2-by-2 blocks in A and B will
*  have a complex conjugate pair of generalized eigenvalues.
*
*  The left and right Schur vectors are the columns of VSL and VSR,
*  respectively, where VSL and VSR are the orthogonal matrices
*  which reduce A and B to Schur form:
*
*  Schur form of (A,B) = ( (VSL)**T A (VSR), (VSL)**T B (VSR) )
*
*
*  Arguments
*  Arguments
*  =========
*  =========
*
*
*  JOBVSL  (input) CHARACTER*1
*  JOBVSL  (input) CHARACTER*1
*          = 'N':  do not compute the left Schur vectors;
*          = 'N':  do not compute the left Schur vectors;
*          = 'V':  compute the left Schur vectors.
*          = 'V':  compute the left Schur vectors (returned in VSL).
*
*
*  JOBVSR  (input) CHARACTER*1
*  JOBVSR  (input) CHARACTER*1
*          = 'N':  do not compute the right Schur vectors;
*          = 'N':  do not compute the right Schur vectors;
*          = 'V':  compute the right Schur vectors.
*          = 'V':  compute the right Schur vectors (returned in VSR).
*
*
*  N       (input) INTEGER
*  N       (input) INTEGER
*          The order of the matrices A, B, VSL, and VSR.  N >= 0.
*          The order of the matrices A, B, VSL, and VSR.  N >= 0.
*
*
*  A       (input/output) DOUBLE PRECISION array, dimension (LDA, N)
*  A       (input/output) DOUBLE PRECISION array, dimension (LDA, N)
*          On entry, the first of the pair of matrices whose generalized
*          On entry, the matrix A.
*          eigenvalues and (optionally) Schur vectors are to be
*          On exit, the upper quasi-triangular matrix S from the
*          computed.
*          generalized real Schur factorization.
*          On exit, the generalized Schur form of A.
*          Note: to avoid overflow, the Frobenius norm of the matrix
*          A should be less than the overflow threshold.
*
*
*  LDA     (input) INTEGER
*  LDA     (input) INTEGER
*          The leading dimension of A.  LDA >= max(1,N).
*          The leading dimension of A.  LDA >= max(1,N).
*
*
*  B       (input/output) DOUBLE PRECISION array, dimension (LDB, N)
*  B       (input/output) DOUBLE PRECISION array, dimension (LDB, N)
*          On entry, the second of the pair of matrices whose
*          On entry, the matrix B.
*          generalized eigenvalues and (optionally) Schur vectors are
*          On exit, the upper triangular matrix T from the generalized
*          to be computed.
*          real Schur factorization.
*          On exit, the generalized Schur form of B.
*          Note: to avoid overflow, the Frobenius norm of the matrix
*          B should be less than the overflow threshold.
*
*
*  LDB     (input) INTEGER
*  LDB     (input) INTEGER
*          The leading dimension of B.  LDB >= max(1,N).
*          The leading dimension of B.  LDB >= max(1,N).
*
*
*  ALPHAR  (output) DOUBLE PRECISION array, dimension (N)
*  ALPHAR  (output) DOUBLE PRECISION array, dimension (N)
*          The real parts of each scalar alpha defining an eigenvalue
*          of GNEP.
*
*  ALPHAI  (output) DOUBLE PRECISION array, dimension (N)
*  ALPHAI  (output) DOUBLE PRECISION array, dimension (N)
*  BETA    (output) DOUBLE PRECISION array, dimension (N)
*          The imaginary parts of each scalar alpha defining an
*          On exit, (ALPHAR(j) + ALPHAI(j)*i)/BETA(j), j=1,...,N, will
*          eigenvalue of GNEP.  If ALPHAI(j) is zero, then the j-th
*          be the generalized eigenvalues.  ALPHAR(j) + ALPHAI(j)*i,
*          j=1,...,N  and  BETA(j),j=1,...,N  are the diagonals of the
*          complex Schur form (A,B) that would result if the 2-by-2
*          diagonal blocks of the real Schur form of (A,B) were further
*          reduced to triangular form using 2-by-2 complex unitary
*          transformations.  If ALPHAI(j) is zero, then the j-th
*          eigenvalue is real; if positive, then the j-th and (j+1)-st
*          eigenvalue is real; if positive, then the j-th and (j+1)-st
*          eigenvalues are a complex conjugate pair, with ALPHAI(j+1)
*          eigenvalues are a complex conjugate pair, with
*          negative.
*          ALPHAI(j+1) = -ALPHAI(j).
*
*
*          Note: the quotients ALPHAR(j)/BETA(j) and ALPHAI(j)/BETA(j)
*  BETA    (output) DOUBLE PRECISION array, dimension (N)
*          may easily over- or underflow, and BETA(j) may even be zero.
*          The scalars beta that define the eigenvalues of GNEP.
*          Thus, the user should avoid naively computing the ratio
*          Together, the quantities alpha = (ALPHAR(j),ALPHAI(j)) and
*          alpha/beta.  However, ALPHAR and ALPHAI will be always less
*          beta = BETA(j) represent the j-th eigenvalue of the matrix
*          than and usually comparable with norm(A) in magnitude, and
*          pair (A,B), in one of the forms lambda = alpha/beta or
*          BETA always less than and usually comparable with norm(B).
*          mu = beta/alpha.  Since either lambda or mu may overflow,
*          they should not, in general, be computed.
*
*
*  VSL     (output) DOUBLE PRECISION array, dimension (LDVSL,N)
*  VSL     (output) DOUBLE PRECISION array, dimension (LDVSL,N)
*          If JOBVSL = 'V', VSL will contain the left Schur vectors.
*          If JOBVSL = 'V', the matrix of left Schur vectors Q.
*          (See "Purpose", above.)
*          Not referenced if JOBVSL = 'N'.
*          Not referenced if JOBVSL = 'N'.
*
*
*  LDVSL   (input) INTEGER
*  LDVSL   (input) INTEGER
 Lines 128-135    Link Here 
*          if JOBVSL = 'V', LDVSL >= N.
*          if JOBVSL = 'V', LDVSL >= N.
*
*
*  VSR     (output) DOUBLE PRECISION array, dimension (LDVSR,N)
*  VSR     (output) DOUBLE PRECISION array, dimension (LDVSR,N)
*          If JOBVSR = 'V', VSR will contain the right Schur vectors.
*          If JOBVSR = 'V', the matrix of right Schur vectors Z.
*          (See "Purpose", above.)
*          Not referenced if JOBVSR = 'N'.
*          Not referenced if JOBVSR = 'N'.
*
*
*  LDVSR   (input) INTEGER
*  LDVSR   (input) INTEGER
(-) LAPACK/SRC/dgegv.f (-61 / +86 lines)
 Lines 4-10    Link Here 
*  -- LAPACK driver routine (version 3.0) --
*  -- LAPACK driver routine (version 3.0) --
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Courant Institute, Argonne National Lab, and Rice University
*     Courant Institute, Argonne National Lab, and Rice University
*     June 30, 1999
*     April 26, 2001
*
*
*     .. Scalar Arguments ..
*     .. Scalar Arguments ..
      CHARACTER          JOBVL, JOBVR
      CHARACTER          JOBVL, JOBVR
 Lines 21-43    Link Here 
*
*
*  This routine is deprecated and has been replaced by routine DGGEV.
*  This routine is deprecated and has been replaced by routine DGGEV.
*
*
*  DGEGV computes for a pair of n-by-n real nonsymmetric matrices A and
*  DGEGV computes the eigenvalues and, optionally, the left and/or right
*  B, the generalized eigenvalues (alphar +/- alphai*i, beta), and
*  eigenvectors of a real matrix pair (A,B).
*  optionally, the left and/or right generalized eigenvectors (VL and
*  Given two square matrices A and B,
*  VR).
*  the generalized nonsymmetric eigenvalue problem (GNEP) is to find the
*
*  eigenvalues lambda and corresponding (non-zero) eigenvectors x such
*  A generalized eigenvalue for a pair of matrices (A,B) is, roughly
*  that
*  speaking, a scalar w or a ratio  alpha/beta = w, such that  A - w*B
*
*  is singular.  It is usually represented as the pair (alpha,beta),
*     A*x = lambda*B*x.
*  as there is a reasonable interpretation for beta=0, and even for
*
*  both being zero.  A good beginning reference is the book, "Matrix
*  An alternate form is to find the eigenvalues mu and corresponding
*  Computations", by G. Golub & C. van Loan (Johns Hopkins U. Press)
*  eigenvectors y such that
*
*
*  A right generalized eigenvector corresponding to a generalized
*     mu*A*y = B*y.
*  eigenvalue  w  for a pair of matrices (A,B) is a vector  r  such
*
*  that  (A - w B) r = 0 .  A left generalized eigenvector is a vector
*  These two forms are equivalent with mu = 1/lambda and x = y if
*  l such that l**H * (A - w B) = 0, where l**H is the
*  neither lambda nor mu is zero.  In order to deal with the case that
*  conjugate-transpose of l.
*  lambda or mu is zero or small, two values alpha and beta are returned
*  for each eigenvalue, such that lambda = alpha/beta and
*  mu = beta/alpha.
*
*  The vectors x and y in the above equations are right eigenvectors of
*  the matrix pair (A,B).  Vectors u and v satisfying
*
*     u**H*A = lambda*u**H*B  or  mu*v**H*A = v**H*B
*
*  are left eigenvectors of (A,B).
*
*
*  Note: this routine performs "full balancing" on A and B -- see
*  Note: this routine performs "full balancing" on A and B -- see
*  "Further Details", below.
*  "Further Details", below.
 Lines 47-109    Link Here 
*
*
*  JOBVL   (input) CHARACTER*1
*  JOBVL   (input) CHARACTER*1
*          = 'N':  do not compute the left generalized eigenvectors;
*          = 'N':  do not compute the left generalized eigenvectors;
*          = 'V':  compute the left generalized eigenvectors.
*          = 'V':  compute the left generalized eigenvectors (returned
*                  in VL).
*
*
*  JOBVR   (input) CHARACTER*1
*  JOBVR   (input) CHARACTER*1
*          = 'N':  do not compute the right generalized eigenvectors;
*          = 'N':  do not compute the right generalized eigenvectors;
*          = 'V':  compute the right generalized eigenvectors.
*          = 'V':  compute the right generalized eigenvectors (returned
*                  in VR).
*
*
*  N       (input) INTEGER
*  N       (input) INTEGER
*          The order of the matrices A, B, VL, and VR.  N >= 0.
*          The order of the matrices A, B, VL, and VR.  N >= 0.
*
*
*  A       (input/output) DOUBLE PRECISION array, dimension (LDA, N)
*  A       (input/output) DOUBLE PRECISION array, dimension (LDA, N)
*          On entry, the first of the pair of matrices whose
*          On entry, the matrix A.
*          generalized eigenvalues and (optionally) generalized
*          If JOBVL = 'V' or JOBVR = 'V', then on exit A
*          eigenvectors are to be computed.
*          contains the real Schur form of A from the generalized Schur
*          On exit, the contents will have been destroyed.  (For a
*          factorization of the pair (A,B) after balancing.
*          description of the contents of A on exit, see "Further
*          If no eigenvectors were computed, then only the diagonal
*          Details", below.)
*          blocks from the Schur form will be correct.  See DGGHRD and
*          DHGEQZ for details.
*
*
*  LDA     (input) INTEGER
*  LDA     (input) INTEGER
*          The leading dimension of A.  LDA >= max(1,N).
*          The leading dimension of A.  LDA >= max(1,N).
*
*
*  B       (input/output) DOUBLE PRECISION array, dimension (LDB, N)
*  B       (input/output) DOUBLE PRECISION array, dimension (LDB, N)
*          On entry, the second of the pair of matrices whose
*          On entry, the matrix B.
*          generalized eigenvalues and (optionally) generalized
*          If JOBVL = 'V' or JOBVR = 'V', then on exit B contains the
*          eigenvectors are to be computed.
*          upper triangular matrix obtained from B in the generalized
*          On exit, the contents will have been destroyed.  (For a
*          Schur factorization of the pair (A,B) after balancing.
*          description of the contents of B on exit, see "Further
*          If no eigenvectors were computed, then only those elements of
*          Details", below.)
*          B corresponding to the diagonal blocks from the Schur form of
*          A will be correct.  See DGGHRD and DHGEQZ for details.
*
*
*  LDB     (input) INTEGER
*  LDB     (input) INTEGER
*          The leading dimension of B.  LDB >= max(1,N).
*          The leading dimension of B.  LDB >= max(1,N).
*
*
*  ALPHAR  (output) DOUBLE PRECISION array, dimension (N)
*  ALPHAR  (output) DOUBLE PRECISION array, dimension (N)
*          The real parts of each scalar alpha defining an eigenvalue of
*          GNEP.
*
*  ALPHAI  (output) DOUBLE PRECISION array, dimension (N)
*  ALPHAI  (output) DOUBLE PRECISION array, dimension (N)
*  BETA    (output) DOUBLE PRECISION array, dimension (N)
*          The imaginary parts of each scalar alpha defining an
*          On exit, (ALPHAR(j) + ALPHAI(j)*i)/BETA(j), j=1,...,N, will
*          eigenvalue of GNEP.  If ALPHAI(j) is zero, then the j-th
*          be the generalized eigenvalues.  If ALPHAI(j) is zero, then
*          eigenvalue is real; if positive, then the j-th and
*          the j-th eigenvalue is real; if positive, then the j-th and
*          (j+1)-st eigenvalues are a complex conjugate pair, with
*          (j+1)-st eigenvalues are a complex conjugate pair, with
*          ALPHAI(j+1) negative.
*          ALPHAI(j+1) = -ALPHAI(j).
*
*
*          Note: the quotients ALPHAR(j)/BETA(j) and ALPHAI(j)/BETA(j)
*  BETA    (output) DOUBLE PRECISION array, dimension (N)
*          may easily over- or underflow, and BETA(j) may even be zero.
*          The scalars beta that define the eigenvalues of GNEP.
*          Thus, the user should avoid naively computing the ratio
*          
*          alpha/beta.  However, ALPHAR and ALPHAI will be always less
*          Together, the quantities alpha = (ALPHAR(j),ALPHAI(j)) and
*          than and usually comparable with norm(A) in magnitude, and
*          beta = BETA(j) represent the j-th eigenvalue of the matrix
*          BETA always less than and usually comparable with norm(B).
*          pair (A,B), in one of the forms lambda = alpha/beta or
*          mu = beta/alpha.  Since either lambda or mu may overflow,
*          they should not, in general, be computed.
*
*
*  VL      (output) DOUBLE PRECISION array, dimension (LDVL,N)
*  VL      (output) DOUBLE PRECISION array, dimension (LDVL,N)
*          If JOBVL = 'V', the left generalized eigenvectors.  (See
*          If JOBVL = 'V', the left eigenvectors u(j) are stored
*          "Purpose", above.)  Real eigenvectors take one column,
*          in the columns of VL, in the same order as their eigenvalues.
*          complex take two columns, the first for the real part and
*          If the j-th eigenvalue is real, then u(j) = VL(:,j).
*          the second for the imaginary part.  Complex eigenvectors
*          If the j-th and (j+1)-st eigenvalues form a complex conjugate
*          correspond to an eigenvalue with positive imaginary part.
*          pair, then
*          Each eigenvector will be scaled so the largest component
*             u(j) = VL(:,j) + i*VL(:,j+1)
*          will have abs(real part) + abs(imag. part) = 1, *except*
*          and
*          that for eigenvalues with alpha=beta=0, a zero vector will
*            u(j+1) = VL(:,j) - i*VL(:,j+1).
*          be returned as the corresponding eigenvector.
*
*          Each eigenvector is scaled so that its largest component has
*          abs(real part) + abs(imag. part) = 1, except for eigenvectors
*          corresponding to an eigenvalue with alpha = beta = 0, which
*          are set to zero.
*          Not referenced if JOBVL = 'N'.
*          Not referenced if JOBVL = 'N'.
*
*
*  LDVL    (input) INTEGER
*  LDVL    (input) INTEGER
 Lines 111-125    Link Here 
*          if JOBVL = 'V', LDVL >= N.
*          if JOBVL = 'V', LDVL >= N.
*
*
*  VR      (output) DOUBLE PRECISION array, dimension (LDVR,N)
*  VR      (output) DOUBLE PRECISION array, dimension (LDVR,N)
*          If JOBVR = 'V', the right generalized eigenvectors.  (See
*          If JOBVR = 'V', the right eigenvectors x(j) are stored
*          "Purpose", above.)  Real eigenvectors take one column,
*          in the columns of VR, in the same order as their eigenvalues.
*          complex take two columns, the first for the real part and
*          If the j-th eigenvalue is real, then x(j) = VR(:,j).
*          the second for the imaginary part.  Complex eigenvectors
*          If the j-th and (j+1)-st eigenvalues form a complex conjugate
*          correspond to an eigenvalue with positive imaginary part.
*          pair, then
*          Each eigenvector will be scaled so the largest component
*            x(j) = VR(:,j) + i*VR(:,j+1)
*          will have abs(real part) + abs(imag. part) = 1, *except*
*          and
*          that for eigenvalues with alpha=beta=0, a zero vector will
*            x(j+1) = VR(:,j) - i*VR(:,j+1).
*          be returned as the corresponding eigenvector.
*
*          Each eigenvector is scaled so that its largest component has
*          abs(real part) + abs(imag. part) = 1, except for eigenvalues
*          corresponding to an eigenvalue with alpha = beta = 0, which
*          are set to zero.
*          Not referenced if JOBVR = 'N'.
*          Not referenced if JOBVR = 'N'.
*
*
*  LDVR    (input) INTEGER
*  LDVR    (input) INTEGER
(-) LAPACK/SRC/dgelsd.f (-34 / +33 lines)
 Lines 4-10    Link Here 
*  -- LAPACK driver routine (version 3.0) --
*  -- LAPACK driver routine (version 3.0) --
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Courant Institute, Argonne National Lab, and Rice University
*     Courant Institute, Argonne National Lab, and Rice University
*     October 31, 1999
*     June 30, 1999
*     8-15-00:  Improve consistency of WS calculations (eca)
*
*
*     .. Scalar Arguments ..
*     .. Scalar Arguments ..
      INTEGER            INFO, LDA, LDB, LWORK, M, N, NRHS, RANK
      INTEGER            INFO, LDA, LDB, LWORK, M, N, NRHS, RANK
 Lines 61-69    Link Here 
*          The number of right hand sides, i.e., the number of columns
*          The number of right hand sides, i.e., the number of columns
*          of the matrices B and X. NRHS >= 0.
*          of the matrices B and X. NRHS >= 0.
*
*
*  A       (input) DOUBLE PRECISION array, dimension (LDA,N)
*  A       (input/output) DOUBLE PRECISION array, dimension (LDA,N)
*          On entry, the M-by-N matrix A.
*          On entry, the M-by-N matrix A.
*          On exit, A has been destroyed.
*          On exit, the first min(m,n) rows of A are overwritten with
*          its right singular vectors, stored rowwise.
*
*
*  LDA     (input) INTEGER
*  LDA     (input) INTEGER
*          The leading dimension of the array A.  LDA >= max(1,M).
*          The leading dimension of the array A.  LDA >= max(1,M).
 Lines 95-117    Link Here 
*          On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
*          On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
*
*
*  LWORK   (input) INTEGER
*  LWORK   (input) INTEGER
*          The dimension of the array WORK. LWORK must be at least 1.
*          The dimension of the array WORK. LWORK >= 1.
*          The exact minimum amount of workspace needed depends on M,
*          The exact minimum amount of workspace needed depends on M,
*          N and NRHS. As long as LWORK is at least
*          N and NRHS.
*              12*N + 2*N*SMLSIZ + 8*N*NLVL + N*NRHS + (SMLSIZ+1)**2,
*          If M >= N, LWORK >=  11*N + 2*N*SMLSIZ + 8*N*NLVL + N*NRHS.
*          if M is greater than or equal to N or
*          If M < N, LWORK >=  11*M + 2*M*SMLSIZ + 8*M*NLVL + M*NRHS.
*              12*M + 2*M*SMLSIZ + 8*M*NLVL + M*NRHS + (SMLSIZ+1)**2,
*          if M is less than N, the code will execute correctly.
*          SMLSIZ is returned by ILAENV and is equal to the maximum
*          SMLSIZ is returned by ILAENV and is equal to the maximum
*          size of the subproblems at the bottom of the computation
*          size of the subproblems at the bottom of the computation
*          tree (usually about 25), and
*          tree (usually about 25), and
*             NLVL = MAX( 0, INT( LOG_2( MIN( M,N )/(SMLSIZ+1) ) ) + 1 )
*              NLVL = INT( LOG_2( MIN( M,N )/(SMLSIZ+1) ) ) + 1
*          For good performance, LWORK should generally be larger.
*          For good performance, LWORK should generally be larger.
*
*
*          If LWORK = -1, then a workspace query is assumed; the routine
*          If LWORK = -1, a workspace query is assumed.  The optimal
*          only calculates the optimal size of the WORK array, returns
*          size for the WORK array is calculated and stored in WORK(1),
*          this value as the first entry of the WORK array, and no error
*          and no other work except argument checking is performed.
*          message related to LWORK is issued by XERBLA.
*
*
*  IWORK   (workspace) INTEGER array, dimension (LIWORK)
*  IWORK   (workspace) INTEGER array, dimension (LIWORK)
*          LIWORK >= 3 * MINMN * NLVL + 11 * MINMN,
*          LIWORK >= 3 * MINMN * NLVL + 11 * MINMN,
 Lines 135-148    Link Here 
*  =====================================================================
*  =====================================================================
*
*
*     .. Parameters ..
*     .. Parameters ..
      INTEGER            LQUERV
      PARAMETER          ( LQUERV = -1 )
      DOUBLE PRECISION   ZERO, ONE, TWO
      DOUBLE PRECISION   ZERO, ONE, TWO
      PARAMETER          ( ZERO = 0.0D0, ONE = 1.0D0, TWO = 2.0D0 )
      PARAMETER          ( ZERO = 0.0D0, ONE = 1.0D0, TWO = 2.0D0 )
*     ..
*     ..
*     .. Local Scalars ..
*     .. Local Scalars ..
      LOGICAL            LQUERY
      INTEGER            IASCL, IBSCL, IE, IL, ITAU, ITAUP, ITAUQ,
      INTEGER            IASCL, IBSCL, IE, IL, ITAU, ITAUP, ITAUQ,
     $                   LDWORK, MAXMN, MAXWRK, MINMN, MINWRK, MM,
     $                   LDWORK, MAXMN, MAXWRK, MINMN, MINWRK, MM,
     $                   MNTHR, NLVL, NWORK, SMLSIZ, WLALSD
     $                   MNTHR, NLVL, NWORK, SMLSIZ
      DOUBLE PRECISION   ANRM, BIGNUM, BNRM, EPS, SFMIN, SMLNUM
      DOUBLE PRECISION   ANRM, BIGNUM, BNRM, EPS, SFMIN, SMLNUM
*     ..
*     ..
*     .. External Subroutines ..
*     .. External Subroutines ..
 Lines 165-171    Link Here 
      MINMN = MIN( M, N )
      MINMN = MIN( M, N )
      MAXMN = MAX( M, N )
      MAXMN = MAX( M, N )
      MNTHR = ILAENV( 6, 'DGELSD', ' ', M, N, NRHS, -1 )
      MNTHR = ILAENV( 6, 'DGELSD', ' ', M, N, NRHS, -1 )
      LQUERY = ( LWORK.EQ.-1 )
      IF( M.LT.0 ) THEN
      IF( M.LT.0 ) THEN
         INFO = -1
         INFO = -1
      ELSE IF( N.LT.0 ) THEN
      ELSE IF( N.LT.0 ) THEN
 Lines 189-196    Link Here 
*
*
      MINWRK = 1
      MINWRK = 1
      MINMN = MAX( 1, MINMN )
      MINMN = MAX( 1, MINMN )
      NLVL = MAX( INT( LOG( DBLE( MINMN ) / DBLE( SMLSIZ+1 ) ) /
      NLVL = INT( LOG( DBLE( MINMN ) / DBLE( SMLSIZ+1 ) ) / LOG( TWO ) )
     $       LOG( TWO ) ) + 1, 0 )
     $        + 1
*
*
      IF( INFO.EQ.0 ) THEN
      IF( INFO.EQ.0 ) THEN
         MAXWRK = 0
         MAXWRK = 0
 Lines 215-226    Link Here 
     $               ILAENV( 1, 'DORMBR', 'QLT', MM, NRHS, N, -1 ) )
     $               ILAENV( 1, 'DORMBR', 'QLT', MM, NRHS, N, -1 ) )
            MAXWRK = MAX( MAXWRK, 3*N+( N-1 )*
            MAXWRK = MAX( MAXWRK, 3*N+( N-1 )*
     $               ILAENV( 1, 'DORMBR', 'PLN', N, NRHS, N, -1 ) )
     $               ILAENV( 1, 'DORMBR', 'PLN', N, NRHS, N, -1 ) )
            WLALSD = 9*N+2*N*SMLSIZ+8*N*NLVL+N*NRHS+(SMLSIZ+1)**2
            MAXWRK = MAX( MAXWRK, 3*N+8*N+2*N*SMLSIZ+8*N*NLVL+N*NRHS )
            MAXWRK = MAX( MAXWRK, 3*N+WLALSD )
            MINWRK = MAX( 3*N+MM, 3*N+NRHS,
            MINWRK = MAX( 3*N+MM, 3*N+NRHS, 3*N+WLALSD )
     $               3*N+8*N+2*N*SMLSIZ+8*N*NLVL+N*NRHS )
         END IF
         END IF
         IF( N.GT.M ) THEN
         IF( N.GT.M ) THEN
            WLALSD = 9*M+2*M*SMLSIZ+8*M*NLVL+M*NRHS+(SMLSIZ+1)**2
            IF( N.GE.MNTHR ) THEN
            IF( N.GE.MNTHR ) THEN
*
*
*              Path 2a - underdetermined, with many more columns
*              Path 2a - underdetermined, with many more columns
 Lines 240-246    Link Here 
               END IF
               END IF
               MAXWRK = MAX( MAXWRK, M+NRHS*
               MAXWRK = MAX( MAXWRK, M+NRHS*
     $                  ILAENV( 1, 'DORMLQ', 'LT', N, NRHS, M, -1 ) )
     $                  ILAENV( 1, 'DORMLQ', 'LT', N, NRHS, M, -1 ) )
               MAXWRK = MAX( MAXWRK, M*M+4*M+WLALSD )
               MAXWRK = MAX( MAXWRK, M*M+4*M+8*M+2*M*SMLSIZ+8*M*NLVL+M*
     $                  NRHS )
            ELSE
            ELSE
*
*
*              Path 2 - remaining underdetermined cases.
*              Path 2 - remaining underdetermined cases.
 Lines 251-276    Link Here 
     $                  ILAENV( 1, 'DORMBR', 'QLT', M, NRHS, N, -1 ) )
     $                  ILAENV( 1, 'DORMBR', 'QLT', M, NRHS, N, -1 ) )
               MAXWRK = MAX( MAXWRK, 3*M+M*
               MAXWRK = MAX( MAXWRK, 3*M+M*
     $                  ILAENV( 1, 'DORMBR', 'PLN', N, NRHS, M, -1 ) )
     $                  ILAENV( 1, 'DORMBR', 'PLN', N, NRHS, M, -1 ) )
               MAXWRK = MAX( MAXWRK, 3*M+WLALSD )
               MAXWRK = MAX( MAXWRK, 3*M+8*M+2*M*SMLSIZ+8*M*NLVL+M*
     $                  NRHS )
            END IF
            END IF
            MINWRK = MAX( 3*M+NRHS, 3*M+M, 3*M+WLALSD )
            MINWRK = MAX( 3*M+NRHS, 3*M+M,
     $               3*M+8*M+2*M*SMLSIZ+8*M*NLVL+M*NRHS )
         END IF
         END IF
         MINWRK = MIN( MINWRK, MAXWRK )
         MINWRK = MIN( MINWRK, MAXWRK )
         WORK( 1 ) = MAXWRK
         WORK( 1 ) = MAXWRK
         IF( LWORK.LT.MINWRK .AND. .NOT.LQUERY ) THEN
         IF( LWORK.LT.MINWRK .AND. LWORK.NE.LQUERV )
            INFO = -12
     $      INFO = -12
         END IF
      END IF
      END IF
*
*
*     Quick returns
*
      IF( INFO.NE.0 ) THEN
      IF( INFO.NE.0 ) THEN
         CALL XERBLA( 'DGELSD', -INFO )
         CALL XERBLA( 'DGELSD', -INFO )
         RETURN
         RETURN
      ELSE IF( LQUERY ) THEN
         GO TO 10
      END IF
      END IF
*
      IF( LWORK.EQ.LQUERV )
*     Quick return if possible.
     $   RETURN
*
      IF( M.EQ.0 .OR. N.EQ.0 ) THEN
      IF( M.EQ.0 .OR. N.EQ.0 ) THEN
         RANK = 0
         RANK = 0
         RETURN
         RETURN
(-) LAPACK/SRC/dgelss.f (-14 / +11 lines)
 Lines 4-10    Link Here 
*  -- LAPACK driver routine (version 3.0) --
*  -- LAPACK driver routine (version 3.0) --
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Courant Institute, Argonne National Lab, and Rice University
*     Courant Institute, Argonne National Lab, and Rice University
*     October 31, 1999
*     April 25, 2001 
*
*
*     .. Scalar Arguments ..
*     .. Scalar Arguments ..
      INTEGER            INFO, LDA, LDB, LWORK, M, N, NRHS, RANK
      INTEGER            INFO, LDA, LDB, LWORK, M, N, NRHS, RANK
 Lines 86-95    Link Here 
*          LWORK >= 3*min(M,N) + max( 2*min(M,N), max(M,N), NRHS )
*          LWORK >= 3*min(M,N) + max( 2*min(M,N), max(M,N), NRHS )
*          For good performance, LWORK should generally be larger.
*          For good performance, LWORK should generally be larger.
*
*
*          If LWORK = -1, then a workspace query is assumed; the routine
*          If LWORK = -1, a workspace query is assumed.  The optimal
*          only calculates the optimal size of the WORK array, returns
*          size for the WORK array is calculated and stored in WORK(1),
*          this value as the first entry of the WORK array, and no error
*          and no other work except argument checking is performed.
*          message related to LWORK is issued by XERBLA.
*
*
*  INFO    (output) INTEGER
*  INFO    (output) INTEGER
*          = 0:  successful exit
*          = 0:  successful exit
 Lines 156-162    Link Here 
*       following subroutine, as returned by ILAENV.)
*       following subroutine, as returned by ILAENV.)
*
*
      MINWRK = 1
      MINWRK = 1
      IF( INFO.EQ.0 .AND. ( LWORK.GE.1 .OR. LQUERY ) ) THEN
      IF( INFO.EQ.0 ) THEN
         MAXWRK = 0
         MAXWRK = 0
         MM = M
         MM = M
         IF( M.GE.N .AND. M.GE.MNTHR ) THEN
         IF( M.GE.N .AND. M.GE.MNTHR ) THEN
 Lines 229-248    Link Here 
         END IF
         END IF
         MAXWRK = MAX( MINWRK, MAXWRK )
         MAXWRK = MAX( MINWRK, MAXWRK )
         WORK( 1 ) = MAXWRK
         WORK( 1 ) = MAXWRK
         IF( LWORK.LT.MINWRK .AND. .NOT.LQUERY )
     $      INFO = -12
      END IF
      END IF
*
*
      MINWRK = MAX( MINWRK, 1 )
*     Quick returns
      IF( LWORK.LT.MINWRK .AND. .NOT.LQUERY )
*
     $   INFO = -12
      IF( INFO.NE.0 ) THEN
      IF( INFO.NE.0 ) THEN
         CALL XERBLA( 'DGELSS', -INFO )
         CALL XERBLA( 'DGELSS', -INFO )
         RETURN
         RETURN
      ELSE IF( LQUERY ) THEN
      ELSE IF( LQUERY ) THEN
         RETURN
         RETURN
      END IF
      END IF
*
*     Quick return if possible
*
      IF( M.EQ.0 .OR. N.EQ.0 ) THEN
      IF( M.EQ.0 .OR. N.EQ.0 ) THEN
         RANK = 0
         RANK = 0
         RETURN
         RETURN
 Lines 491-498    Link Here 
            DO 40 I = 1, NRHS, CHUNK
            DO 40 I = 1, NRHS, CHUNK
               BL = MIN( NRHS-I+1, CHUNK )
               BL = MIN( NRHS-I+1, CHUNK )
               CALL DGEMM( 'T', 'N', M, BL, M, ONE, WORK( IL ), LDWORK,
               CALL DGEMM( 'T', 'N', M, BL, M, ONE, WORK( IL ), LDWORK,
     $                     B( 1, I ), LDB, ZERO, WORK( IWORK ), N )
     $                     B( 1, I ), LDB, ZERO, WORK( IWORK ), M )
               CALL DLACPY( 'G', M, BL, WORK( IWORK ), N, B( 1, I ),
               CALL DLACPY( 'G', M, BL, WORK( IWORK ), M, B( 1, I ),
     $                      LDB )
     $                      LDB )
   40       CONTINUE
   40       CONTINUE
         ELSE
         ELSE
(-) LAPACK/SRC/dgesdd.f (-121 / +121 lines)
 Lines 4-10    Link Here 
*  -- LAPACK driver routine (version 3.0) --
*  -- LAPACK driver routine (version 3.0) --
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Courant Institute, Argonne National Lab, and Rice University
*     Courant Institute, Argonne National Lab, and Rice University
*     October 31, 1999
*     June 30, 1999
*     8-15-00:  Improve consistency of WS calculations (eca)
*
*
*     .. Scalar Arguments ..
*     .. Scalar Arguments ..
      CHARACTER          JOBZ
      CHARACTER          JOBZ
 Lines 116-131    Link Here 
*  LWORK   (input) INTEGER
*  LWORK   (input) INTEGER
*          The dimension of the array WORK. LWORK >= 1.
*          The dimension of the array WORK. LWORK >= 1.
*          If JOBZ = 'N',
*          If JOBZ = 'N',
*            LWORK >= 3*min(M,N) + max(max(M,N),6*min(M,N)).
*            LWORK >= max(14*min(M,N)+4, 10*min(M,N)+2+
*                     SMLSIZ*(SMLSIZ+8)) + max(M,N)
*          where SMLSIZ is returned by ILAENV and is equal to the
*          maximum size of the subproblems at the bottom of the
*          computation tree (usually about 25).
*          If JOBZ = 'O',
*          If JOBZ = 'O',
*            LWORK >= 3*min(M,N)*min(M,N) + 
*            LWORK >= 5*min(M,N)*min(M,N) + max(M,N) + 9*min(M,N).
*                     max(max(M,N),5*min(M,N)*min(M,N)+4*min(M,N)).
*          If JOBZ = 'S' or 'A'
*          If JOBZ = 'S' or 'A'
*            LWORK >= 3*min(M,N)*min(M,N) +
*            LWORK >= 4*min(M,N)*min(M,N) + max(M,N) + 9*min(M,N).
*                     max(max(M,N),4*min(M,N)*min(M,N)+4*min(M,N)).
*          For good performance, LWORK should generally be larger.
*          For good performance, LWORK should generally be larger.
*          If LWORK < 0 but other input arguments are legal, WORK(1)
*
*          returns the optimal LWORK.
*          If LWORK = -1, a workspace query is assumed.  The optimal
*          size for the WORK array is calculated and stored in WORK(1),
*          and no other work except argument checking is performed.
*
*
*  IWORK   (workspace) INTEGER array, dimension (8*min(M,N))
*  IWORK   (workspace) INTEGER array, dimension (8*min(M,N))
*
*
 Lines 144-158    Link Here 
*  =====================================================================
*  =====================================================================
*
*
*     .. Parameters ..
*     .. Parameters ..
      INTEGER            LQUERV
      PARAMETER          ( LQUERV = -1 )
      DOUBLE PRECISION   ZERO, ONE
      DOUBLE PRECISION   ZERO, ONE
      PARAMETER          ( ZERO = 0.0D0, ONE = 1.0D0 )
      PARAMETER          ( ZERO = 0.0D+0, ONE = 1.0D+0 )
*     ..
*     ..
*     .. Local Scalars ..
*     .. Local Scalars ..
      LOGICAL            LQUERY, WNTQA, WNTQAS, WNTQN, WNTQO, WNTQS
      LOGICAL            WNTQA, WNTQAS, WNTQN, WNTQO, WNTQS
      INTEGER            BDSPAC, BLK, CHUNK, I, IE, IERR, IL,
      INTEGER            BDSPAC, BDSPAN, BLK, CHUNK, I, IE, IERR, IL,
     $                   IR, ISCL, ITAU, ITAUP, ITAUQ, IU, IVT, LDWKVT,
     $                   IR, ISCL, ITAU, ITAUP, ITAUQ, IU, IVT, LDWKVT,
     $                   LDWRKL, LDWRKR, LDWRKU, MAXWRK, MINMN, MINWRK,
     $                   LDWRKL, LDWRKR, LDWRKU, MAXWRK, MINMN, MINWRK,
     $                   MNTHR, NWORK, WRKBL
     $                   MNTHR, NWORK, SMLSIZ, WRKBL
      DOUBLE PRECISION   ANRM, BIGNUM, EPS, SMLNUM
      DOUBLE PRECISION   ANRM, BIGNUM, EPS, SMLNUM
*     ..
*     ..
*     .. Local Arrays ..
*     .. Local Arrays ..
 Lines 168-174    Link Here 
      LOGICAL            LSAME
      LOGICAL            LSAME
      INTEGER            ILAENV
      INTEGER            ILAENV
      DOUBLE PRECISION   DLAMCH, DLANGE
      DOUBLE PRECISION   DLAMCH, DLANGE
      EXTERNAL           DLAMCH, DLANGE, ILAENV, LSAME
      EXTERNAL           LSAME, ILAENV, DLAMCH, DLANGE
*     ..
*     ..
*     .. Intrinsic Functions ..
*     .. Intrinsic Functions ..
      INTRINSIC          DBLE, INT, MAX, MIN, SQRT
      INTRINSIC          DBLE, INT, MAX, MIN, SQRT
 Lines 187-193    Link Here 
      WNTQN = LSAME( JOBZ, 'N' )
      WNTQN = LSAME( JOBZ, 'N' )
      MINWRK = 1
      MINWRK = 1
      MAXWRK = 1
      MAXWRK = 1
      LQUERY = ( LWORK.EQ.-1 )
*
*
      IF( .NOT.( WNTQA .OR. WNTQS .OR. WNTQO .OR. WNTQN ) ) THEN
      IF( .NOT.( WNTQA .OR. WNTQS .OR. WNTQO .OR. WNTQN ) ) THEN
         INFO = -1
         INFO = -1
 Lines 206-211    Link Here 
         INFO = -10
         INFO = -10
      END IF
      END IF
*
*
      SMLSIZ = ILAENV( 9, 'DGESDD', ' ', 0, 0, 0, 0 )
*
*     Compute workspace
*     Compute workspace
*      (Note: Comments in the code beginning "Workspace:" describe the
*      (Note: Comments in the code beginning "Workspace:" describe the
*       minimal amount of workspace needed at that point in the code,
*       minimal amount of workspace needed at that point in the code,
 Lines 218-239    Link Here 
*
*
*           Compute space needed for DBDSDC
*           Compute space needed for DBDSDC
*
*
            IF( WNTQN ) THEN
            BDSPAC = 3*N*N + 7*N
               BDSPAC = 7*N
            BDSPAN = MAX( 12*N+4, 8*N+2+SMLSIZ*( SMLSIZ+8 ) )
            ELSE
               BDSPAC = 3*N*N + 4*N
            END IF
            IF( M.GE.MNTHR ) THEN
            IF( M.GE.MNTHR ) THEN
               IF( WNTQN ) THEN
               IF( WNTQN ) THEN
*
*
*                 Path 1 (M much larger than N, JOBZ='N')
*                 Path 1 (M much larger than N, JOBZ='N')
*
*
                  WRKBL = N + N*ILAENV( 1, 'DGEQRF', ' ', M, N, -1,
                  MAXWRK = N + N*ILAENV( 1, 'DGEQRF', ' ', M, N, -1,
     $                    -1 )
     $                     -1 )
                  WRKBL = MAX( WRKBL, 3*N+2*N*
                  MAXWRK = MAX( MAXWRK, 3*N+2*N*
     $                    ILAENV( 1, 'DGEBRD', ' ', N, N, -1, -1 ) )
     $                     ILAENV( 1, 'DGEBRD', ' ', N, N, -1, -1 ) )
                  MAXWRK = MAX( WRKBL, BDSPAC+N )
                  MAXWRK = MAX( MAXWRK, BDSPAC )
                  MINWRK = BDSPAC + N
                  MINWRK = BDSPAC
               ELSE IF( WNTQO ) THEN
               ELSE IF( WNTQO ) THEN
*
*
*                 Path 2 (M much larger than N, JOBZ='O')
*                 Path 2 (M much larger than N, JOBZ='O')
 Lines 247-255    Link Here 
     $                    ILAENV( 1, 'DORMBR', 'QLN', N, N, N, -1 ) )
     $                    ILAENV( 1, 'DORMBR', 'QLN', N, N, N, -1 ) )
                  WRKBL = MAX( WRKBL, 3*N+N*
                  WRKBL = MAX( WRKBL, 3*N+N*
     $                    ILAENV( 1, 'DORMBR', 'PRT', N, N, N, -1 ) )
     $                    ILAENV( 1, 'DORMBR', 'PRT', N, N, N, -1 ) )
                  WRKBL = MAX( WRKBL, BDSPAC+3*N )
                  WRKBL = MAX( WRKBL, BDSPAC+2*N )
                  MAXWRK = WRKBL + 2*N*N
                  MAXWRK = WRKBL + 2*N*N
                  MINWRK = BDSPAC + 2*N*N + 3*N
                  MINWRK = BDSPAC + 2*N*N + 2*N
               ELSE IF( WNTQS ) THEN
               ELSE IF( WNTQS ) THEN
*
*
*                 Path 3 (M much larger than N, JOBZ='S')
*                 Path 3 (M much larger than N, JOBZ='S')
 Lines 263-271    Link Here 
     $                    ILAENV( 1, 'DORMBR', 'QLN', N, N, N, -1 ) )
     $                    ILAENV( 1, 'DORMBR', 'QLN', N, N, N, -1 ) )
                  WRKBL = MAX( WRKBL, 3*N+N*
                  WRKBL = MAX( WRKBL, 3*N+N*
     $                    ILAENV( 1, 'DORMBR', 'PRT', N, N, N, -1 ) )
     $                    ILAENV( 1, 'DORMBR', 'PRT', N, N, N, -1 ) )
                  WRKBL = MAX( WRKBL, BDSPAC+3*N )
                  WRKBL = MAX( WRKBL, BDSPAC+2*N )
                  MAXWRK = WRKBL + N*N
                  MAXWRK = WRKBL + N*N
                  MINWRK = BDSPAC + N*N + 3*N
                  MINWRK = BDSPAC + N*N + 2*N
               ELSE IF( WNTQA ) THEN
               ELSE IF( WNTQA ) THEN
*
*
*                 Path 4 (M much larger than N, JOBZ='A')
*                 Path 4 (M much larger than N, JOBZ='A')
 Lines 279-287    Link Here 
     $                    ILAENV( 1, 'DORMBR', 'QLN', N, N, N, -1 ) )
     $                    ILAENV( 1, 'DORMBR', 'QLN', N, N, N, -1 ) )
                  WRKBL = MAX( WRKBL, 3*N+N*
                  WRKBL = MAX( WRKBL, 3*N+N*
     $                    ILAENV( 1, 'DORMBR', 'PRT', N, N, N, -1 ) )
     $                    ILAENV( 1, 'DORMBR', 'PRT', N, N, N, -1 ) )
                  WRKBL = MAX( WRKBL, BDSPAC+3*N )
                  WRKBL = MAX( WRKBL, BDSPAC+2*N )
                  MAXWRK = WRKBL + N*N
                  MAXWRK = N*N + WRKBL
                  MINWRK = BDSPAC + N*N + 3*N
                  MINWRK = BDSPAC + N*N + M + N
               END IF
               END IF
            ELSE
            ELSE
*
*
 Lines 289-341    Link Here 
*
*
               WRKBL = 3*N + ( M+N )*ILAENV( 1, 'DGEBRD', ' ', M, N, -1,
               WRKBL = 3*N + ( M+N )*ILAENV( 1, 'DGEBRD', ' ', M, N, -1,
     $                 -1 )
     $                 -1 )
               IF( WNTQN ) THEN
               IF( WNTQO ) THEN
                  MAXWRK = MAX( WRKBL, BDSPAC+3*N )
                  MINWRK = 3*N + MAX( M, BDSPAC )
               ELSE IF( WNTQO ) THEN
                  WRKBL = MAX( WRKBL, 3*N+N*
                  WRKBL = MAX( WRKBL, 3*N+N*
     $                    ILAENV( 1, 'DORMBR', 'QLN', M, N, N, -1 ) )
     $                    ILAENV( 1, 'DORMBR', 'QLN', M, N, N, -1 ) )
                  WRKBL = MAX( WRKBL, 3*N+N*
                  WRKBL = MAX( WRKBL, 3*N+N*
     $                    ILAENV( 1, 'DORMBR', 'PRT', N, N, N, -1 ) )
     $                    ILAENV( 1, 'DORMBR', 'PRT', N, N, N, -1 ) )
                  WRKBL = MAX( WRKBL, BDSPAC+3*N )
                  WRKBL = MAX( WRKBL, BDSPAC+2*N+M )
                  MAXWRK = WRKBL + M*N
                  MAXWRK = WRKBL + M*N
                  MINWRK = 3*N + MAX( M, N*N+BDSPAC )
                  MINWRK = BDSPAC + N*N + 2*N + M
               ELSE IF( WNTQS ) THEN
               ELSE IF( WNTQS ) THEN
                  WRKBL = MAX( WRKBL, 3*N+N*
                  MAXWRK = MAX( MAXWRK, 3*N+N*
     $                    ILAENV( 1, 'DORMBR', 'QLN', M, N, N, -1 ) )
     $                     ILAENV( 1, 'DORMBR', 'QLN', M, N, N, -1 ) )
                  WRKBL = MAX( WRKBL, 3*N+N*
                  MAXWRK = MAX( MAXWRK, 3*N+N*
     $                    ILAENV( 1, 'DORMBR', 'PRT', N, N, N, -1 ) )
     $                     ILAENV( 1, 'DORMBR', 'PRT', N, N, N, -1 ) )
                  MAXWRK = MAX( WRKBL, BDSPAC+3*N )
                  MAXWRK = MAX( MAXWRK, BDSPAC+2*N+M )
                  MINWRK = 3*N + MAX( M, BDSPAC )
                  MINWRK = BDSPAC + 2*N + M
               ELSE IF( WNTQA ) THEN
               ELSE IF( WNTQA ) THEN
                  WRKBL = MAX( WRKBL, 3*N+M*
                  MAXWRK = MAX( MAXWRK, 3*N+M*
     $                    ILAENV( 1, 'DORMBR', 'QLN', M, M, N, -1 ) )
     $                     ILAENV( 1, 'DORMBR', 'QLN', M, M, N, -1 ) )
                  WRKBL = MAX( WRKBL, 3*N+N*
                  MAXWRK = MAX( MAXWRK, 3*N+N*
     $                    ILAENV( 1, 'DORMBR', 'PRT', N, N, N, -1 ) )
     $                     ILAENV( 1, 'DORMBR', 'PRT', N, N, N, -1 ) )
                  MAXWRK = MAX( MAXWRK, BDSPAC+3*N )
                  MAXWRK = MAX( MAXWRK, BDSPAC+2*N+M )
                  MINWRK = 3*N + MAX( M, BDSPAC )
                  MINWRK = BDSPAC + 2*N + M
               END IF
               END IF
            END IF
            END IF
         ELSE
         ELSE
*
*
*           Compute space needed for DBDSDC
*           Compute space needed for DBDSDC
*
*
            IF( WNTQN ) THEN
            BDSPAC = 3*M*M + 7*M
               BDSPAC = 7*M
            BDSPAN = MAX( 12*M+4, 8*M+2+SMLSIZ*( SMLSIZ+8 ) )
            ELSE
               BDSPAC = 3*M*M + 4*M
            END IF
            IF( N.GE.MNTHR ) THEN
            IF( N.GE.MNTHR ) THEN
               IF( WNTQN ) THEN
               IF( WNTQN ) THEN
*
*
*                 Path 1t (N much larger than M, JOBZ='N')
*                 Path 1t (N much larger than M, JOBZ='N')
*
*
                  WRKBL = M + M*ILAENV( 1, 'DGELQF', ' ', M, N, -1,
                  MAXWRK = M + M*ILAENV( 1, 'DGELQF', ' ', M, N, -1,
     $                    -1 )
     $                     -1 )
                  WRKBL = MAX( WRKBL, 3*M+2*M*
                  MAXWRK = MAX( MAXWRK, 3*M+2*M*
     $                    ILAENV( 1, 'DGEBRD', ' ', M, M, -1, -1 ) )
     $                     ILAENV( 1, 'DGEBRD', ' ', M, M, -1, -1 ) )
                  MAXWRK = MAX( WRKBL, BDSPAC+M )
                  MAXWRK = MAX( MAXWRK, BDSPAC )
                  MINWRK = BDSPAC + M
                  MINWRK = BDSPAC
               ELSE IF( WNTQO ) THEN
               ELSE IF( WNTQO ) THEN
*
*
*                 Path 2t (N much larger than M, JOBZ='O')
*                 Path 2t (N much larger than M, JOBZ='O')
 Lines 349-357    Link Here 
     $                    ILAENV( 1, 'DORMBR', 'QLN', M, M, M, -1 ) )
     $                    ILAENV( 1, 'DORMBR', 'QLN', M, M, M, -1 ) )
                  WRKBL = MAX( WRKBL, 3*M+M*
                  WRKBL = MAX( WRKBL, 3*M+M*
     $                    ILAENV( 1, 'DORMBR', 'PRT', M, M, M, -1 ) )
     $                    ILAENV( 1, 'DORMBR', 'PRT', M, M, M, -1 ) )
                  WRKBL = MAX( WRKBL, BDSPAC+3*M )
                  WRKBL = MAX( WRKBL, BDSPAC+2*M )
                  MAXWRK = WRKBL + 2*M*M
                  MAXWRK = WRKBL + 2*M*M
                  MINWRK = BDSPAC + 2*M*M + 3*M
                  MINWRK = BDSPAC + 2*M*M + 2*M
               ELSE IF( WNTQS ) THEN
               ELSE IF( WNTQS ) THEN
*
*
*                 Path 3t (N much larger than M, JOBZ='S')
*                 Path 3t (N much larger than M, JOBZ='S')
 Lines 365-373    Link Here 
     $                    ILAENV( 1, 'DORMBR', 'QLN', M, M, M, -1 ) )
     $                    ILAENV( 1, 'DORMBR', 'QLN', M, M, M, -1 ) )
                  WRKBL = MAX( WRKBL, 3*M+M*
                  WRKBL = MAX( WRKBL, 3*M+M*
     $                    ILAENV( 1, 'DORMBR', 'PRT', M, M, M, -1 ) )
     $                    ILAENV( 1, 'DORMBR', 'PRT', M, M, M, -1 ) )
                  WRKBL = MAX( WRKBL, BDSPAC+3*M )
                  WRKBL = MAX( WRKBL, BDSPAC+2*M )
                  MAXWRK = WRKBL + M*M
                  MAXWRK = WRKBL + M*M
                  MINWRK = BDSPAC + M*M + 3*M
                  MINWRK = BDSPAC + M*M + 2*M
               ELSE IF( WNTQA ) THEN
               ELSE IF( WNTQA ) THEN
*
*
*                 Path 4t (N much larger than M, JOBZ='A')
*                 Path 4t (N much larger than M, JOBZ='A')
 Lines 381-389    Link Here 
     $                    ILAENV( 1, 'DORMBR', 'QLN', M, M, M, -1 ) )
     $                    ILAENV( 1, 'DORMBR', 'QLN', M, M, M, -1 ) )
                  WRKBL = MAX( WRKBL, 3*M+M*
                  WRKBL = MAX( WRKBL, 3*M+M*
     $                    ILAENV( 1, 'DORMBR', 'PRT', M, M, M, -1 ) )
     $                    ILAENV( 1, 'DORMBR', 'PRT', M, M, M, -1 ) )
                  WRKBL = MAX( WRKBL, BDSPAC+3*M )
                  WRKBL = MAX( WRKBL, BDSPAC+2*M )
                  MAXWRK = WRKBL + M*M
                  MAXWRK = WRKBL + M*M
                  MINWRK = BDSPAC + M*M + 3*M
                  MINWRK = BDSPAC + M*M + M + N
               END IF
               END IF
            ELSE
            ELSE
*
*
 Lines 391-442    Link Here 
*
*
               WRKBL = 3*M + ( M+N )*ILAENV( 1, 'DGEBRD', ' ', M, N, -1,
               WRKBL = 3*M + ( M+N )*ILAENV( 1, 'DGEBRD', ' ', M, N, -1,
     $                 -1 )
     $                 -1 )
               IF( WNTQN ) THEN
               IF( WNTQO ) THEN
                  MAXWRK = MAX( WRKBL, BDSPAC+3*M )
                  MINWRK = 3*M + MAX( N, BDSPAC )
               ELSE IF( WNTQO ) THEN
                  WRKBL = MAX( WRKBL, 3*M+M*
                  WRKBL = MAX( WRKBL, 3*M+M*
     $                    ILAENV( 1, 'DORMBR', 'QLN', M, M, N, -1 ) )
     $                    ILAENV( 1, 'DORMBR', 'QLN', M, M, N, -1 ) )
                  WRKBL = MAX( WRKBL, 3*M+M*
                  WRKBL = MAX( WRKBL, 3*M+M*
     $                    ILAENV( 1, 'DORMBR', 'PRT', M, N, M, -1 ) )
     $                    ILAENV( 1, 'DORMBR', 'PRT', M, N, M, -1 ) )
                  WRKBL = MAX( WRKBL, BDSPAC+3*M )
                  WRKBL = MAX( WRKBL, BDSPAC+2*M )
                  MAXWRK = WRKBL + M*N
                  MAXWRK = WRKBL + M*N
                  MINWRK = 3*M + MAX( N, M*M+BDSPAC )
                  MINWRK = BDSPAC + M*M + 2*M + N
               ELSE IF( WNTQS ) THEN
               ELSE IF( WNTQS ) THEN
                  WRKBL = MAX( WRKBL, 3*M+M*
                  MAXWRK = MAX( MAXWRK, 3*M+M*
     $                    ILAENV( 1, 'DORMBR', 'QLN', M, M, N, -1 ) )
     $                     ILAENV( 1, 'DORMBR', 'QLN', M, M, N, -1 ) )
                  WRKBL = MAX( WRKBL, 3*M+M*
                  MAXWRK = MAX( MAXWRK, 3*M+M*
     $                    ILAENV( 1, 'DORMBR', 'PRT', M, N, M, -1 ) )
     $                     ILAENV( 1, 'DORMBR', 'PRT', M, N, M, -1 ) )
                  MAXWRK = MAX( WRKBL, BDSPAC+3*M )
                  MAXWRK = MAX( MAXWRK, BDSPAC+2*M )
                  MINWRK = 3*M + MAX( N, BDSPAC )
                  MINWRK = BDSPAC + 2*M + N
               ELSE IF( WNTQA ) THEN
               ELSE IF( WNTQA ) THEN
                  WRKBL = MAX( WRKBL, 3*M+M*
                  MAXWRK = MAX( MAXWRK, 3*M+M*
     $                    ILAENV( 1, 'DORMBR', 'QLN', M, M, N, -1 ) )
     $                     ILAENV( 1, 'DORMBR', 'QLN', M, M, N, -1 ) )
                  WRKBL = MAX( WRKBL, 3*M+M*
                  MAXWRK = MAX( MAXWRK, 3*M+N*
     $                    ILAENV( 1, 'DORMBR', 'PRT', N, N, M, -1 ) )
     $                     ILAENV( 1, 'DORMBR', 'PRT', N, N, M, -1 ) )
                  MAXWRK = MAX( WRKBL, BDSPAC+3*M )
                  MAXWRK = MAX( MAXWRK, BDSPAC+2*M )
                  MINWRK = 3*M + MAX( N, BDSPAC )
                  MINWRK = BDSPAC + 2*M + N
               END IF
               END IF
            END IF
            END IF
         END IF
         END IF
      END IF
      IF( INFO.EQ.0 ) THEN
         WORK( 1 ) = MAXWRK
         WORK( 1 ) = MAXWRK
         IF( LWORK.LT.MINWRK .AND. LWORK.NE.LQUERV )
     $      INFO = -12
      END IF
      END IF
*
*
      IF( LWORK.LT.MINWRK .AND. .NOT.LQUERY ) THEN
*     Quick returns
         INFO = -12
*
      END IF
      IF( INFO.NE.0 ) THEN
      IF( INFO.NE.0 ) THEN
         CALL XERBLA( 'DGESDD', -INFO )
         CALL XERBLA( 'DGESDD', -INFO )
         RETURN
         RETURN
      ELSE IF( LQUERY ) THEN
         RETURN
      END IF
      END IF
*
      IF( LWORK.EQ.LQUERV )
*     Quick return if possible
     $   RETURN
*
      IF( M.EQ.0 .OR. N.EQ.0 ) THEN
      IF( M.EQ.0 .OR. N.EQ.0 ) THEN
         IF( LWORK.GE.1 )
     $      WORK( 1 ) = ONE
         RETURN
         RETURN
      END IF
      END IF
*
*
 Lines 497-503    Link Here 
               NWORK = IE + N
               NWORK = IE + N
*
*
*              Perform bidiagonal SVD, computing singular values only
*              Perform bidiagonal SVD, computing singular values only
*              (Workspace: need N+BDSPAC)
*              (Workspace: need BDSPAN)
*
*
               CALL DBDSDC( 'U', 'N', N, S, WORK( IE ), DUM, 1, DUM, 1,
               CALL DBDSDC( 'U', 'N', N, S, WORK( IE ), DUM, 1, DUM, 1,
     $                      DUM, IDUM, WORK( NWORK ), IWORK, INFO )
     $                      DUM, IDUM, WORK( NWORK ), IWORK, INFO )
 Lines 512-521    Link Here 
*
*
*              WORK(IR) is LDWRKR by N
*              WORK(IR) is LDWRKR by N
*
*
               IF( LWORK.GE.LDA*N+N*N+3*N+BDSPAC ) THEN
               IF( LWORK.GE.LDA*N+4*N*N+9*N ) THEN
                  LDWRKR = LDA
                  LDWRKR = LDA
               ELSE
               ELSE
                  LDWRKR = ( LWORK-N*N-3*N-BDSPAC ) / N
                  LDWRKR = ( LWORK-4*N*N-9*N ) / N
               END IF
               END IF
               ITAU = IR + LDWRKR*N
               ITAU = IR + LDWRKR*N
               NWORK = ITAU + N
               NWORK = ITAU + N
 Lines 557-563    Link Here 
*              Perform bidiagonal SVD, computing left singular vectors
*              Perform bidiagonal SVD, computing left singular vectors
*              of bidiagonal matrix in WORK(IU) and computing right
*              of bidiagonal matrix in WORK(IU) and computing right
*              singular vectors of bidiagonal matrix in VT
*              singular vectors of bidiagonal matrix in VT
*              (Workspace: need N+N*N+BDSPAC)
*              (Workspace: need 2*N*N+BDSPAC)
*
*
               CALL DBDSDC( 'U', 'I', N, S, WORK( IE ), WORK( IU ), N,
               CALL DBDSDC( 'U', 'I', N, S, WORK( IE ), WORK( IU ), N,
     $                      VT, LDVT, DUM, IDUM, WORK( NWORK ), IWORK,
     $                      VT, LDVT, DUM, IDUM, WORK( NWORK ), IWORK,
 Lines 633-639    Link Here 
*              Perform bidiagonal SVD, computing left singular vectors
*              Perform bidiagonal SVD, computing left singular vectors
*              of bidiagoal matrix in U and computing right singular
*              of bidiagoal matrix in U and computing right singular
*              vectors of bidiagonal matrix in VT
*              vectors of bidiagonal matrix in VT
*              (Workspace: need N+BDSPAC)
*              (Workspace: need N*N+BDSPAC)
*
*
               CALL DBDSDC( 'U', 'I', N, S, WORK( IE ), U, LDU, VT,
               CALL DBDSDC( 'U', 'I', N, S, WORK( IE ), U, LDU, VT,
     $                      LDVT, DUM, IDUM, WORK( NWORK ), IWORK,
     $                      LDVT, DUM, IDUM, WORK( NWORK ), IWORK,
 Lines 681-687    Link Here 
               CALL DLACPY( 'L', M, N, A, LDA, U, LDU )
               CALL DLACPY( 'L', M, N, A, LDA, U, LDU )
*
*
*              Generate Q in U
*              Generate Q in U
*              (Workspace: need N*N+2*N, prefer N*N+N+N*NB)
*              (Workspace: need N*N+N+M, prefer N*N+N+M*NB)
               CALL DORGQR( M, M, N, U, LDU, WORK( ITAU ),
               CALL DORGQR( M, M, N, U, LDU, WORK( ITAU ),
     $                      WORK( NWORK ), LWORK-NWORK+1, IERR )
     $                      WORK( NWORK ), LWORK-NWORK+1, IERR )
*
*
 Lines 703-709    Link Here 
*              Perform bidiagonal SVD, computing left singular vectors
*              Perform bidiagonal SVD, computing left singular vectors
*              of bidiagonal matrix in WORK(IU) and computing right
*              of bidiagonal matrix in WORK(IU) and computing right
*              singular vectors of bidiagonal matrix in VT
*              singular vectors of bidiagonal matrix in VT
*              (Workspace: need N+N*N+BDSPAC)
*              (Workspace: need N*N+BDSPAC)
*
*
               CALL DBDSDC( 'U', 'I', N, S, WORK( IE ), WORK( IU ), N,
               CALL DBDSDC( 'U', 'I', N, S, WORK( IE ), WORK( IU ), N,
     $                      VT, LDVT, DUM, IDUM, WORK( NWORK ), IWORK,
     $                      VT, LDVT, DUM, IDUM, WORK( NWORK ), IWORK,
 Lines 754-766    Link Here 
            IF( WNTQN ) THEN
            IF( WNTQN ) THEN
*
*
*              Perform bidiagonal SVD, only computing singular values
*              Perform bidiagonal SVD, only computing singular values
*              (Workspace: need N+BDSPAC)
*              (Workspace: need BDSPAN)
*
*
               CALL DBDSDC( 'U', 'N', N, S, WORK( IE ), DUM, 1, DUM, 1,
               CALL DBDSDC( 'U', 'N', N, S, WORK( IE ), DUM, 1, DUM, 1,
     $                      DUM, IDUM, WORK( NWORK ), IWORK, INFO )
     $                      DUM, IDUM, WORK( NWORK ), IWORK, INFO )
            ELSE IF( WNTQO ) THEN
            ELSE IF( WNTQO ) THEN
               IU = NWORK
               IU = NWORK
               IF( LWORK.GE.M*N+3*N+BDSPAC ) THEN
               IF( LWORK.GE.M*N+3*N*N+9*N ) THEN
*
*
*                 WORK( IU ) is M by N
*                 WORK( IU ) is M by N
*
*
 Lines 785-791    Link Here 
*              Perform bidiagonal SVD, computing left singular vectors
*              Perform bidiagonal SVD, computing left singular vectors
*              of bidiagonal matrix in WORK(IU) and computing right
*              of bidiagonal matrix in WORK(IU) and computing right
*              singular vectors of bidiagonal matrix in VT
*              singular vectors of bidiagonal matrix in VT
*              (Workspace: need N+N*N+BDSPAC)
*              (Workspace: need N*N+BDSPAC)
*
*
               CALL DBDSDC( 'U', 'I', N, S, WORK( IE ), WORK( IU ),
               CALL DBDSDC( 'U', 'I', N, S, WORK( IE ), WORK( IU ),
     $                      LDWRKU, VT, LDVT, DUM, IDUM, WORK( NWORK ),
     $                      LDWRKU, VT, LDVT, DUM, IDUM, WORK( NWORK ),
 Lines 798-804    Link Here 
     $                      WORK( ITAUP ), VT, LDVT, WORK( NWORK ),
     $                      WORK( ITAUP ), VT, LDVT, WORK( NWORK ),
     $                      LWORK-NWORK+1, IERR )
     $                      LWORK-NWORK+1, IERR )
*
*
               IF( LWORK.GE.M*N+3*N+BDSPAC ) THEN
               IF( LWORK.GE.M*N+3*N*N+9*N ) THEN
*
*
*                 Overwrite WORK(IU) by left singular vectors of A
*                 Overwrite WORK(IU) by left singular vectors of A
*                 (Workspace: need N*N+2*N, prefer N*N+N+N*NB)
*                 (Workspace: need N*N+2*N, prefer N*N+N+N*NB)
 Lines 838-844    Link Here 
*              Perform bidiagonal SVD, computing left singular vectors
*              Perform bidiagonal SVD, computing left singular vectors
*              of bidiagonal matrix in U and computing right singular
*              of bidiagonal matrix in U and computing right singular
*              vectors of bidiagonal matrix in VT
*              vectors of bidiagonal matrix in VT
*              (Workspace: need N+BDSPAC)
*              (Workspace: need BDSPAC)
*
*
               CALL DLASET( 'F', M, N, ZERO, ZERO, U, LDU )
               CALL DLASET( 'F', M, N, ZERO, ZERO, U, LDU )
               CALL DBDSDC( 'U', 'I', N, S, WORK( IE ), U, LDU, VT,
               CALL DBDSDC( 'U', 'I', N, S, WORK( IE ), U, LDU, VT,
 Lines 855-866    Link Here 
               CALL DORMBR( 'P', 'R', 'T', N, N, N, A, LDA,
               CALL DORMBR( 'P', 'R', 'T', N, N, N, A, LDA,
     $                      WORK( ITAUP ), VT, LDVT, WORK( NWORK ),
     $                      WORK( ITAUP ), VT, LDVT, WORK( NWORK ),
     $                      LWORK-NWORK+1, IERR )
     $                      LWORK-NWORK+1, IERR )
            ELSE IF( WNTQA ) THEN
            ELSE
*
*
*              Perform bidiagonal SVD, computing left singular vectors
*              Perform bidiagonal SVD, computing left singular vectors
*              of bidiagonal matrix in U and computing right singular
*              of bidiagonal matrix in U and computing right singular
*              vectors of bidiagonal matrix in VT
*              vectors of bidiagonal matrix in VT
*              (Workspace: need N+BDSPAC)
*              (Workspace: need BDSPAC)
*
*
               CALL DLASET( 'F', M, M, ZERO, ZERO, U, LDU )
               CALL DLASET( 'F', M, M, ZERO, ZERO, U, LDU )
               CALL DBDSDC( 'U', 'I', N, S, WORK( IE ), U, LDU, VT,
               CALL DBDSDC( 'U', 'I', N, S, WORK( IE ), U, LDU, VT,
 Lines 925-931    Link Here 
               NWORK = IE + M
               NWORK = IE + M
*
*
*              Perform bidiagonal SVD, computing singular values only
*              Perform bidiagonal SVD, computing singular values only
*              (Workspace: need M+BDSPAC)
*              (Workspace: need BDSPAN)
*
*
               CALL DBDSDC( 'U', 'N', M, S, WORK( IE ), DUM, 1, DUM, 1,
               CALL DBDSDC( 'U', 'N', M, S, WORK( IE ), DUM, 1, DUM, 1,
     $                      DUM, IDUM, WORK( NWORK ), IWORK, INFO )
     $                      DUM, IDUM, WORK( NWORK ), IWORK, INFO )
 Lines 941-947    Link Here 
*              IVT is M by M
*              IVT is M by M
*
*
               IL = IVT + M*M
               IL = IVT + M*M
               IF( LWORK.GE.M*N+M*M+3*M+BDSPAC ) THEN
               IF( LWORK.GE.M*N+4*M*M+9*M ) THEN
*
*
*                 WORK(IL) is M by N
*                 WORK(IL) is M by N
*
*
 Lines 986-992    Link Here 
*              Perform bidiagonal SVD, computing left singular vectors
*              Perform bidiagonal SVD, computing left singular vectors
*              of bidiagonal matrix in U, and computing right singular
*              of bidiagonal matrix in U, and computing right singular
*              vectors of bidiagonal matrix in WORK(IVT)
*              vectors of bidiagonal matrix in WORK(IVT)
*              (Workspace: need M+M*M+BDSPAC)
*              (Workspace: need 2*M*M+BDSPAC)
*
*
               CALL DBDSDC( 'U', 'I', M, S, WORK( IE ), U, LDU,
               CALL DBDSDC( 'U', 'I', M, S, WORK( IE ), U, LDU,
     $                      WORK( IVT ), M, DUM, IDUM, WORK( NWORK ),
     $                      WORK( IVT ), M, DUM, IDUM, WORK( NWORK ),
 Lines 1061-1067    Link Here 
*              Perform bidiagonal SVD, computing left singular vectors
*              Perform bidiagonal SVD, computing left singular vectors
*              of bidiagonal matrix in U and computing right singular
*              of bidiagonal matrix in U and computing right singular
*              vectors of bidiagonal matrix in VT
*              vectors of bidiagonal matrix in VT
*              (Workspace: need M+BDSPAC)
*              (Workspace: need M*M+BDSPAC)
*
*
               CALL DBDSDC( 'U', 'I', M, S, WORK( IE ), U, LDU, VT,
               CALL DBDSDC( 'U', 'I', M, S, WORK( IE ), U, LDU, VT,
     $                      LDVT, DUM, IDUM, WORK( NWORK ), IWORK,
     $                      LDVT, DUM, IDUM, WORK( NWORK ), IWORK,
 Lines 1108-1114    Link Here 
               CALL DLACPY( 'U', M, N, A, LDA, VT, LDVT )
               CALL DLACPY( 'U', M, N, A, LDA, VT, LDVT )
*
*
*              Generate Q in VT
*              Generate Q in VT
*              (Workspace: need M*M+2*M, prefer M*M+M+M*NB)
*              (Workspace: need M*M+M+N, prefer M*M+M+N*NB)
*
*
               CALL DORGLQ( N, N, M, VT, LDVT, WORK( ITAU ),
               CALL DORGLQ( N, N, M, VT, LDVT, WORK( ITAU ),
     $                      WORK( NWORK ), LWORK-NWORK+1, IERR )
     $                      WORK( NWORK ), LWORK-NWORK+1, IERR )
 Lines 1131-1137    Link Here 
*              Perform bidiagonal SVD, computing left singular vectors
*              Perform bidiagonal SVD, computing left singular vectors
*              of bidiagonal matrix in U and computing right singular
*              of bidiagonal matrix in U and computing right singular
*              vectors of bidiagonal matrix in WORK(IVT)
*              vectors of bidiagonal matrix in WORK(IVT)
*              (Workspace: need M+M*M+BDSPAC)
*              (Workspace: need M*M+BDSPAC)
*
*
               CALL DBDSDC( 'U', 'I', M, S, WORK( IE ), U, LDU,
               CALL DBDSDC( 'U', 'I', M, S, WORK( IE ), U, LDU,
     $                      WORK( IVT ), LDWKVT, DUM, IDUM,
     $                      WORK( IVT ), LDWKVT, DUM, IDUM,
 Lines 1182-1195    Link Here 
            IF( WNTQN ) THEN
            IF( WNTQN ) THEN
*
*
*              Perform bidiagonal SVD, only computing singular values
*              Perform bidiagonal SVD, only computing singular values
*              (Workspace: need M+BDSPAC)
*              (Workspace: need BDSPAN)
*
*
               CALL DBDSDC( 'L', 'N', M, S, WORK( IE ), DUM, 1, DUM, 1,
               CALL DBDSDC( 'L', 'N', M, S, WORK( IE ), DUM, 1, DUM, 1,
     $                      DUM, IDUM, WORK( NWORK ), IWORK, INFO )
     $                      DUM, IDUM, WORK( NWORK ), IWORK, INFO )
            ELSE IF( WNTQO ) THEN
            ELSE IF( WNTQO ) THEN
               LDWKVT = M
               LDWKVT = M
               IVT = NWORK
               IVT = NWORK
               IF( LWORK.GE.M*N+3*M+BDSPAC ) THEN
               IF( LWORK.GE.M*N+3*M*M+9*M ) THEN
*
*
*                 WORK( IVT ) is M by N
*                 WORK( IVT ) is M by N
*
*
 Lines 1224-1230    Link Here 
     $                      WORK( ITAUQ ), U, LDU, WORK( NWORK ),
     $                      WORK( ITAUQ ), U, LDU, WORK( NWORK ),
     $                      LWORK-NWORK+1, IERR )
     $                      LWORK-NWORK+1, IERR )
*
*
               IF( LWORK.GE.M*N+3*M+BDSPAC ) THEN
               IF( LWORK.GE.M*N+3*M*M+9*M ) THEN
*
*
*                 Overwrite WORK(IVT) by left singular vectors of A
*                 Overwrite WORK(IVT) by left singular vectors of A
*                 (Workspace: need M*M+2*M, prefer M*M+M+M*NB)
*                 (Workspace: need M*M+2*M, prefer M*M+M+M*NB)
 Lines 1263-1269    Link Here 
*              Perform bidiagonal SVD, computing left singular vectors
*              Perform bidiagonal SVD, computing left singular vectors
*              of bidiagonal matrix in U and computing right singular
*              of bidiagonal matrix in U and computing right singular
*              vectors of bidiagonal matrix in VT
*              vectors of bidiagonal matrix in VT
*              (Workspace: need M+BDSPAC)
*              (Workspace: need BDSPAC)
*
*
               CALL DLASET( 'F', M, N, ZERO, ZERO, VT, LDVT )
               CALL DLASET( 'F', M, N, ZERO, ZERO, VT, LDVT )
               CALL DBDSDC( 'L', 'I', M, S, WORK( IE ), U, LDU, VT,
               CALL DBDSDC( 'L', 'I', M, S, WORK( IE ), U, LDU, VT,
 Lines 1280-1291    Link Here 
               CALL DORMBR( 'P', 'R', 'T', M, N, M, A, LDA,
               CALL DORMBR( 'P', 'R', 'T', M, N, M, A, LDA,
     $                      WORK( ITAUP ), VT, LDVT, WORK( NWORK ),
     $                      WORK( ITAUP ), VT, LDVT, WORK( NWORK ),
     $                      LWORK-NWORK+1, IERR )
     $                      LWORK-NWORK+1, IERR )
            ELSE IF( WNTQA ) THEN
            ELSE
*
*
*              Perform bidiagonal SVD, computing left singular vectors
*              Perform bidiagonal SVD, computing left singular vectors
*              of bidiagonal matrix in U and computing right singular
*              of bidiagonal matrix in U and computing right singular
*              vectors of bidiagonal matrix in VT
*              vectors of bidiagonal matrix in VT
*              (Workspace: need M+BDSPAC)
*              (Workspace: need BDSPAC)
*
*
               CALL DLASET( 'F', N, N, ZERO, ZERO, VT, LDVT )
               CALL DLASET( 'F', N, N, ZERO, ZERO, VT, LDVT )
               CALL DBDSDC( 'L', 'I', M, S, WORK( IE ), U, LDU, VT,
               CALL DBDSDC( 'L', 'I', M, S, WORK( IE ), U, LDU, VT,
 Lines 1319-1327    Link Here 
         IF( ANRM.GT.BIGNUM )
         IF( ANRM.GT.BIGNUM )
     $      CALL DLASCL( 'G', 0, 0, BIGNUM, ANRM, MINMN, 1, S, MINMN,
     $      CALL DLASCL( 'G', 0, 0, BIGNUM, ANRM, MINMN, 1, S, MINMN,
     $                   IERR )
     $                   IERR )
         IF( INFO.NE.0 .AND. ANRM.GT.BIGNUM )
     $      CALL DLASCL( 'G', 0, 0, BIGNUM, ANRM, MINMN-1, 1, WORK( 2 ),
     $                   MINMN, IERR )
         IF( ANRM.LT.SMLNUM )
         IF( ANRM.LT.SMLNUM )
     $      CALL DLASCL( 'G', 0, 0, SMLNUM, ANRM, MINMN, 1, S, MINMN,
     $      CALL DLASCL( 'G', 0, 0, SMLNUM, ANRM, MINMN, 1, S, MINMN,
     $                   IERR )
     $                   IERR )
         IF( INFO.NE.0 .AND. ANRM.LT.SMLNUM )
     $      CALL DLASCL( 'G', 0, 0, SMLNUM, ANRM, MINMN-1, 1, WORK( 2 ),
     $                   MINMN, IERR )
      END IF
      END IF
*
*
*     Return optimal workspace in WORK(1)
*     Return optimal workspace in WORK(1)
(-) LAPACK/SRC/dgesvd.f (-20 / +19 lines)
 Lines 4-10    Link Here 
*  -- LAPACK driver routine (version 3.0) --
*  -- LAPACK driver routine (version 3.0) --
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Courant Institute, Argonne National Lab, and Rice University
*     Courant Institute, Argonne National Lab, and Rice University
*     October 31, 1999
*     June 30, 1999
*     8-15-00:  Improve consistency of WS calculations (eca)
*
*
*     .. Scalar Arguments ..
*     .. Scalar Arguments ..
      CHARACTER          JOBU, JOBVT
      CHARACTER          JOBU, JOBVT
 Lines 118-127    Link Here 
*          LWORK >= MAX(3*MIN(M,N)+MAX(M,N),5*MIN(M,N)).
*          LWORK >= MAX(3*MIN(M,N)+MAX(M,N),5*MIN(M,N)).
*          For good performance, LWORK should generally be larger.
*          For good performance, LWORK should generally be larger.
*
*
*          If LWORK = -1, then a workspace query is assumed; the routine
*          If LWORK = -1, a workspace query is assumed.  The optimal
*          only calculates the optimal size of the WORK array, returns
*          size for the WORK array is calculated and stored in WORK(1),
*          this value as the first entry of the WORK array, and no error
*          and no other work except argument checking is performed.
*          message related to LWORK is issued by XERBLA.
*
*
*  INFO    (output) INTEGER
*  INFO    (output) INTEGER
*          = 0:  successful exit.
*          = 0:  successful exit.
 Lines 134-145    Link Here 
*  =====================================================================
*  =====================================================================
*
*
*     .. Parameters ..
*     .. Parameters ..
      INTEGER            LQUERV
      PARAMETER          ( LQUERV = -1 )
      DOUBLE PRECISION   ZERO, ONE
      DOUBLE PRECISION   ZERO, ONE
      PARAMETER          ( ZERO = 0.0D0, ONE = 1.0D0 )
      PARAMETER          ( ZERO = 0.0D0, ONE = 1.0D0 )
*     ..
*     ..
*     .. Local Scalars ..
*     .. Local Scalars ..
      LOGICAL            LQUERY, WNTUA, WNTUAS, WNTUN, WNTUO, WNTUS,
      LOGICAL            WNTUA, WNTUAS, WNTUN, WNTUO, WNTUS, WNTVA,
     $                   WNTVA, WNTVAS, WNTVN, WNTVO, WNTVS
     $                   WNTVAS, WNTVN, WNTVO, WNTVS
      INTEGER            BDSPAC, BLK, CHUNK, I, IE, IERR, IR, ISCL,
      INTEGER            BDSPAC, BLK, CHUNK, I, IE, IERR, IR, ISCL,
     $                   ITAU, ITAUP, ITAUQ, IU, IWORK, LDWRKR, LDWRKU,
     $                   ITAU, ITAUP, ITAUQ, IU, IWORK, LDWRKR, LDWRKU,
     $                   MAXWRK, MINMN, MINWRK, MNTHR, NCU, NCVT, NRU,
     $                   MAXWRK, MINMN, MINWRK, MNTHR, NCU, NCVT, NRU,
 Lines 181-187    Link Here 
      WNTVO = LSAME( JOBVT, 'O' )
      WNTVO = LSAME( JOBVT, 'O' )
      WNTVN = LSAME( JOBVT, 'N' )
      WNTVN = LSAME( JOBVT, 'N' )
      MINWRK = 1
      MINWRK = 1
      LQUERY = ( LWORK.EQ.-1 )
      MAXWRK = 1
*
*
      IF( .NOT.( WNTUA .OR. WNTUS .OR. WNTUO .OR. WNTUN ) ) THEN
      IF( .NOT.( WNTUA .OR. WNTUS .OR. WNTUO .OR. WNTUN ) ) THEN
         INFO = -1
         INFO = -1
 Lines 208-215    Link Here 
*       NB refers to the optimal block size for the immediately
*       NB refers to the optimal block size for the immediately
*       following subroutine, as returned by ILAENV.)
*       following subroutine, as returned by ILAENV.)
*
*
      IF( INFO.EQ.0 .AND. ( LWORK.GE.1 .OR. LQUERY ) .AND. M.GT.0 .AND.
      IF( INFO.EQ.0 .AND. M.GT.0 .AND. N.GT.0 ) THEN
     $    N.GT.0 ) THEN
         IF( M.GE.N ) THEN
         IF( M.GE.N ) THEN
*
*
*           Compute space needed for DBDSQR
*           Compute space needed for DBDSQR
 Lines 557-580    Link Here 
               MAXWRK = MAX( MAXWRK, MINWRK )
               MAXWRK = MAX( MAXWRK, MINWRK )
            END IF
            END IF
         END IF
         END IF
      END IF
      IF( INFO.EQ.0 ) THEN
         WORK( 1 ) = MAXWRK
         WORK( 1 ) = MAXWRK
         IF( LWORK.LT.MINWRK .AND. LWORK.NE.LQUERV )
     $      INFO = -13
      END IF
      END IF
*
*
      IF( LWORK.LT.MINWRK .AND. .NOT.LQUERY ) THEN
*     Quick returns
         INFO = -13
*
      END IF
      IF( INFO.NE.0 ) THEN
      IF( INFO.NE.0 ) THEN
         CALL XERBLA( 'DGESVD', -INFO )
         CALL XERBLA( 'DGESVD', -INFO )
         RETURN
         RETURN
      ELSE IF( LQUERY ) THEN
         RETURN
      END IF
      END IF
*
      IF( LWORK.EQ.LQUERV )
*     Quick return if possible
     $   RETURN
*
      IF( M.EQ.0 .OR. N.EQ.0 ) THEN
      IF( M.EQ.0 .OR. N.EQ.0 ) THEN
         IF( LWORK.GE.1 )
     $      WORK( 1 ) = ONE
         RETURN
         RETURN
      END IF
      END IF
*
*
(-) LAPACK/SRC/dggbak.f (-3 / +8 lines)
 Lines 4-10    Link Here 
*  -- LAPACK routine (version 3.0) --
*  -- LAPACK routine (version 3.0) --
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Courant Institute, Argonne National Lab, and Rice University
*     Courant Institute, Argonne National Lab, and Rice University
*     September 30, 1994
*     February 1, 2001
*
*
*     .. Scalar Arguments ..
*     .. Scalar Arguments ..
      CHARACTER          JOB, SIDE
      CHARACTER          JOB, SIDE
 Lines 108-117    Link Here 
         INFO = -3
         INFO = -3
      ELSE IF( ILO.LT.1 ) THEN
      ELSE IF( ILO.LT.1 ) THEN
         INFO = -4
         INFO = -4
      ELSE IF( IHI.LT.ILO .OR. IHI.GT.MAX( 1, N ) ) THEN
      ELSE IF( N.EQ.0 .AND. IHI.EQ.0 .AND. ILO.NE.1 ) THEN
         INFO = -4
      ELSE IF( N.GT.0 .AND. ( IHI.LT.ILO .OR. IHI.GT.MAX( 1, N ) ) )
     $   THEN
         INFO = -5
      ELSE IF( N.EQ.0 .AND. ILO.EQ.1 .AND. IHI.NE.0 ) THEN
         INFO = -5
         INFO = -5
      ELSE IF( M.LT.0 ) THEN
      ELSE IF( M.LT.0 ) THEN
         INFO = -6
         INFO = -8
      ELSE IF( LDV.LT.MAX( 1, N ) ) THEN
      ELSE IF( LDV.LT.MAX( 1, N ) ) THEN
         INFO = -10
         INFO = -10
      END IF
      END IF
(-) LAPACK/SRC/dggbal.f (-7 / +7 lines)
 Lines 4-10    Link Here 
*  -- LAPACK routine (version 3.0) --
*  -- LAPACK routine (version 3.0) --
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Courant Institute, Argonne National Lab, and Rice University
*     Courant Institute, Argonne National Lab, and Rice University
*     September 30, 1994
*     April 12, 2001
*
*
*     .. Scalar Arguments ..
*     .. Scalar Arguments ..
      CHARACTER          JOB
      CHARACTER          JOB
 Lines 141-147    Link Here 
      ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
      ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
         INFO = -4
         INFO = -4
      ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
      ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
         INFO = -5
         INFO = -6
      END IF
      END IF
      IF( INFO.NE.0 ) THEN
      IF( INFO.NE.0 ) THEN
         CALL XERBLA( 'DGGBAL', -INFO )
         CALL XERBLA( 'DGGBAL', -INFO )
 Lines 188-195    Link Here 
      IF( L.NE.1 )
      IF( L.NE.1 )
     $   GO TO 30
     $   GO TO 30
*
*
      RSCALE( 1 ) = 1
      RSCALE( 1 ) = ONE
      LSCALE( 1 ) = 1
      LSCALE( 1 ) = ONE
      GO TO 190
      GO TO 190
*
*
   30 CONTINUE
   30 CONTINUE
 Lines 247-253    Link Here 
*     Permute rows M and I
*     Permute rows M and I
*
*
  160 CONTINUE
  160 CONTINUE
      LSCALE( M ) = I
      LSCALE( M ) = DBLE( I )
      IF( I.EQ.M )
      IF( I.EQ.M )
     $   GO TO 170
     $   GO TO 170
      CALL DSWAP( N-K+1, A( I, K ), LDA, A( M, K ), LDA )
      CALL DSWAP( N-K+1, A( I, K ), LDA, A( M, K ), LDA )
 Lines 256-262    Link Here 
*     Permute columns M and J
*     Permute columns M and J
*
*
  170 CONTINUE
  170 CONTINUE
      RSCALE( M ) = J
      RSCALE( M ) = DBLE( J )
      IF( J.EQ.M )
      IF( J.EQ.M )
     $   GO TO 180
     $   GO TO 180
      CALL DSWAP( L, A( 1, J ), 1, A( 1, M ), 1 )
      CALL DSWAP( L, A( 1, J ), 1, A( 1, M ), 1 )
 Lines 424-430    Link Here 
      DO 360 I = ILO, IHI
      DO 360 I = ILO, IHI
         IRAB = IDAMAX( N-ILO+1, A( I, ILO ), LDA )
         IRAB = IDAMAX( N-ILO+1, A( I, ILO ), LDA )
         RAB = ABS( A( I, IRAB+ILO-1 ) )
         RAB = ABS( A( I, IRAB+ILO-1 ) )
         IRAB = IDAMAX( N-ILO+1, B( I, ILO ), LDA )
         IRAB = IDAMAX( N-ILO+1, B( I, ILO ), LDB )
         RAB = MAX( RAB, ABS( B( I, IRAB+ILO-1 ) ) )
         RAB = MAX( RAB, ABS( B( I, IRAB+ILO-1 ) ) )
         LRAB = INT( LOG10( RAB+SFMIN ) / BASL+ONE )
         LRAB = INT( LOG10( RAB+SFMIN ) / BASL+ONE )
         IR = LSCALE( I ) + SIGN( HALF, LSCALE( I ) )
         IR = LSCALE( I ) + SIGN( HALF, LSCALE( I ) )
(-) LAPACK/SRC/dgges.f (-14 / +14 lines)
 Lines 6-11    Link Here 
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Courant Institute, Argonne National Lab, and Rice University
*     Courant Institute, Argonne National Lab, and Rice University
*     June 30, 1999
*     June 30, 1999
*     8-15-00:  Improve consistency of WS calculations (eca)
*
*
*     .. Scalar Arguments ..
*     .. Scalar Arguments ..
      CHARACTER          JOBVSL, JOBVSR, SORT
      CHARACTER          JOBVSL, JOBVSR, SORT
 Lines 158-167    Link Here 
*  LWORK   (input) INTEGER
*  LWORK   (input) INTEGER
*          The dimension of the array WORK.  LWORK >= 8*N+16.
*          The dimension of the array WORK.  LWORK >= 8*N+16.
*
*
*          If LWORK = -1, then a workspace query is assumed; the routine
*          If LWORK = -1, a workspace query is assumed.  The optimal
*          only calculates the optimal size of the WORK array, returns
*          size for the WORK array is calculated and stored in WORK(1),
*          this value as the first entry of the WORK array, and no error
*          and no other work except argument checking is performed.
*          message related to LWORK is issued by XERBLA.
*
*
*  BWORK   (workspace) LOGICAL array, dimension (N)
*  BWORK   (workspace) LOGICAL array, dimension (N)
*          Not referenced if SORT = 'N'.
*          Not referenced if SORT = 'N'.
 Lines 184-195    Link Here 
*  =====================================================================
*  =====================================================================
*
*
*     .. Parameters ..
*     .. Parameters ..
      INTEGER            LQUERV
      PARAMETER          ( LQUERV = -1 )
      DOUBLE PRECISION   ZERO, ONE
      DOUBLE PRECISION   ZERO, ONE
      PARAMETER          ( ZERO = 0.0D+0, ONE = 1.0D+0 )
      PARAMETER          ( ZERO = 0.0D+0, ONE = 1.0D+0 )
*     ..
*     ..
*     .. Local Scalars ..
*     .. Local Scalars ..
      LOGICAL            CURSL, ILASCL, ILBSCL, ILVSL, ILVSR, LASTSL,
      LOGICAL            CURSL, ILASCL, ILBSCL, ILVSL, ILVSR, LASTSL,
     $                   LQUERY, LST2SL, WANTST
     $                   LST2SL, WANTST
      INTEGER            I, ICOLS, IERR, IHI, IJOBVL, IJOBVR, ILEFT,
      INTEGER            I, ICOLS, IERR, IHI, IJOBVL, IJOBVR, ILEFT,
     $                   ILO, IP, IRIGHT, IROWS, ITAU, IWRK, MAXWRK,
     $                   ILO, IP, IRIGHT, IROWS, ITAU, IWRK, MAXWRK,
     $                   MINWRK
     $                   MINWRK
 Lines 245-251    Link Here 
*     Test the input arguments
*     Test the input arguments
*
*
      INFO = 0
      INFO = 0
      LQUERY = ( LWORK.EQ.-1 )
      IF( IJOBVL.LE.0 ) THEN
      IF( IJOBVL.LE.0 ) THEN
         INFO = -1
         INFO = -1
      ELSE IF( IJOBVR.LE.0 ) THEN
      ELSE IF( IJOBVR.LE.0 ) THEN
 Lines 272-278    Link Here 
*       following subroutine, as returned by ILAENV.)
*       following subroutine, as returned by ILAENV.)
*
*
      MINWRK = 1
      MINWRK = 1
      IF( INFO.EQ.0 .AND. ( LWORK.GE.1 .OR. LQUERY ) ) THEN
      IF( INFO.EQ.0 ) THEN
         MINWRK = 7*( N+1 ) + 16
         MINWRK = 7*( N+1 ) + 16
         MAXWRK = 7*( N+1 ) + N*ILAENV( 1, 'DGEQRF', ' ', N, 1, N, 0 ) +
         MAXWRK = 7*( N+1 ) + N*ILAENV( 1, 'DGEQRF', ' ', N, 1, N, 0 ) +
     $            16
     $            16
 Lines 281-299    Link Here 
     $               ILAENV( 1, 'DORGQR', ' ', N, 1, N, -1 ) )
     $               ILAENV( 1, 'DORGQR', ' ', N, 1, N, -1 ) )
         END IF
         END IF
         WORK( 1 ) = MAXWRK
         WORK( 1 ) = MAXWRK
         IF( LWORK.LT.MINWRK .AND. LWORK.NE.LQUERV )
     $      INFO = -19
      END IF
      END IF
*
*
      IF( LWORK.LT.MINWRK .AND. .NOT.LQUERY )
*     Quick returns
     $   INFO = -19
*
      IF( INFO.NE.0 ) THEN
      IF( INFO.NE.0 ) THEN
         CALL XERBLA( 'DGGES ', -INFO )
         CALL XERBLA( 'DGGES ', -INFO )
         RETURN
         RETURN
      ELSE IF( LQUERY ) THEN
         RETURN
      END IF
      END IF
*
      IF( LWORK.EQ.LQUERV )
*     Quick return if possible
     $   RETURN
*
      IF( N.EQ.0 ) THEN
      IF( N.EQ.0 ) THEN
         SDIM = 0
         SDIM = 0
         RETURN
         RETURN
(-) LAPACK/SRC/dggesx.f (-8 / +21 lines)
 Lines 7-12    Link Here 
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Courant Institute, Argonne National Lab, and Rice University
*     Courant Institute, Argonne National Lab, and Rice University
*     June 30, 1999
*     June 30, 1999
*     8-15-00:  Do WS calculations if LWORK = -1 (eca)
*
*
*     .. Scalar Arguments ..
*     .. Scalar Arguments ..
      CHARACTER          JOBVSL, JOBVSR, SENSE, SORT
      CHARACTER          JOBVSL, JOBVSR, SENSE, SORT
 Lines 185-190    Link Here 
*          If SENSE = 'E', 'V', or 'B',
*          If SENSE = 'E', 'V', or 'B',
*          LWORK >= MAX( 8*(N+1)+16, 2*SDIM*(N-SDIM) ).
*          LWORK >= MAX( 8*(N+1)+16, 2*SDIM*(N-SDIM) ).
*
*
*          If LWORK = -1, a workspace query is assumed.  The optimal
*          size for the WORK array is calculated and stored in WORK(1),
*          and no other work except argument checking is performed.
*
*  IWORK   (workspace) INTEGER array, dimension (LIWORK)
*  IWORK   (workspace) INTEGER array, dimension (LIWORK)
*          Not referenced if SENSE = 'N'.
*          Not referenced if SENSE = 'N'.
*
*
 Lines 227-232    Link Here 
*  =====================================================================
*  =====================================================================
*
*
*     .. Parameters ..
*     .. Parameters ..
      INTEGER            LQUERV
      PARAMETER          ( LQUERV = -1 )
      DOUBLE PRECISION   ZERO, ONE
      DOUBLE PRECISION   ZERO, ONE
      PARAMETER          ( ZERO = 0.0D+0, ONE = 1.0D+0 )
      PARAMETER          ( ZERO = 0.0D+0, ONE = 1.0D+0 )
*     ..
*     ..
 Lines 330-336    Link Here 
*       following subroutine, as returned by ILAENV.)
*       following subroutine, as returned by ILAENV.)
*
*
      MINWRK = 1
      MINWRK = 1
      IF( INFO.EQ.0 .AND. LWORK.GE.1 ) THEN
      IF( INFO.EQ.0 ) THEN
         MINWRK = 8*( N+1 ) + 16
         MINWRK = 8*( N+1 ) + 16
         MAXWRK = 7*( N+1 ) + N*ILAENV( 1, 'DGEQRF', ' ', N, 1, N, 0 ) +
         MAXWRK = 7*( N+1 ) + N*ILAENV( 1, 'DGEQRF', ' ', N, 1, N, 0 ) +
     $            16
     $            16
 Lines 338-344    Link Here 
            MAXWRK = MAX( MAXWRK, 8*( N+1 )+N*
            MAXWRK = MAX( MAXWRK, 8*( N+1 )+N*
     $               ILAENV( 1, 'DORGQR', ' ', N, 1, N, -1 )+16 )
     $               ILAENV( 1, 'DORGQR', ' ', N, 1, N, -1 )+16 )
         END IF
         END IF
*
*        Estimate the workspace needed by DTGSEN.
*
         IF( WANTST ) THEN
            MAXWRK = MAX( MAXWRK, 2*N+( N*N+1 ) / 2 )
         END IF
         WORK( 1 ) = MAXWRK
         WORK( 1 ) = MAXWRK
         IF( LWORK.LT.MINWRK .AND. LWORK.NE.LQUERV )
     $      INFO = -22
      END IF
      END IF
      IF( .NOT.WANTSN ) THEN
      IF( .NOT.WANTSN ) THEN
         LIWMIN = 1
         LIWMIN = 1
 Lines 346-366    Link Here 
         LIWMIN = N + 6
         LIWMIN = N + 6
      END IF
      END IF
      IWORK( 1 ) = LIWMIN
      IWORK( 1 ) = LIWMIN
*
      IF( INFO.EQ.0 .AND. IJOB.GE.1 ) THEN
      IF( INFO.EQ.0 .AND. LWORK.LT.MINWRK ) THEN
         INFO = -22
      ELSE IF( INFO.EQ.0 .AND. IJOB.GE.1 ) THEN
         IF( LIWORK.LT.LIWMIN )
         IF( LIWORK.LT.LIWMIN )
     $      INFO = -24
     $      INFO = -24
      END IF
      END IF
*
*
*     Quick returns
*
      IF( INFO.NE.0 ) THEN
      IF( INFO.NE.0 ) THEN
         CALL XERBLA( 'DGGESX', -INFO )
         CALL XERBLA( 'DGGESX', -INFO )
         RETURN
         RETURN
      END IF
      END IF
*
      IF( LWORK.EQ.LQUERV )
*     Quick return if possible
     $   RETURN
*
      IF( N.EQ.0 ) THEN
      IF( N.EQ.0 ) THEN
         SDIM = 0
         SDIM = 0
         RETURN
         RETURN
(-) LAPACK/SRC/dggev.f (-16 / +16 lines)
 Lines 5-10    Link Here 
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Courant Institute, Argonne National Lab, and Rice University
*     Courant Institute, Argonne National Lab, and Rice University
*     June 30, 1999
*     June 30, 1999
*     8-15-00:  Improve consistency of WS calculations (eca)
*
*
*     .. Scalar Arguments ..
*     .. Scalar Arguments ..
      CHARACTER          JOBVL, JOBVR
      CHARACTER          JOBVL, JOBVR
 Lines 123-132    Link Here 
*          The dimension of the array WORK.  LWORK >= max(1,8*N).
*          The dimension of the array WORK.  LWORK >= max(1,8*N).
*          For good performance, LWORK must generally be larger.
*          For good performance, LWORK must generally be larger.
*
*
*          If LWORK = -1, then a workspace query is assumed; the routine
*          If LWORK = -1, a workspace query is assumed.  The optimal
*          only calculates the optimal size of the WORK array, returns
*          size for the WORK array is calculated and stored in WORK(1),
*          this value as the first entry of the WORK array, and no error
*          and no other work except argument checking is performed.
*          message related to LWORK is issued by XERBLA.
*
*
*  INFO    (output) INTEGER
*  INFO    (output) INTEGER
*          = 0:  successful exit
*          = 0:  successful exit
 Lines 141-151    Link Here 
*  =====================================================================
*  =====================================================================
*
*
*     .. Parameters ..
*     .. Parameters ..
      INTEGER            LQUERV
      PARAMETER          ( LQUERV = -1 )
      DOUBLE PRECISION   ZERO, ONE
      DOUBLE PRECISION   ZERO, ONE
      PARAMETER          ( ZERO = 0.0D+0, ONE = 1.0D+0 )
      PARAMETER          ( ZERO = 0.0D+0, ONE = 1.0D+0 )
*     ..
*     ..
*     .. Local Scalars ..
*     .. Local Scalars ..
      LOGICAL            ILASCL, ILBSCL, ILV, ILVL, ILVR, LQUERY
      LOGICAL            ILASCL, ILBSCL, ILV, ILVL, ILVR
      CHARACTER          CHTEMP
      CHARACTER          CHTEMP
      INTEGER            ICOLS, IERR, IHI, IJOBVL, IJOBVR, ILEFT, ILO,
      INTEGER            ICOLS, IERR, IHI, IJOBVL, IJOBVR, ILEFT, ILO,
     $                   IN, IRIGHT, IROWS, ITAU, IWRK, JC, JR, MAXWRK,
     $                   IN, IRIGHT, IROWS, ITAU, IWRK, JC, JR, MAXWRK,
 Lines 157-164    Link Here 
      LOGICAL            LDUMMA( 1 )
      LOGICAL            LDUMMA( 1 )
*     ..
*     ..
*     .. External Subroutines ..
*     .. External Subroutines ..
      EXTERNAL           DGEQRF, DGGBAK, DGGBAL, DGGHRD, DHGEQZ, DLACPY,
      EXTERNAL           DGEQRF, DGGBAK, DGGBAL, DGGHRD, DHGEQZ, DLABAD,
     $                   DLASCL, DLASET, DORGQR, DORMQR, DTGEVC, XERBLA
     $                   DLACPY, DLASCL, DLASET, DORGQR, DORMQR, DTGEVC,
     $                   XERBLA
*     ..
*     ..
*     .. External Functions ..
*     .. External Functions ..
      LOGICAL            LSAME
      LOGICAL            LSAME
 Lines 199-205    Link Here 
*     Test the input arguments
*     Test the input arguments
*
*
      INFO = 0
      INFO = 0
      LQUERY = ( LWORK.EQ.-1 )
      IF( IJOBVL.LE.0 ) THEN
      IF( IJOBVL.LE.0 ) THEN
         INFO = -1
         INFO = -1
      ELSE IF( IJOBVR.LE.0 ) THEN
      ELSE IF( IJOBVR.LE.0 ) THEN
 Lines 225-248    Link Here 
*       computed assuming ILO = 1 and IHI = N, the worst case.)
*       computed assuming ILO = 1 and IHI = N, the worst case.)
*
*
      MINWRK = 1
      MINWRK = 1
      IF( INFO.EQ.0 .AND. ( LWORK.GE.1 .OR. LQUERY ) ) THEN
      IF( INFO.EQ.0 ) THEN
         MAXWRK = 7*N + N*ILAENV( 1, 'DGEQRF', ' ', N, 1, N, 0 )
         MAXWRK = 7*N + N*ILAENV( 1, 'DGEQRF', ' ', N, 1, N, 0 )
         MINWRK = MAX( 1, 8*N )
         MINWRK = MAX( 1, 8*N )
         WORK( 1 ) = MAXWRK
         WORK( 1 ) = MAXWRK
         IF( LWORK.LT.MINWRK .AND. LWORK.NE.LQUERV )
     $      INFO = -16
      END IF
      END IF
*
*
      IF( LWORK.LT.MINWRK .AND. .NOT.LQUERY )
*     Quick returns
     $   INFO = -16
*
*
      IF( INFO.NE.0 ) THEN
      IF( INFO.NE.0 ) THEN
         CALL XERBLA( 'DGGEV ', -INFO )
         CALL XERBLA( 'DGGEV ', -INFO )
         RETURN
         RETURN
      ELSE IF( LQUERY ) THEN
         RETURN
      END IF
      END IF
*
      IF( LWORK.EQ.LQUERV )
*     Quick return if possible
     $   RETURN
*
      IF( N.EQ.0 )
      IF( N.EQ.0 )
     $   RETURN
     $   RETURN
*
*
(-) LAPACK/SRC/dggevx.f (-20 / +17 lines)
 Lines 7-12    Link Here 
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Courant Institute, Argonne National Lab, and Rice University
*     Courant Institute, Argonne National Lab, and Rice University
*     June 30, 1999
*     June 30, 1999
*     8-15-00:  Improve consistency of WS calculations (eca)
*
*
*     .. Scalar Arguments ..
*     .. Scalar Arguments ..
      CHARACTER          BALANC, JOBVL, JOBVR, SENSE
      CHARACTER          BALANC, JOBVL, JOBVR, SENSE
 Lines 212-221    Link Here 
*          If SENSE = 'E', LWORK >= 12*N.
*          If SENSE = 'E', LWORK >= 12*N.
*          If SENSE = 'V' or 'B', LWORK >= 2*N*N+12*N+16.
*          If SENSE = 'V' or 'B', LWORK >= 2*N*N+12*N+16.
*
*
*          If LWORK = -1, then a workspace query is assumed; the routine
*          If LWORK = -1, a workspace query is assumed.  The optimal
*          only calculates the optimal size of the WORK array, returns
*          size for the WORK array is calculated and stored in WORK(1),
*          this value as the first entry of the WORK array, and no error
*          and no other work except argument checking is performed.
*          message related to LWORK is issued by XERBLA.
*
*
*  IWORK   (workspace) INTEGER array, dimension (N+6)
*  IWORK   (workspace) INTEGER array, dimension (N+6)
*          If SENSE = 'E', IWORK is not referenced.
*          If SENSE = 'E', IWORK is not referenced.
 Lines 262-273    Link Here 
*  =====================================================================
*  =====================================================================
*
*
*     .. Parameters ..
*     .. Parameters ..
      INTEGER            LQUERV
      PARAMETER          ( LQUERV = -1 )
      DOUBLE PRECISION   ZERO, ONE
      DOUBLE PRECISION   ZERO, ONE
      PARAMETER          ( ZERO = 0.0D+0, ONE = 1.0D+0 )
      PARAMETER          ( ZERO = 0.0D+0, ONE = 1.0D+0 )
*     ..
*     ..
*     .. Local Scalars ..
*     .. Local Scalars ..
      LOGICAL            ILASCL, ILBSCL, ILV, ILVL, ILVR, LQUERY, PAIR,
      LOGICAL            ILASCL, ILBSCL, ILV, ILVL, ILVR, PAIR, WANTSB,
     $                   WANTSB, WANTSE, WANTSN, WANTSV
     $                   WANTSE, WANTSN, WANTSV
      CHARACTER          CHTEMP
      CHARACTER          CHTEMP
      INTEGER            I, ICOLS, IERR, IJOBVL, IJOBVR, IN, IROWS,
      INTEGER            I, ICOLS, IERR, IJOBVL, IJOBVR, IN, IROWS,
     $                   ITAU, IWRK, IWRK1, J, JC, JR, M, MAXWRK,
     $                   ITAU, IWRK, IWRK1, J, JC, JR, M, MAXWRK,
 Lines 279-287    Link Here 
      LOGICAL            LDUMMA( 1 )
      LOGICAL            LDUMMA( 1 )
*     ..
*     ..
*     .. External Subroutines ..
*     .. External Subroutines ..
      EXTERNAL           DGEQRF, DGGBAK, DGGBAL, DGGHRD, DHGEQZ, DLACPY,
      EXTERNAL           DGEQRF, DGGBAK, DGGBAL, DGGHRD, DHGEQZ, DLABAD,
     $                   DLASCL, DLASET, DORGQR, DORMQR, DTGEVC, DTGSNA,
     $                   DLACPY, DLASCL, DLASET, DORGQR, DORMQR, DTGEVC,
     $                   XERBLA
     $                   DTGSNA, XERBLA
*     ..
*     ..
*     .. External Functions ..
*     .. External Functions ..
      LOGICAL            LSAME
      LOGICAL            LSAME
 Lines 327-333    Link Here 
*     Test the input arguments
*     Test the input arguments
*
*
      INFO = 0
      INFO = 0
      LQUERY = ( LWORK.EQ.-1 )
      IF( .NOT.( LSAME( BALANC, 'N' ) .OR. LSAME( BALANC,
      IF( .NOT.( LSAME( BALANC, 'N' ) .OR. LSAME( BALANC,
     $    'S' ) .OR. LSAME( BALANC, 'P' ) .OR. LSAME( BALANC, 'B' ) ) )
     $    'S' ) .OR. LSAME( BALANC, 'P' ) .OR. LSAME( BALANC, 'B' ) ) )
     $     THEN
     $     THEN
 Lines 360-366    Link Here 
*       computed assuming ILO = 1 and IHI = N, the worst case.)
*       computed assuming ILO = 1 and IHI = N, the worst case.)
*
*
      MINWRK = 1
      MINWRK = 1
      IF( INFO.EQ.0 .AND. ( LWORK.GE.1 .OR. LQUERY ) ) THEN
      IF( INFO.EQ.0 ) THEN
         MAXWRK = 5*N + N*ILAENV( 1, 'DGEQRF', ' ', N, 1, N, 0 )
         MAXWRK = 5*N + N*ILAENV( 1, 'DGEQRF', ' ', N, 1, N, 0 )
         MINWRK = MAX( 1, 6*N )
         MINWRK = MAX( 1, 6*N )
         IF( WANTSE ) THEN
         IF( WANTSE ) THEN
 Lines 370-393    Link Here 
            MAXWRK = MAX( MAXWRK, 2*N*N+12*N+16 )
            MAXWRK = MAX( MAXWRK, 2*N*N+12*N+16 )
         END IF
         END IF
         WORK( 1 ) = MAXWRK
         WORK( 1 ) = MAXWRK
         IF( LWORK.LT.MINWRK .AND. LWORK.NE.LQUERV )
     $      INFO = -26
      END IF
      END IF
*
*
      IF( LWORK.LT.MINWRK .AND. .NOT.LQUERY ) THEN
*     Quick returns
         INFO = -26
      END IF
*
*
      IF( INFO.NE.0 ) THEN
      IF( INFO.NE.0 ) THEN
         CALL XERBLA( 'DGGEVX', -INFO )
         CALL XERBLA( 'DGGEVX', -INFO )
         RETURN
         RETURN
      ELSE IF( LQUERY ) THEN
         RETURN
      END IF
      END IF
*
      IF( LWORK.EQ.LQUERV )
*     Quick return if possible
     $   RETURN
*
      IF( N.EQ.0 )
      IF( N.EQ.0 )
     $   RETURN
     $   RETURN
*
*
*
*     Get machine constants
*     Get machine constants
*
*
(-) LAPACK/SRC/dgghrd.f (-25 / +37 lines)
 Lines 4-10    Link Here 
*  -- LAPACK routine (version 3.0) --
*  -- LAPACK routine (version 3.0) --
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Courant Institute, Argonne National Lab, and Rice University
*     Courant Institute, Argonne National Lab, and Rice University
*     September 30, 1994
*     April 26, 2001
*
*
*     .. Scalar Arguments ..
*     .. Scalar Arguments ..
      CHARACTER          COMPQ, COMPZ
      CHARACTER          COMPQ, COMPZ
 Lines 20-35    Link Here 
*
*
*  DGGHRD reduces a pair of real matrices (A,B) to generalized upper
*  DGGHRD reduces a pair of real matrices (A,B) to generalized upper
*  Hessenberg form using orthogonal transformations, where A is a
*  Hessenberg form using orthogonal transformations, where A is a
*  general matrix and B is upper triangular:  Q' * A * Z = H and
*  general matrix and B is upper triangular.  The form of the
*  Q' * B * Z = T, where H is upper Hessenberg, T is upper triangular,
*  generalized eigenvalue problem is
*  and Q and Z are orthogonal, and ' means transpose.
*     A*x = lambda*B*x,
*  and B is typically made upper triangular by computing its QR
*  factorization and moving the orthogonal matrix Q to the left side
*  of the equation.
*
*  This subroutine simultaneously reduces A to a Hessenberg matrix H:
*     Q**T*A*Z = H
*  and transforms B to another upper triangular matrix T:
*     Q**T*B*Z = T
*  in order to reduce the problem to its standard form
*     H*y = lambda*T*y
*  where y = Z**T*x.
*
*
*  The orthogonal matrices Q and Z are determined as products of Givens
*  The orthogonal matrices Q and Z are determined as products of Givens
*  rotations.  They may either be formed explicitly, or they may be
*  rotations.  They may either be formed explicitly, or they may be
*  postmultiplied into input matrices Q1 and Z1, so that
*  postmultiplied into input matrices Q1 and Z1, so that
*
*
*       Q1 * A * Z1' = (Q1*Q) * H * (Z1*Z)'
*       Q1 * A * Z1**T = (Q1*Q) * H * (Z1*Z)**T
*       Q1 * B * Z1' = (Q1*Q) * T * (Z1*Z)'
*
*       Q1 * B * Z1**T = (Q1*Q) * T * (Z1*Z)**T
*
*  If Q1 is the orthogonal matrix from the QR factorization of B in the
*  original equation A*x = lambda*B*x, then DGGHRD reduces the original
*  problem to generalized Hessenberg form.
*
*
*  Arguments
*  Arguments
*  =========
*  =========
 Lines 53-62    Link Here 
*
*
*  ILO     (input) INTEGER
*  ILO     (input) INTEGER
*  IHI     (input) INTEGER
*  IHI     (input) INTEGER
*          It is assumed that A is already upper triangular in rows and
*          ILO and IHI mark the rows and columns of A which are to be
*          columns 1:ILO-1 and IHI+1:N.  ILO and IHI are normally set
*          reduced.  It is assumed that A is already upper triangular
*          by a previous call to DGGBAL; otherwise they should be set
*          in rows and columns 1:ILO-1 and IHI+1:N.  ILO and IHI are
*          to 1 and N respectively.
*          normally set by a previous call to SGGBAL; otherwise they
*          should be set to 1 and N respectively.
*          1 <= ILO <= IHI <= N, if N > 0; ILO=1 and IHI=0, if N=0.
*          1 <= ILO <= IHI <= N, if N > 0; ILO=1 and IHI=0, if N=0.
*
*
*  A       (input/output) DOUBLE PRECISION array, dimension (LDA, N)
*  A       (input/output) DOUBLE PRECISION array, dimension (LDA, N)
 Lines 70-102    Link Here 
*
*
*  B       (input/output) DOUBLE PRECISION array, dimension (LDB, N)
*  B       (input/output) DOUBLE PRECISION array, dimension (LDB, N)
*          On entry, the N-by-N upper triangular matrix B.
*          On entry, the N-by-N upper triangular matrix B.
*          On exit, the upper triangular matrix T = Q' B Z.  The
*          On exit, the upper triangular matrix T = Q**T B Z.  The
*          elements below the diagonal are set to zero.
*          elements below the diagonal are set to zero.
*
*
*  LDB     (input) INTEGER
*  LDB     (input) INTEGER
*          The leading dimension of the array B.  LDB >= max(1,N).
*          The leading dimension of the array B.  LDB >= max(1,N).
*
*
*  Q       (input/output) DOUBLE PRECISION array, dimension (LDQ, N)
*  Q       (input/output) DOUBLE PRECISION array, dimension (LDQ, N)
*          If COMPQ='N':  Q is not referenced.
*          On entry, if COMPQ = 'V', the orthogonal matrix Q1,
*          If COMPQ='I':  on entry, Q need not be set, and on exit it
*          typically from the QR factorization of B.
*                         contains the orthogonal matrix Q, where Q'
*          On exit, if COMPQ='I', the orthogonal matrix Q, and if
*                         is the product of the Givens transformations
*          COMPQ = 'V', the product Q1*Q.
*                         which are applied to A and B on the left.
*          Not referenced if COMPQ='N'.
*          If COMPQ='V':  on entry, Q must contain an orthogonal matrix
*                         Q1, and on exit this is overwritten by Q1*Q.
*
*
*  LDQ     (input) INTEGER
*  LDQ     (input) INTEGER
*          The leading dimension of the array Q.
*          The leading dimension of the array Q.
*          LDQ >= N if COMPQ='V' or 'I'; LDQ >= 1 otherwise.
*          LDQ >= N if COMPQ='V' or 'I'; LDQ >= 1 otherwise.
*
*
*  Z       (input/output) DOUBLE PRECISION array, dimension (LDZ, N)
*  Z       (input/output) DOUBLE PRECISION array, dimension (LDZ, N)
*          If COMPZ='N':  Z is not referenced.
*          On entry, if COMPZ = 'V', the orthogonal matrix Z1.
*          If COMPZ='I':  on entry, Z need not be set, and on exit it
*          On exit, if COMPZ='I', the orthogonal matrix Z, and if
*                         contains the orthogonal matrix Z, which is
*          COMPZ = 'V', the product Z1*Z.
*                         the product of the Givens transformations
*          Not referenced if COMPZ='N'.
*                         which are applied to A and B on the right.
*          If COMPZ='V':  on entry, Z must contain an orthogonal matrix
*                         Z1, and on exit this is overwritten by Z1*Z.
*
*
*  LDZ     (input) INTEGER
*  LDZ     (input) INTEGER
*          The leading dimension of the array Z.
*          The leading dimension of the array Z.
(-) LAPACK/SRC/dhgeqz.f (-351 / +353 lines)
 Lines 1-56    Link Here 
      SUBROUTINE DHGEQZ( JOB, COMPQ, COMPZ, N, ILO, IHI, A, LDA, B, LDB,
      SUBROUTINE DHGEQZ( JOB, COMPQ, COMPZ, N, ILO, IHI, H, LDH, T, LDT,
     $                   ALPHAR, ALPHAI, BETA, Q, LDQ, Z, LDZ, WORK,
     $                   ALPHAR, ALPHAI, BETA, Q, LDQ, Z, LDZ, WORK,
     $                   LWORK, INFO )
     $                   LWORK, INFO )
*
*
*  -- LAPACK routine (version 3.0) --
*  -- LAPACK routine (version 3.0) --
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Courant Institute, Argonne National Lab, and Rice University
*     Courant Institute, Argonne National Lab, and Rice University
*     June 30, 1999
*     May 3, 2001 
*
*
*     .. Scalar Arguments ..
*     .. Scalar Arguments ..
      CHARACTER          COMPQ, COMPZ, JOB
      CHARACTER          COMPQ, COMPZ, JOB
      INTEGER            IHI, ILO, INFO, LDA, LDB, LDQ, LDZ, LWORK, N
      INTEGER            IHI, ILO, INFO, LDH, LDQ, LDT, LDZ, LWORK, N
*     ..
*     ..
*     .. Array Arguments ..
*     .. Array Arguments ..
      DOUBLE PRECISION   A( LDA, * ), ALPHAI( * ), ALPHAR( * ),
      DOUBLE PRECISION   ALPHAI( * ), ALPHAR( * ), BETA( * ),
     $                   B( LDB, * ), BETA( * ), Q( LDQ, * ), WORK( * ),
     $                   H( LDH, * ), Q( LDQ, * ), T( LDT, * ),
     $                   Z( LDZ, * )
     $                   WORK( * ), Z( LDZ, * )
*     ..
*     ..
*
*
*  Purpose
*  Purpose
*  =======
*  =======
*
*
*  DHGEQZ implements a single-/double-shift version of the QZ method for
*  DHGEQZ computes the eigenvalues of a real matrix pair (H,T),
*  finding the generalized eigenvalues
*  where H is an upper Hessenberg matrix and T is upper triangular,
*
*  using the double-shift QZ method.
*  w(j)=(ALPHAR(j) + i*ALPHAI(j))/BETAR(j)   of the equation
*  Matrix pairs of this type are produced by the reduction to
*
*  generalized upper Hessenberg form of a real matrix pair (A,B):
*       det( A - w(i) B ) = 0
*
*
*     A = Q1*H*Z1**T,  B = Q1*T*Z1**T,
*  In addition, the pair A,B may be reduced to generalized Schur form:
*
*  B is upper triangular, and A is block upper triangular, where the
*  as computed by DGGHRD.
*  diagonal blocks are either 1-by-1 or 2-by-2, the 2-by-2 blocks having
*
*  complex generalized eigenvalues (see the description of the argument
*  If JOB='S', then the Hessenberg-triangular pair (H,T) is
*  JOB.)
*  also reduced to generalized Schur form,
*
*  
*  If JOB='S', then the pair (A,B) is simultaneously reduced to Schur
*     H = Q*S*Z**T,  T = Q*P*Z**T,
*  form by applying one orthogonal tranformation (usually called Q) on
*  
*  the left and another (usually called Z) on the right.  The 2-by-2
*  where Q and Z are orthogonal matrices, P is an upper triangular
*  upper-triangular diagonal blocks of B corresponding to 2-by-2 blocks
*  matrix, and S is a quasi-triangular matrix with 1-by-1 and 2-by-2
*  of A will be reduced to positive diagonal matrices.  (I.e.,
*  diagonal blocks.
*  if A(j+1,j) is non-zero, then B(j+1,j)=B(j,j+1)=0 and B(j,j) and
*
*  B(j+1,j+1) will be positive.)
*  The 1-by-1 blocks correspond to real eigenvalues of the matrix pair
*
*  (H,T) and the 2-by-2 blocks correspond to complex conjugate pairs of
*  If JOB='E', then at each iteration, the same transformations
*  eigenvalues.
*  are computed, but they are only applied to those parts of A and B
*
*  which are needed to compute ALPHAR, ALPHAI, and BETAR.
*  Additionally, the 2-by-2 upper triangular diagonal blocks of P
*
*  corresponding to 2-by-2 blocks of S are reduced to positive diagonal
*  If JOB='S' and COMPQ and COMPZ are 'V' or 'I', then the orthogonal
*  form, i.e., if S(j+1,j) is non-zero, then P(j+1,j) = P(j,j+1) = 0,
*  transformations used to reduce (A,B) are accumulated into the arrays
*  P(j,j) > 0, and P(j+1,j+1) > 0.
*  Q and Z s.t.:
*
*
*  Optionally, the orthogonal matrix Q from the generalized Schur
*       Q(in) A(in) Z(in)* = Q(out) A(out) Z(out)*
*  factorization may be postmultiplied into an input matrix Q1, and the
*       Q(in) B(in) Z(in)* = Q(out) B(out) Z(out)*
*  orthogonal matrix Z may be postmultiplied into an input matrix Z1.
*  If Q1 and Z1 are the orthogonal matrices from DGGHRD that reduced
*  the matrix pair (A,B) to generalized upper Hessenberg form, then the
*  output matrices Q1*Q and Z1*Z are the orthogonal factors from the
*  generalized Schur factorization of (A,B):
*
*     A = (Q1*Q)*S*(Z1*Z)**T,  B = (Q1*Q)*P*(Z1*Z)**T.
*  
*  To avoid overflow, eigenvalues of the matrix pair (H,T) (equivalently,
*  of (A,B)) are computed as a pair of values (alpha,beta), where alpha is
*  complex and beta real.
*  If beta is nonzero, lambda = alpha / beta is an eigenvalue of the
*  generalized nonsymmetric eigenvalue problem (GNEP)
*     A*x = lambda*B*x
*  and if alpha is nonzero, mu = beta / alpha is an eigenvalue of the
*  alternate form of the GNEP
*     mu*A*y = B*y.
*  Real eigenvalues can be read directly from the generalized Schur
*  form: 
*    alpha = S(i,i), beta = P(i,i).
*
*
*  Ref: C.B. Moler & G.W. Stewart, "An Algorithm for Generalized Matrix
*  Ref: C.B. Moler & G.W. Stewart, "An Algorithm for Generalized Matrix
*       Eigenvalue Problems", SIAM J. Numer. Anal., 10(1973),
*       Eigenvalue Problems", SIAM J. Numer. Anal., 10(1973),
 Lines 60-173    Link Here 
*  =========
*  =========
*
*
*  JOB     (input) CHARACTER*1
*  JOB     (input) CHARACTER*1
*          = 'E': compute only ALPHAR, ALPHAI, and BETA.  A and B will
*          = 'E': Compute eigenvalues only;
*                 not necessarily be put into generalized Schur form.
*          = 'S': Compute eigenvalues and the Schur form. 
*          = 'S': put A and B into generalized Schur form, as well
*                 as computing ALPHAR, ALPHAI, and BETA.
*
*
*  COMPQ   (input) CHARACTER*1
*  COMPQ   (input) CHARACTER*1
*          = 'N': do not modify Q.
*          = 'N': Left Schur vectors (Q) are not computed;
*          = 'V': multiply the array Q on the right by the transpose of
*          = 'I': Q is initialized to the unit matrix and the matrix Q
*                 the orthogonal tranformation that is applied to the
*                 of left Schur vectors of (H,T) is returned;
*                 left side of A and B to reduce them to Schur form.
*          = 'V': Q must contain an orthogonal matrix Q1 on entry and
*          = 'I': like COMPQ='V', except that Q will be initialized to
*                 the product Q1*Q is returned.
*                 the identity first.
*
*
*  COMPZ   (input) CHARACTER*1
*  COMPZ   (input) CHARACTER*1
*          = 'N': do not modify Z.
*          = 'N': Right Schur vectors (Z) are not computed;
*          = 'V': multiply the array Z on the right by the orthogonal
*          = 'I': Z is initialized to the unit matrix and the matrix Z
*                 tranformation that is applied to the right side of
*                 of right Schur vectors of (H,T) is returned;
*                 A and B to reduce them to Schur form.
*          = 'V': Z must contain an orthogonal matrix Z1 on entry and
*          = 'I': like COMPZ='V', except that Z will be initialized to
*                 the product Z1*Z is returned.
*                 the identity first.
*
*
*  N       (input) INTEGER
*  N       (input) INTEGER
*          The order of the matrices A, B, Q, and Z.  N >= 0.
*          The order of the matrices H, T, Q, and Z.  N >= 0.
*
*
*  ILO     (input) INTEGER
*  ILO     (input) INTEGER
*  IHI     (input) INTEGER
*  IHI     (input) INTEGER
*          It is assumed that A is already upper triangular in rows and
*          ILO and IHI mark the rows and columns of H which are in
*          columns 1:ILO-1 and IHI+1:N.
*          Hessenberg form.  It is assumed that A is already upper
*          1 <= ILO <= IHI <= N, if N > 0; ILO=1 and IHI=0, if N=0.
*          triangular in rows and columns 1:ILO-1 and IHI+1:N.
*
*          If N > 0, 1 <= ILO <= IHI <= N; if N = 0, ILO=1 and IHI=0.
*  A       (input/output) DOUBLE PRECISION array, dimension (LDA, N)
*
*          On entry, the N-by-N upper Hessenberg matrix A.  Elements
*  H       (input/output) DOUBLE PRECISION array, dimension (LDH, N)
*          below the subdiagonal must be zero.
*          On entry, the N-by-N upper Hessenberg matrix H.
*          If JOB='S', then on exit A and B will have been
*          On exit, if JOB = 'S', H contains the upper quasi-triangular
*             simultaneously reduced to generalized Schur form.
*          matrix S from the generalized Schur factorization;
*          If JOB='E', then on exit A will have been destroyed.
*          2-by-2 diagonal blocks (corresponding to complex conjugate
*             The diagonal blocks will be correct, but the off-diagonal
*          pairs of eigenvalues) are returned in standard form, with
*             portion will be meaningless.
*          H(i,i) = H(i+1,i+1) and H(i+1,i)*H(i,i+1) < 0.
*
*          If JOB = 'E', the diagonal blocks of H match those of S, but
*  LDA     (input) INTEGER
*          the rest of H is unspecified.
*          The leading dimension of the array A.  LDA >= max( 1, N ).
*
*
*  LDH     (input) INTEGER
*  B       (input/output) DOUBLE PRECISION array, dimension (LDB, N)
*          The leading dimension of the array H.  LDH >= max( 1, N ).
*          On entry, the N-by-N upper triangular matrix B.  Elements
*
*          below the diagonal must be zero.  2-by-2 blocks in B
*  T       (input/output) DOUBLE PRECISION array, dimension (LDT, N)
*          corresponding to 2-by-2 blocks in A will be reduced to
*          On entry, the N-by-N upper triangular matrix T.
*          positive diagonal form.  (I.e., if A(j+1,j) is non-zero,
*          On exit, if JOB = 'S', T contains the upper triangular
*          then B(j+1,j)=B(j,j+1)=0 and B(j,j) and B(j+1,j+1) will be
*          matrix P from the generalized Schur factorization;
*          positive.)
*          2-by-2 diagonal blocks of P corresponding to 2-by-2 blocks of S
*          If JOB='S', then on exit A and B will have been
*          are reduced to positive diagonal form, i.e., if H(j+1,j) is
*             simultaneously reduced to Schur form.
*          non-zero, then T(j+1,j) = T(j,j+1) = 0, T(j,j) > 0, and
*          If JOB='E', then on exit B will have been destroyed.
*          T(j+1,j+1) > 0.
*             Elements corresponding to diagonal blocks of A will be
*          If JOB = 'E', the diagonal blocks of T match those of P, but
*             correct, but the off-diagonal portion will be meaningless.
*          the rest of T is unspecified.
*
*
*  LDB     (input) INTEGER
*  LDT     (input) INTEGER
*          The leading dimension of the array B.  LDB >= max( 1, N ).
*          The leading dimension of the array T.  LDT >= max( 1, N ).
*
*
*  ALPHAR  (output) DOUBLE PRECISION array, dimension (N)
*  ALPHAR  (output) DOUBLE PRECISION array, dimension (N)
*          ALPHAR(1:N) will be set to real parts of the diagonal
*          The real parts of each scalar alpha defining an eigenvalue
*          elements of A that would result from reducing A and B to
*          of GNEP.
*          Schur form and then further reducing them both to triangular
*          form using unitary transformations s.t. the diagonal of B
*          was non-negative real.  Thus, if A(j,j) is in a 1-by-1 block
*          (i.e., A(j+1,j)=A(j,j+1)=0), then ALPHAR(j)=A(j,j).
*          Note that the (real or complex) values
*          (ALPHAR(j) + i*ALPHAI(j))/BETA(j), j=1,...,N, are the
*          generalized eigenvalues of the matrix pencil A - wB.
*
*
*  ALPHAI  (output) DOUBLE PRECISION array, dimension (N)
*  ALPHAI  (output) DOUBLE PRECISION array, dimension (N)
*          ALPHAI(1:N) will be set to imaginary parts of the diagonal
*          The imaginary parts of each scalar alpha defining an
*          elements of A that would result from reducing A and B to
*          eigenvalue of GNEP.
*          Schur form and then further reducing them both to triangular
*          If ALPHAI(j) is zero, then the j-th eigenvalue is real; if
*          form using unitary transformations s.t. the diagonal of B
*          positive, then the j-th and (j+1)-st eigenvalues are a
*          was non-negative real.  Thus, if A(j,j) is in a 1-by-1 block
*          complex conjugate pair, with ALPHAI(j+1) = -ALPHAI(j).
*          (i.e., A(j+1,j)=A(j,j+1)=0), then ALPHAR(j)=0.
*          Note that the (real or complex) values
*          (ALPHAR(j) + i*ALPHAI(j))/BETA(j), j=1,...,N, are the
*          generalized eigenvalues of the matrix pencil A - wB.
*
*
*  BETA    (output) DOUBLE PRECISION array, dimension (N)
*  BETA    (output) DOUBLE PRECISION array, dimension (N)
*          BETA(1:N) will be set to the (real) diagonal elements of B
*          The scalars beta that define the eigenvalues of GNEP.
*          that would result from reducing A and B to Schur form and
*          Together, the quantities alpha = (ALPHAR(j),ALPHAI(j)) and
*          then further reducing them both to triangular form using
*          beta = BETA(j) represent the j-th eigenvalue of the matrix
*          unitary transformations s.t. the diagonal of B was
*          pair (A,B), in one of the forms lambda = alpha/beta or
*          non-negative real.  Thus, if A(j,j) is in a 1-by-1 block
*          mu = beta/alpha.  Since either lambda or mu may overflow,
*          (i.e., A(j+1,j)=A(j,j+1)=0), then BETA(j)=B(j,j).
*          they should not, in general, be computed.
*          Note that the (real or complex) values
*          (ALPHAR(j) + i*ALPHAI(j))/BETA(j), j=1,...,N, are the
*          generalized eigenvalues of the matrix pencil A - wB.
*          (Note that BETA(1:N) will always be non-negative, and no
*          BETAI is necessary.)
*
*
*  Q       (input/output) DOUBLE PRECISION array, dimension (LDQ, N)
*  Q       (input/output) DOUBLE PRECISION array, dimension (LDQ, N)
*          If COMPQ='N', then Q will not be referenced.
*          On entry, if COMPZ = 'V', the orthogonal matrix Q1 used in
*          If COMPQ='V' or 'I', then the transpose of the orthogonal
*          the reduction of (A,B) to generalized Hessenberg form.
*             transformations which are applied to A and B on the left
*          On exit, if COMPZ = 'I', the orthogonal matrix of left Schur
*             will be applied to the array Q on the right.
*          vectors of (H,T), and if COMPZ = 'V', the orthogonal matrix
*          of left Schur vectors of (A,B).
*          Not referenced if COMPZ = 'N'.
*
*
*  LDQ     (input) INTEGER
*  LDQ     (input) INTEGER
*          The leading dimension of the array Q.  LDQ >= 1.
*          The leading dimension of the array Q.  LDQ >= 1.
*          If COMPQ='V' or 'I', then LDQ >= N.
*          If COMPQ='V' or 'I', then LDQ >= N.
*
*
*  Z       (input/output) DOUBLE PRECISION array, dimension (LDZ, N)
*  Z       (input/output) DOUBLE PRECISION array, dimension (LDZ, N)
*          If COMPZ='N', then Z will not be referenced.
*          On entry, if COMPZ = 'V', the orthogonal matrix Z1 used in
*          If COMPZ='V' or 'I', then the orthogonal transformations
*          the reduction of (A,B) to generalized Hessenberg form.
*             which are applied to A and B on the right will be applied
*          On exit, if COMPZ = 'I', the orthogonal matrix of
*             to the array Z on the right.
*          right Schur vectors of (H,T), and if COMPZ = 'V', the
*          orthogonal matrix of right Schur vectors of (A,B).
*          Not referenced if COMPZ = 'N'.
*
*
*  LDZ     (input) INTEGER
*  LDZ     (input) INTEGER
*          The leading dimension of the array Z.  LDZ >= 1.
*          The leading dimension of the array Z.  LDZ >= 1.
 Lines 187-199    Link Here 
*  INFO    (output) INTEGER
*  INFO    (output) INTEGER
*          = 0: successful exit
*          = 0: successful exit
*          < 0: if INFO = -i, the i-th argument had an illegal value
*          < 0: if INFO = -i, the i-th argument had an illegal value
*          = 1,...,N: the QZ iteration did not converge.  (A,B) is not
*          = 1,...,N: the QZ iteration did not converge.  (H,T) is not
*                     in Schur form, but ALPHAR(i), ALPHAI(i), and
*                     in Schur form, but ALPHAR(i), ALPHAI(i), and
*                     BETA(i), i=INFO+1,...,N should be correct.
*                     BETA(i), i=INFO+1,...,N should be correct.
*          = N+1,...,2*N: the shift calculation failed.  (A,B) is not
*          = N+1,...,2*N: the shift calculation failed.  (H,T) is not
*                     in Schur form, but ALPHAR(i), ALPHAI(i), and
*                     in Schur form, but ALPHAR(i), ALPHAI(i), and
*                     BETA(i), i=INFO-N+1,...,N should be correct.
*                     BETA(i), i=INFO-N+1,...,N should be correct.
*          > 2*N:     various "impossible" errors.
*
*
*  Further Details
*  Further Details
*  ===============
*  ===============
 Lines 225-231    Link Here 
     $                   B1R, B22, B2A, B2I, B2R, BN, BNORM, BSCALE,
     $                   B1R, B22, B2A, B2I, B2R, BN, BNORM, BSCALE,
     $                   BTOL, C, C11I, C11R, C12, C21, C22I, C22R, CL,
     $                   BTOL, C, C11I, C11R, C12, C21, C22I, C22R, CL,
     $                   CQ, CR, CZ, ESHIFT, S, S1, S1INV, S2, SAFMAX,
     $                   CQ, CR, CZ, ESHIFT, S, S1, S1INV, S2, SAFMAX,
     $                   SAFMIN, SCALE, SL, SQI, SQR, SR, SZI, SZR, T,
     $                   SAFMIN, SCALE, SL, SQI, SQR, SR, SZI, SZR, T1,
     $                   TAU, TEMP, TEMP2, TEMPI, TEMPR, U1, U12, U12L,
     $                   TAU, TEMP, TEMP2, TEMPI, TEMPR, U1, U12, U12L,
     $                   U2, ULP, VS, W11, W12, W21, W22, WABS, WI, WR,
     $                   U2, ULP, VS, W11, W12, W21, W22, WABS, WI, WR,
     $                   WR2
     $                   WR2
 Lines 302-310    Link Here 
         INFO = -5
         INFO = -5
      ELSE IF( IHI.GT.N .OR. IHI.LT.ILO-1 ) THEN
      ELSE IF( IHI.GT.N .OR. IHI.LT.ILO-1 ) THEN
         INFO = -6
         INFO = -6
      ELSE IF( LDA.LT.N ) THEN
      ELSE IF( LDH.LT.N ) THEN
         INFO = -8
         INFO = -8
      ELSE IF( LDB.LT.N ) THEN
      ELSE IF( LDT.LT.N ) THEN
         INFO = -10
         INFO = -10
      ELSE IF( LDQ.LT.1 .OR. ( ILQ .AND. LDQ.LT.N ) ) THEN
      ELSE IF( LDQ.LT.1 .OR. ( ILQ .AND. LDQ.LT.N ) ) THEN
         INFO = -15
         INFO = -15
 Lines 340-347    Link Here 
      SAFMIN = DLAMCH( 'S' )
      SAFMIN = DLAMCH( 'S' )
      SAFMAX = ONE / SAFMIN
      SAFMAX = ONE / SAFMIN
      ULP = DLAMCH( 'E' )*DLAMCH( 'B' )
      ULP = DLAMCH( 'E' )*DLAMCH( 'B' )
      ANORM = DLANHS( 'F', IN, A( ILO, ILO ), LDA, WORK )
      ANORM = DLANHS( 'F', IN, H( ILO, ILO ), LDH, WORK )
      BNORM = DLANHS( 'F', IN, B( ILO, ILO ), LDB, WORK )
      BNORM = DLANHS( 'F', IN, T( ILO, ILO ), LDT, WORK )
      ATOL = MAX( SAFMIN, ULP*ANORM )
      ATOL = MAX( SAFMIN, ULP*ANORM )
      BTOL = MAX( SAFMIN, ULP*BNORM )
      BTOL = MAX( SAFMIN, ULP*BNORM )
      ASCALE = ONE / MAX( SAFMIN, ANORM )
      ASCALE = ONE / MAX( SAFMIN, ANORM )
 Lines 350-364    Link Here 
*     Set Eigenvalues IHI+1:N
*     Set Eigenvalues IHI+1:N
*
*
      DO 30 J = IHI + 1, N
      DO 30 J = IHI + 1, N
         IF( B( J, J ).LT.ZERO ) THEN
         IF( T( J, J ).LT.ZERO ) THEN
            IF( ILSCHR ) THEN
            IF( ILSCHR ) THEN
               DO 10 JR = 1, J
               DO 10 JR = 1, J
                  A( JR, J ) = -A( JR, J )
                  H( JR, J ) = -H( JR, J )
                  B( JR, J ) = -B( JR, J )
                  T( JR, J ) = -T( JR, J )
   10          CONTINUE
   10          CONTINUE
            ELSE
            ELSE
               A( J, J ) = -A( J, J )
               H( J, J ) = -H( J, J )
               B( J, J ) = -B( J, J )
               T( J, J ) = -T( J, J )
            END IF
            END IF
            IF( ILZ ) THEN
            IF( ILZ ) THEN
               DO 20 JR = 1, N
               DO 20 JR = 1, N
 Lines 366-374    Link Here 
   20          CONTINUE
   20          CONTINUE
            END IF
            END IF
         END IF
         END IF
         ALPHAR( J ) = A( J, J )
         ALPHAR( J ) = H( J, J )
         ALPHAI( J ) = ZERO
         ALPHAI( J ) = ZERO
         BETA( J ) = B( J, J )
         BETA( J ) = T( J, J )
   30 CONTINUE
   30 CONTINUE
*
*
*     If IHI < ILO, skip QZ steps
*     If IHI < ILO, skip QZ steps
 Lines 408-415    Link Here 
*        Split the matrix if possible.
*        Split the matrix if possible.
*
*
*        Two tests:
*        Two tests:
*           1: A(j,j-1)=0  or  j=ILO
*           1: H(j,j-1)=0  or  j=ILO
*           2: B(j,j)=0
*           2: T(j,j)=0
*
*
         IF( ILAST.EQ.ILO ) THEN
         IF( ILAST.EQ.ILO ) THEN
*
*
 Lines 417-430    Link Here 
*
*
            GO TO 80
            GO TO 80
         ELSE
         ELSE
            IF( ABS( A( ILAST, ILAST-1 ) ).LE.ATOL ) THEN
            IF( ABS( H( ILAST, ILAST-1 ) ).LE.ATOL ) THEN
               A( ILAST, ILAST-1 ) = ZERO
               H( ILAST, ILAST-1 ) = ZERO
               GO TO 80
               GO TO 80
            END IF
            END IF
         END IF
         END IF
*
*
         IF( ABS( B( ILAST, ILAST ) ).LE.BTOL ) THEN
         IF( ABS( T( ILAST, ILAST ) ).LE.BTOL ) THEN
            B( ILAST, ILAST ) = ZERO
            T( ILAST, ILAST ) = ZERO
            GO TO 70
            GO TO 70
         END IF
         END IF
*
*
 Lines 432-467    Link Here 
*
*
         DO 60 J = ILAST - 1, ILO, -1
         DO 60 J = ILAST - 1, ILO, -1
*
*
*           Test 1: for A(j,j-1)=0 or j=ILO
*           Test 1: for H(j,j-1)=0 or j=ILO
*
*
            IF( J.EQ.ILO ) THEN
            IF( J.EQ.ILO ) THEN
               ILAZRO = .TRUE.
               ILAZRO = .TRUE.
            ELSE
            ELSE
               IF( ABS( A( J, J-1 ) ).LE.ATOL ) THEN
               IF( ABS( H( J, J-1 ) ).LE.ATOL ) THEN
                  A( J, J-1 ) = ZERO
                  H( J, J-1 ) = ZERO
                  ILAZRO = .TRUE.
                  ILAZRO = .TRUE.
               ELSE
               ELSE
                  ILAZRO = .FALSE.
                  ILAZRO = .FALSE.
               END IF
               END IF
            END IF
            END IF
*
*
*           Test 2: for B(j,j)=0
*           Test 2: for T(j,j)=0
*
*
            IF( ABS( B( J, J ) ).LT.BTOL ) THEN
            IF( ABS( T( J, J ) ).LT.BTOL ) THEN
               B( J, J ) = ZERO
               T( J, J ) = ZERO
*
*
*              Test 1a: Check for 2 consecutive small subdiagonals in A
*              Test 1a: Check for 2 consecutive small subdiagonals in A
*
*
               ILAZR2 = .FALSE.
               ILAZR2 = .FALSE.
               IF( .NOT.ILAZRO ) THEN
               IF( .NOT.ILAZRO ) THEN
                  TEMP = ABS( A( J, J-1 ) )
                  TEMP = ABS( H( J, J-1 ) )
                  TEMP2 = ABS( A( J, J ) )
                  TEMP2 = ABS( H( J, J ) )
                  TEMPR = MAX( TEMP, TEMP2 )
                  TEMPR = MAX( TEMP, TEMP2 )
                  IF( TEMPR.LT.ONE .AND. TEMPR.NE.ZERO ) THEN
                  IF( TEMPR.LT.ONE .AND. TEMPR.NE.ZERO ) THEN
                     TEMP = TEMP / TEMPR
                     TEMP = TEMP / TEMPR
                     TEMP2 = TEMP2 / TEMPR
                     TEMP2 = TEMP2 / TEMPR
                  END IF
                  END IF
                  IF( TEMP*( ASCALE*ABS( A( J+1, J ) ) ).LE.TEMP2*
                  IF( TEMP*( ASCALE*ABS( H( J+1, J ) ) ).LE.TEMP2*
     $                ( ASCALE*ATOL ) )ILAZR2 = .TRUE.
     $                ( ASCALE*ATOL ) )ILAZR2 = .TRUE.
               END IF
               END IF
*
*
 Lines 473-493    Link Here 
*
*
               IF( ILAZRO .OR. ILAZR2 ) THEN
               IF( ILAZRO .OR. ILAZR2 ) THEN
                  DO 40 JCH = J, ILAST - 1
                  DO 40 JCH = J, ILAST - 1
                     TEMP = A( JCH, JCH )
                     TEMP = H( JCH, JCH )
                     CALL DLARTG( TEMP, A( JCH+1, JCH ), C, S,
                     CALL DLARTG( TEMP, H( JCH+1, JCH ), C, S,
     $                            A( JCH, JCH ) )
     $                            H( JCH, JCH ) )
                     A( JCH+1, JCH ) = ZERO
                     H( JCH+1, JCH ) = ZERO
                     CALL DROT( ILASTM-JCH, A( JCH, JCH+1 ), LDA,
                     CALL DROT( ILASTM-JCH, H( JCH, JCH+1 ), LDH,
     $                          A( JCH+1, JCH+1 ), LDA, C, S )
     $                          H( JCH+1, JCH+1 ), LDH, C, S )
                     CALL DROT( ILASTM-JCH, B( JCH, JCH+1 ), LDB,
                     CALL DROT( ILASTM-JCH, T( JCH, JCH+1 ), LDT,
     $                          B( JCH+1, JCH+1 ), LDB, C, S )
     $                          T( JCH+1, JCH+1 ), LDT, C, S )
                     IF( ILQ )
                     IF( ILQ )
     $                  CALL DROT( N, Q( 1, JCH ), 1, Q( 1, JCH+1 ), 1,
     $                  CALL DROT( N, Q( 1, JCH ), 1, Q( 1, JCH+1 ), 1,
     $                             C, S )
     $                             C, S )
                     IF( ILAZR2 )
                     IF( ILAZR2 )
     $                  A( JCH, JCH-1 ) = A( JCH, JCH-1 )*C
     $                  H( JCH, JCH-1 ) = H( JCH, JCH-1 )*C
                     ILAZR2 = .FALSE.
                     ILAZR2 = .FALSE.
                     IF( ABS( B( JCH+1, JCH+1 ) ).GE.BTOL ) THEN
                     IF( ABS( T( JCH+1, JCH+1 ) ).GE.BTOL ) THEN
                        IF( JCH+1.GE.ILAST ) THEN
                        IF( JCH+1.GE.ILAST ) THEN
                           GO TO 80
                           GO TO 80
                        ELSE
                        ELSE
 Lines 495-529    Link Here 
                           GO TO 110
                           GO TO 110
                        END IF
                        END IF
                     END IF
                     END IF
                     B( JCH+1, JCH+1 ) = ZERO
                     T( JCH+1, JCH+1 ) = ZERO
   40             CONTINUE
   40             CONTINUE
                  GO TO 70
                  GO TO 70
               ELSE
               ELSE
*
*
*                 Only test 2 passed -- chase the zero to B(ILAST,ILAST)
*                 Only test 2 passed -- chase the zero to T(ILAST,ILAST)
*                 Then process as in the case B(ILAST,ILAST)=0
*                 Then process as in the case T(ILAST,ILAST)=0
*
*
                  DO 50 JCH = J, ILAST - 1
                  DO 50 JCH = J, ILAST - 1
                     TEMP = B( JCH, JCH+1 )
                     TEMP = T( JCH, JCH+1 )
                     CALL DLARTG( TEMP, B( JCH+1, JCH+1 ), C, S,
                     CALL DLARTG( TEMP, T( JCH+1, JCH+1 ), C, S,
     $                            B( JCH, JCH+1 ) )
     $                            T( JCH, JCH+1 ) )
                     B( JCH+1, JCH+1 ) = ZERO
                     T( JCH+1, JCH+1 ) = ZERO
                     IF( JCH.LT.ILASTM-1 )
                     IF( JCH.LT.ILASTM-1 )
     $                  CALL DROT( ILASTM-JCH-1, B( JCH, JCH+2 ), LDB,
     $                  CALL DROT( ILASTM-JCH-1, T( JCH, JCH+2 ), LDT,
     $                             B( JCH+1, JCH+2 ), LDB, C, S )
     $                             T( JCH+1, JCH+2 ), LDT, C, S )
                     CALL DROT( ILASTM-JCH+2, A( JCH, JCH-1 ), LDA,
                     CALL DROT( ILASTM-JCH+2, H( JCH, JCH-1 ), LDH,
     $                          A( JCH+1, JCH-1 ), LDA, C, S )
     $                          H( JCH+1, JCH-1 ), LDH, C, S )
                     IF( ILQ )
                     IF( ILQ )
     $                  CALL DROT( N, Q( 1, JCH ), 1, Q( 1, JCH+1 ), 1,
     $                  CALL DROT( N, Q( 1, JCH ), 1, Q( 1, JCH+1 ), 1,
     $                             C, S )
     $                             C, S )
                     TEMP = A( JCH+1, JCH )
                     TEMP = H( JCH+1, JCH )
                     CALL DLARTG( TEMP, A( JCH+1, JCH-1 ), C, S,
                     CALL DLARTG( TEMP, H( JCH+1, JCH-1 ), C, S,
     $                            A( JCH+1, JCH ) )
     $                            H( JCH+1, JCH ) )
                     A( JCH+1, JCH-1 ) = ZERO
                     H( JCH+1, JCH-1 ) = ZERO
                     CALL DROT( JCH+1-IFRSTM, A( IFRSTM, JCH ), 1,
                     CALL DROT( JCH+1-IFRSTM, H( IFRSTM, JCH ), 1,
     $                          A( IFRSTM, JCH-1 ), 1, C, S )
     $                          H( IFRSTM, JCH-1 ), 1, C, S )
                     CALL DROT( JCH-IFRSTM, B( IFRSTM, JCH ), 1,
                     CALL DROT( JCH-IFRSTM, T( IFRSTM, JCH ), 1,
     $                          B( IFRSTM, JCH-1 ), 1, C, S )
     $                          T( IFRSTM, JCH-1 ), 1, C, S )
                     IF( ILZ )
                     IF( ILZ )
     $                  CALL DROT( N, Z( 1, JCH ), 1, Z( 1, JCH-1 ), 1,
     $                  CALL DROT( N, Z( 1, JCH ), 1, Z( 1, JCH-1 ), 1,
     $                             C, S )
     $                             C, S )
 Lines 547-580    Link Here 
         INFO = N + 1
         INFO = N + 1
         GO TO 420
         GO TO 420
*
*
*        B(ILAST,ILAST)=0 -- clear A(ILAST,ILAST-1) to split off a
*        T(ILAST,ILAST)=0 -- clear H(ILAST,ILAST-1) to split off a
*        1x1 block.
*        1x1 block.
*
*
   70    CONTINUE
   70    CONTINUE
         TEMP = A( ILAST, ILAST )
         TEMP = H( ILAST, ILAST )
         CALL DLARTG( TEMP, A( ILAST, ILAST-1 ), C, S,
         CALL DLARTG( TEMP, H( ILAST, ILAST-1 ), C, S,
     $                A( ILAST, ILAST ) )
     $                H( ILAST, ILAST ) )
         A( ILAST, ILAST-1 ) = ZERO
         H( ILAST, ILAST-1 ) = ZERO
         CALL DROT( ILAST-IFRSTM, A( IFRSTM, ILAST ), 1,
         CALL DROT( ILAST-IFRSTM, H( IFRSTM, ILAST ), 1,
     $              A( IFRSTM, ILAST-1 ), 1, C, S )
     $              H( IFRSTM, ILAST-1 ), 1, C, S )
         CALL DROT( ILAST-IFRSTM, B( IFRSTM, ILAST ), 1,
         CALL DROT( ILAST-IFRSTM, T( IFRSTM, ILAST ), 1,
     $              B( IFRSTM, ILAST-1 ), 1, C, S )
     $              T( IFRSTM, ILAST-1 ), 1, C, S )
         IF( ILZ )
         IF( ILZ )
     $      CALL DROT( N, Z( 1, ILAST ), 1, Z( 1, ILAST-1 ), 1, C, S )
     $      CALL DROT( N, Z( 1, ILAST ), 1, Z( 1, ILAST-1 ), 1, C, S )
*
*
*        A(ILAST,ILAST-1)=0 -- Standardize B, set ALPHAR, ALPHAI,
*        H(ILAST,ILAST-1)=0 -- Standardize B, set ALPHAR, ALPHAI,
*                              and BETA
*                              and BETA
*
*
   80    CONTINUE
   80    CONTINUE
         IF( B( ILAST, ILAST ).LT.ZERO ) THEN
         IF( T( ILAST, ILAST ).LT.ZERO ) THEN
            IF( ILSCHR ) THEN
            IF( ILSCHR ) THEN
               DO 90 J = IFRSTM, ILAST
               DO 90 J = IFRSTM, ILAST
                  A( J, ILAST ) = -A( J, ILAST )
                  H( J, ILAST ) = -H( J, ILAST )
                  B( J, ILAST ) = -B( J, ILAST )
                  T( J, ILAST ) = -T( J, ILAST )
   90          CONTINUE
   90          CONTINUE
            ELSE
            ELSE
               A( ILAST, ILAST ) = -A( ILAST, ILAST )
               H( ILAST, ILAST ) = -H( ILAST, ILAST )
               B( ILAST, ILAST ) = -B( ILAST, ILAST )
               T( ILAST, ILAST ) = -T( ILAST, ILAST )
            END IF
            END IF
            IF( ILZ ) THEN
            IF( ILZ ) THEN
               DO 100 J = 1, N
               DO 100 J = 1, N
 Lines 582-590    Link Here 
  100          CONTINUE
  100          CONTINUE
            END IF
            END IF
         END IF
         END IF
         ALPHAR( ILAST ) = A( ILAST, ILAST )
         ALPHAR( ILAST ) = H( ILAST, ILAST )
         ALPHAI( ILAST ) = ZERO
         ALPHAI( ILAST ) = ZERO
         BETA( ILAST ) = B( ILAST, ILAST )
         BETA( ILAST ) = T( ILAST, ILAST )
*
*
*        Go to next block -- exit if finished.
*        Go to next block -- exit if finished.
*
*
 Lines 617-623    Link Here 
*        Compute single shifts.
*        Compute single shifts.
*
*
*        At this point, IFIRST < ILAST, and the diagonal elements of
*        At this point, IFIRST < ILAST, and the diagonal elements of
*        B(IFIRST:ILAST,IFIRST,ILAST) are larger than BTOL (in
*        T(IFIRST:ILAST,IFIRST,ILAST) are larger than BTOL (in
*        magnitude)
*        magnitude)
*
*
         IF( ( IITER / 10 )*10.EQ.IITER ) THEN
         IF( ( IITER / 10 )*10.EQ.IITER ) THEN
 Lines 625-634    Link Here 
*           Exceptional shift.  Chosen for no particularly good reason.
*           Exceptional shift.  Chosen for no particularly good reason.
*           (Single shift only.)
*           (Single shift only.)
*
*
            IF( ( DBLE( MAXIT )*SAFMIN )*ABS( A( ILAST-1, ILAST ) ).LT.
            IF( ( DBLE( MAXIT )*SAFMIN )*ABS( H( ILAST-1, ILAST ) ).LT.
     $          ABS( B( ILAST-1, ILAST-1 ) ) ) THEN
     $          ABS( T( ILAST-1, ILAST-1 ) ) ) THEN
               ESHIFT = ESHIFT + A( ILAST-1, ILAST ) /
               ESHIFT = ESHIFT + H( ILAST-1, ILAST ) /
     $                  B( ILAST-1, ILAST-1 )
     $                  T( ILAST-1, ILAST-1 )
            ELSE
            ELSE
               ESHIFT = ESHIFT + ONE / ( SAFMIN*DBLE( MAXIT ) )
               ESHIFT = ESHIFT + ONE / ( SAFMIN*DBLE( MAXIT ) )
            END IF
            END IF
 Lines 641-648    Link Here 
*           bottom-right 2x2 block of A and B. The first eigenvalue
*           bottom-right 2x2 block of A and B. The first eigenvalue
*           returned by DLAG2 is the Wilkinson shift (AEP p.512),
*           returned by DLAG2 is the Wilkinson shift (AEP p.512),
*
*
            CALL DLAG2( A( ILAST-1, ILAST-1 ), LDA,
            CALL DLAG2( H( ILAST-1, ILAST-1 ), LDH,
     $                  B( ILAST-1, ILAST-1 ), LDB, SAFMIN*SAFETY, S1,
     $                  T( ILAST-1, ILAST-1 ), LDT, SAFMIN*SAFETY, S1,
     $                  S2, WR, WR2, WI )
     $                  S2, WR, WR2, WI )
*
*
            TEMP = MAX( S1, SAFMIN*MAX( ONE, ABS( WR ), ABS( WI ) ) )
            TEMP = MAX( S1, SAFMIN*MAX( ONE, ABS( WR ), ABS( WI ) ) )
 Lines 669-682    Link Here 
*
*
         DO 120 J = ILAST - 1, IFIRST + 1, -1
         DO 120 J = ILAST - 1, IFIRST + 1, -1
            ISTART = J
            ISTART = J
            TEMP = ABS( S1*A( J, J-1 ) )
            TEMP = ABS( S1*H( J, J-1 ) )
            TEMP2 = ABS( S1*A( J, J )-WR*B( J, J ) )
            TEMP2 = ABS( S1*H( J, J )-WR*T( J, J ) )
            TEMPR = MAX( TEMP, TEMP2 )
            TEMPR = MAX( TEMP, TEMP2 )
            IF( TEMPR.LT.ONE .AND. TEMPR.NE.ZERO ) THEN
            IF( TEMPR.LT.ONE .AND. TEMPR.NE.ZERO ) THEN
               TEMP = TEMP / TEMPR
               TEMP = TEMP / TEMPR
               TEMP2 = TEMP2 / TEMPR
               TEMP2 = TEMP2 / TEMPR
            END IF
            END IF
            IF( ABS( ( ASCALE*A( J+1, J ) )*TEMP ).LE.( ASCALE*ATOL )*
            IF( ABS( ( ASCALE*H( J+1, J ) )*TEMP ).LE.( ASCALE*ATOL )*
     $          TEMP2 )GO TO 130
     $          TEMP2 )GO TO 130
  120    CONTINUE
  120    CONTINUE
*
*
 Lines 687-712    Link Here 
*
*
*        Initial Q
*        Initial Q
*
*
         TEMP = S1*A( ISTART, ISTART ) - WR*B( ISTART, ISTART )
         TEMP = S1*H( ISTART, ISTART ) - WR*T( ISTART, ISTART )
         TEMP2 = S1*A( ISTART+1, ISTART )
         TEMP2 = S1*H( ISTART+1, ISTART )
         CALL DLARTG( TEMP, TEMP2, C, S, TEMPR )
         CALL DLARTG( TEMP, TEMP2, C, S, TEMPR )
*
*
*        Sweep
*        Sweep
*
*
         DO 190 J = ISTART, ILAST - 1
         DO 190 J = ISTART, ILAST - 1
            IF( J.GT.ISTART ) THEN
            IF( J.GT.ISTART ) THEN
               TEMP = A( J, J-1 )
               TEMP = H( J, J-1 )
               CALL DLARTG( TEMP, A( J+1, J-1 ), C, S, A( J, J-1 ) )
               CALL DLARTG( TEMP, H( J+1, J-1 ), C, S, H( J, J-1 ) )
               A( J+1, J-1 ) = ZERO
               H( J+1, J-1 ) = ZERO
            END IF
            END IF
*
*
            DO 140 JC = J, ILASTM
            DO 140 JC = J, ILASTM
               TEMP = C*A( J, JC ) + S*A( J+1, JC )
               TEMP = C*H( J, JC ) + S*H( J+1, JC )
               A( J+1, JC ) = -S*A( J, JC ) + C*A( J+1, JC )
               H( J+1, JC ) = -S*H( J, JC ) + C*H( J+1, JC )
               A( J, JC ) = TEMP
               H( J, JC ) = TEMP
               TEMP2 = C*B( J, JC ) + S*B( J+1, JC )
               TEMP2 = C*T( J, JC ) + S*T( J+1, JC )
               B( J+1, JC ) = -S*B( J, JC ) + C*B( J+1, JC )
               T( J+1, JC ) = -S*T( J, JC ) + C*T( J+1, JC )
               B( J, JC ) = TEMP2
               T( J, JC ) = TEMP2
  140       CONTINUE
  140       CONTINUE
            IF( ILQ ) THEN
            IF( ILQ ) THEN
               DO 150 JR = 1, N
               DO 150 JR = 1, N
 Lines 716-734    Link Here 
  150          CONTINUE
  150          CONTINUE
            END IF
            END IF
*
*
            TEMP = B( J+1, J+1 )
            TEMP = T( J+1, J+1 )
            CALL DLARTG( TEMP, B( J+1, J ), C, S, B( J+1, J+1 ) )
            CALL DLARTG( TEMP, T( J+1, J ), C, S, T( J+1, J+1 ) )
            B( J+1, J ) = ZERO
            T( J+1, J ) = ZERO
*
*
            DO 160 JR = IFRSTM, MIN( J+2, ILAST )
            DO 160 JR = IFRSTM, MIN( J+2, ILAST )
               TEMP = C*A( JR, J+1 ) + S*A( JR, J )
               TEMP = C*H( JR, J+1 ) + S*H( JR, J )
               A( JR, J ) = -S*A( JR, J+1 ) + C*A( JR, J )
               H( JR, J ) = -S*H( JR, J+1 ) + C*H( JR, J )
               A( JR, J+1 ) = TEMP
               H( JR, J+1 ) = TEMP
  160       CONTINUE
  160       CONTINUE
            DO 170 JR = IFRSTM, J
            DO 170 JR = IFRSTM, J
               TEMP = C*B( JR, J+1 ) + S*B( JR, J )
               TEMP = C*T( JR, J+1 ) + S*T( JR, J )
               B( JR, J ) = -S*B( JR, J+1 ) + C*B( JR, J )
               T( JR, J ) = -S*T( JR, J+1 ) + C*T( JR, J )
               B( JR, J+1 ) = TEMP
               T( JR, J+1 ) = TEMP
  170       CONTINUE
  170       CONTINUE
            IF( ILZ ) THEN
            IF( ILZ ) THEN
               DO 180 JR = 1, N
               DO 180 JR = 1, N
 Lines 759-766    Link Here 
*                   B = (         )  with B11 non-negative.
*                   B = (         )  with B11 non-negative.
*                       (  0  B22 )
*                       (  0  B22 )
*
*
            CALL DLASV2( B( ILAST-1, ILAST-1 ), B( ILAST-1, ILAST ),
            CALL DLASV2( T( ILAST-1, ILAST-1 ), T( ILAST-1, ILAST ),
     $                   B( ILAST, ILAST ), B22, B11, SR, CR, SL, CL )
     $                   T( ILAST, ILAST ), B22, B11, SR, CR, SL, CL )
*
*
            IF( B11.LT.ZERO ) THEN
            IF( B11.LT.ZERO ) THEN
               CR = -CR
               CR = -CR
 Lines 769-785    Link Here 
               B22 = -B22
               B22 = -B22
            END IF
            END IF
*
*
            CALL DROT( ILASTM+1-IFIRST, A( ILAST-1, ILAST-1 ), LDA,
            CALL DROT( ILASTM+1-IFIRST, H( ILAST-1, ILAST-1 ), LDH,
     $                 A( ILAST, ILAST-1 ), LDA, CL, SL )
     $                 H( ILAST, ILAST-1 ), LDH, CL, SL )
            CALL DROT( ILAST+1-IFRSTM, A( IFRSTM, ILAST-1 ), 1,
            CALL DROT( ILAST+1-IFRSTM, H( IFRSTM, ILAST-1 ), 1,
     $                 A( IFRSTM, ILAST ), 1, CR, SR )
     $                 H( IFRSTM, ILAST ), 1, CR, SR )
*
*
            IF( ILAST.LT.ILASTM )
            IF( ILAST.LT.ILASTM )
     $         CALL DROT( ILASTM-ILAST, B( ILAST-1, ILAST+1 ), LDB,
     $         CALL DROT( ILASTM-ILAST, T( ILAST-1, ILAST+1 ), LDT,
     $                    B( ILAST, ILAST+1 ), LDA, CL, SL )
     $                    T( ILAST, ILAST+1 ), LDH, CL, SL )
            IF( IFRSTM.LT.ILAST-1 )
            IF( IFRSTM.LT.ILAST-1 )
     $         CALL DROT( IFIRST-IFRSTM, B( IFRSTM, ILAST-1 ), 1,
     $         CALL DROT( IFIRST-IFRSTM, T( IFRSTM, ILAST-1 ), 1,
     $                    B( IFRSTM, ILAST ), 1, CR, SR )
     $                    T( IFRSTM, ILAST ), 1, CR, SR )
*
*
            IF( ILQ )
            IF( ILQ )
     $         CALL DROT( N, Q( 1, ILAST-1 ), 1, Q( 1, ILAST ), 1, CL,
     $         CALL DROT( N, Q( 1, ILAST-1 ), 1, Q( 1, ILAST ), 1, CL,
 Lines 788-804    Link Here 
     $         CALL DROT( N, Z( 1, ILAST-1 ), 1, Z( 1, ILAST ), 1, CR,
     $         CALL DROT( N, Z( 1, ILAST-1 ), 1, Z( 1, ILAST ), 1, CR,
     $                    SR )
     $                    SR )
*
*
            B( ILAST-1, ILAST-1 ) = B11
            T( ILAST-1, ILAST-1 ) = B11
            B( ILAST-1, ILAST ) = ZERO
            T( ILAST-1, ILAST ) = ZERO
            B( ILAST, ILAST-1 ) = ZERO
            T( ILAST, ILAST-1 ) = ZERO
            B( ILAST, ILAST ) = B22
            T( ILAST, ILAST ) = B22
*
*
*           If B22 is negative, negate column ILAST
*           If B22 is negative, negate column ILAST
*
*
            IF( B22.LT.ZERO ) THEN
            IF( B22.LT.ZERO ) THEN
               DO 210 J = IFRSTM, ILAST
               DO 210 J = IFRSTM, ILAST
                  A( J, ILAST ) = -A( J, ILAST )
                  H( J, ILAST ) = -H( J, ILAST )
                  B( J, ILAST ) = -B( J, ILAST )
                  T( J, ILAST ) = -T( J, ILAST )
  210          CONTINUE
  210          CONTINUE
*
*
               IF( ILZ ) THEN
               IF( ILZ ) THEN
 Lines 812-819    Link Here 
*
*
*           Recompute shift
*           Recompute shift
*
*
            CALL DLAG2( A( ILAST-1, ILAST-1 ), LDA,
            CALL DLAG2( H( ILAST-1, ILAST-1 ), LDH,
     $                  B( ILAST-1, ILAST-1 ), LDB, SAFMIN*SAFETY, S1,
     $                  T( ILAST-1, ILAST-1 ), LDT, SAFMIN*SAFETY, S1,
     $                  TEMP, WR, TEMP2, WI )
     $                  TEMP, WR, TEMP2, WI )
*
*
*           If standardization has perturbed the shift onto real line,
*           If standardization has perturbed the shift onto real line,
 Lines 825-834    Link Here 
*
*
*           Do EISPACK (QZVAL) computation of alpha and beta
*           Do EISPACK (QZVAL) computation of alpha and beta
*
*
            A11 = A( ILAST-1, ILAST-1 )
            A11 = H( ILAST-1, ILAST-1 )
            A21 = A( ILAST, ILAST-1 )
            A21 = H( ILAST, ILAST-1 )
            A12 = A( ILAST-1, ILAST )
            A12 = H( ILAST-1, ILAST )
            A22 = A( ILAST, ILAST )
            A22 = H( ILAST, ILAST )
*
*
*           Compute complex Givens rotation on right
*           Compute complex Givens rotation on right
*           (Assume some element of C = (sA - wB) > unfl )
*           (Assume some element of C = (sA - wB) > unfl )
 Lines 845-854    Link Here 
*
*
            IF( ABS( C11R )+ABS( C11I )+ABS( C12 ).GT.ABS( C21 )+
            IF( ABS( C11R )+ABS( C11I )+ABS( C12 ).GT.ABS( C21 )+
     $          ABS( C22R )+ABS( C22I ) ) THEN
     $          ABS( C22R )+ABS( C22I ) ) THEN
               T = DLAPY3( C12, C11R, C11I )
               T1 = DLAPY3( C12, C11R, C11I )
               CZ = C12 / T
               CZ = C12 / T1
               SZR = -C11R / T
               SZR = -C11R / T1
               SZI = -C11I / T
               SZI = -C11I / T1
            ELSE
            ELSE
               CZ = DLAPY2( C22R, C22I )
               CZ = DLAPY2( C22R, C22I )
               IF( CZ.LE.SAFMIN ) THEN
               IF( CZ.LE.SAFMIN ) THEN
 Lines 858-867    Link Here 
               ELSE
               ELSE
                  TEMPR = C22R / CZ
                  TEMPR = C22R / CZ
                  TEMPI = C22I / CZ
                  TEMPI = C22I / CZ
                  T = DLAPY2( CZ, C21 )
                  T1 = DLAPY2( CZ, C21 )
                  CZ = CZ / T
                  CZ = CZ / T1
                  SZR = -C21*TEMPR / T
                  SZR = -C21*TEMPR / T1
                  SZI = C21*TEMPI / T
                  SZI = C21*TEMPI / T1
               END IF
               END IF
            END IF
            END IF
*
*
 Lines 895-904    Link Here 
                  SQI = TEMPI*A2R - TEMPR*A2I
                  SQI = TEMPI*A2R - TEMPR*A2I
               END IF
               END IF
            END IF
            END IF
            T = DLAPY3( CQ, SQR, SQI )
            T1 = DLAPY3( CQ, SQR, SQI )
            CQ = CQ / T
            CQ = CQ / T1
            SQR = SQR / T
            SQR = SQR / T1
            SQI = SQI / T
            SQI = SQI / T1
*
*
*           Compute diagonal elements of QBZ
*           Compute diagonal elements of QBZ
*
*
 Lines 950-975    Link Here 
*
*
*           We assume that the block is at least 3x3
*           We assume that the block is at least 3x3
*
*
            AD11 = ( ASCALE*A( ILAST-1, ILAST-1 ) ) /
            AD11 = ( ASCALE*H( ILAST-1, ILAST-1 ) ) /
     $             ( BSCALE*B( ILAST-1, ILAST-1 ) )
     $             ( BSCALE*T( ILAST-1, ILAST-1 ) )
            AD21 = ( ASCALE*A( ILAST, ILAST-1 ) ) /
            AD21 = ( ASCALE*H( ILAST, ILAST-1 ) ) /
     $             ( BSCALE*B( ILAST-1, ILAST-1 ) )
     $             ( BSCALE*T( ILAST-1, ILAST-1 ) )
            AD12 = ( ASCALE*A( ILAST-1, ILAST ) ) /
            AD12 = ( ASCALE*H( ILAST-1, ILAST ) ) /
     $             ( BSCALE*B( ILAST, ILAST ) )
     $             ( BSCALE*T( ILAST, ILAST ) )
            AD22 = ( ASCALE*A( ILAST, ILAST ) ) /
            AD22 = ( ASCALE*H( ILAST, ILAST ) ) /
     $             ( BSCALE*B( ILAST, ILAST ) )
     $             ( BSCALE*T( ILAST, ILAST ) )
            U12 = B( ILAST-1, ILAST ) / B( ILAST, ILAST )
            U12 = T( ILAST-1, ILAST ) / T( ILAST, ILAST )
            AD11L = ( ASCALE*A( IFIRST, IFIRST ) ) /
            AD11L = ( ASCALE*H( IFIRST, IFIRST ) ) /
     $              ( BSCALE*B( IFIRST, IFIRST ) )
     $              ( BSCALE*T( IFIRST, IFIRST ) )
            AD21L = ( ASCALE*A( IFIRST+1, IFIRST ) ) /
            AD21L = ( ASCALE*H( IFIRST+1, IFIRST ) ) /
     $              ( BSCALE*B( IFIRST, IFIRST ) )
     $              ( BSCALE*T( IFIRST, IFIRST ) )
            AD12L = ( ASCALE*A( IFIRST, IFIRST+1 ) ) /
            AD12L = ( ASCALE*H( IFIRST, IFIRST+1 ) ) /
     $              ( BSCALE*B( IFIRST+1, IFIRST+1 ) )
     $              ( BSCALE*T( IFIRST+1, IFIRST+1 ) )
            AD22L = ( ASCALE*A( IFIRST+1, IFIRST+1 ) ) /
            AD22L = ( ASCALE*H( IFIRST+1, IFIRST+1 ) ) /
     $              ( BSCALE*B( IFIRST+1, IFIRST+1 ) )
     $              ( BSCALE*T( IFIRST+1, IFIRST+1 ) )
            AD32L = ( ASCALE*A( IFIRST+2, IFIRST+1 ) ) /
            AD32L = ( ASCALE*H( IFIRST+2, IFIRST+1 ) ) /
     $              ( BSCALE*B( IFIRST+1, IFIRST+1 ) )
     $              ( BSCALE*T( IFIRST+1, IFIRST+1 ) )
            U12L = B( IFIRST, IFIRST+1 ) / B( IFIRST+1, IFIRST+1 )
            U12L = T( IFIRST, IFIRST+1 ) / T( IFIRST+1, IFIRST+1 )
*
*
            V( 1 ) = ( AD11-AD11L )*( AD22-AD11L ) - AD12*AD21 +
            V( 1 ) = ( AD11-AD11L )*( AD22-AD11L ) - AD12*AD21 +
     $               AD21*U12*AD11L + ( AD12L-AD11L*U12L )*AD21L
     $               AD21*U12*AD11L + ( AD12L-AD11L*U12L )*AD21L
 Lines 991-1017    Link Here 
*              Zero (j-1)st column of A
*              Zero (j-1)st column of A
*
*
               IF( J.GT.ISTART ) THEN
               IF( J.GT.ISTART ) THEN
                  V( 1 ) = A( J, J-1 )
                  V( 1 ) = H( J, J-1 )
                  V( 2 ) = A( J+1, J-1 )
                  V( 2 ) = H( J+1, J-1 )
                  V( 3 ) = A( J+2, J-1 )
                  V( 3 ) = H( J+2, J-1 )
*
*
                  CALL DLARFG( 3, A( J, J-1 ), V( 2 ), 1, TAU )
                  CALL DLARFG( 3, H( J, J-1 ), V( 2 ), 1, TAU )
                  V( 1 ) = ONE
                  V( 1 ) = ONE
                  A( J+1, J-1 ) = ZERO
                  H( J+1, J-1 ) = ZERO
                  A( J+2, J-1 ) = ZERO
                  H( J+2, J-1 ) = ZERO
               END IF
               END IF
*
*
               DO 230 JC = J, ILASTM
               DO 230 JC = J, ILASTM
                  TEMP = TAU*( A( J, JC )+V( 2 )*A( J+1, JC )+V( 3 )*
                  TEMP = TAU*( H( J, JC )+V( 2 )*H( J+1, JC )+V( 3 )*
     $                   A( J+2, JC ) )
     $                   H( J+2, JC ) )
                  A( J, JC ) = A( J, JC ) - TEMP
                  H( J, JC ) = H( J, JC ) - TEMP
                  A( J+1, JC ) = A( J+1, JC ) - TEMP*V( 2 )
                  H( J+1, JC ) = H( J+1, JC ) - TEMP*V( 2 )
                  A( J+2, JC ) = A( J+2, JC ) - TEMP*V( 3 )
                  H( J+2, JC ) = H( J+2, JC ) - TEMP*V( 3 )
                  TEMP2 = TAU*( B( J, JC )+V( 2 )*B( J+1, JC )+V( 3 )*
                  TEMP2 = TAU*( T( J, JC )+V( 2 )*T( J+1, JC )+V( 3 )*
     $                    B( J+2, JC ) )
     $                    T( J+2, JC ) )
                  B( J, JC ) = B( J, JC ) - TEMP2
                  T( J, JC ) = T( J, JC ) - TEMP2
                  B( J+1, JC ) = B( J+1, JC ) - TEMP2*V( 2 )
                  T( J+1, JC ) = T( J+1, JC ) - TEMP2*V( 2 )
                  B( J+2, JC ) = B( J+2, JC ) - TEMP2*V( 3 )
                  T( J+2, JC ) = T( J+2, JC ) - TEMP2*V( 3 )
  230          CONTINUE
  230          CONTINUE
               IF( ILQ ) THEN
               IF( ILQ ) THEN
                  DO 240 JR = 1, N
                  DO 240 JR = 1, N
 Lines 1028-1054    Link Here 
*              Swap rows to pivot
*              Swap rows to pivot
*
*
               ILPIVT = .FALSE.
               ILPIVT = .FALSE.
               TEMP = MAX( ABS( B( J+1, J+1 ) ), ABS( B( J+1, J+2 ) ) )
               TEMP = MAX( ABS( T( J+1, J+1 ) ), ABS( T( J+1, J+2 ) ) )
               TEMP2 = MAX( ABS( B( J+2, J+1 ) ), ABS( B( J+2, J+2 ) ) )
               TEMP2 = MAX( ABS( T( J+2, J+1 ) ), ABS( T( J+2, J+2 ) ) )
               IF( MAX( TEMP, TEMP2 ).LT.SAFMIN ) THEN
               IF( MAX( TEMP, TEMP2 ).LT.SAFMIN ) THEN
                  SCALE = ZERO
                  SCALE = ZERO
                  U1 = ONE
                  U1 = ONE
                  U2 = ZERO
                  U2 = ZERO
                  GO TO 250
                  GO TO 250
               ELSE IF( TEMP.GE.TEMP2 ) THEN
               ELSE IF( TEMP.GE.TEMP2 ) THEN
                  W11 = B( J+1, J+1 )
                  W11 = T( J+1, J+1 )
                  W21 = B( J+2, J+1 )
                  W21 = T( J+2, J+1 )
                  W12 = B( J+1, J+2 )
                  W12 = T( J+1, J+2 )
                  W22 = B( J+2, J+2 )
                  W22 = T( J+2, J+2 )
                  U1 = B( J+1, J )
                  U1 = T( J+1, J )
                  U2 = B( J+2, J )
                  U2 = T( J+2, J )
               ELSE
               ELSE
                  W21 = B( J+1, J+1 )
                  W21 = T( J+1, J+1 )
                  W11 = B( J+2, J+1 )
                  W11 = T( J+2, J+1 )
                  W22 = B( J+1, J+2 )
                  W22 = T( J+1, J+2 )
                  W12 = B( J+2, J+2 )
                  W12 = T( J+2, J+2 )
                  U2 = B( J+1, J )
                  U2 = T( J+1, J )
                  U1 = B( J+2, J )
                  U1 = T( J+2, J )
               END IF
               END IF
*
*
*              Swap columns if nec.
*              Swap columns if nec.
 Lines 1098-1106    Link Here 
*
*
*              Compute Householder Vector
*              Compute Householder Vector
*
*
               T = SQRT( SCALE**2+U1**2+U2**2 )
               T1 = SQRT( SCALE**2+U1**2+U2**2 )
               TAU = ONE + SCALE / T
               TAU = ONE + SCALE / T1
               VS = -ONE / ( SCALE+T )
               VS = -ONE / ( SCALE+T1 )
               V( 1 ) = ONE
               V( 1 ) = ONE
               V( 2 ) = VS*U1
               V( 2 ) = VS*U1
               V( 3 ) = VS*U2
               V( 3 ) = VS*U2
 Lines 1108-1125    Link Here 
*              Apply transformations from the right.
*              Apply transformations from the right.
*
*
               DO 260 JR = IFRSTM, MIN( J+3, ILAST )
               DO 260 JR = IFRSTM, MIN( J+3, ILAST )
                  TEMP = TAU*( A( JR, J )+V( 2 )*A( JR, J+1 )+V( 3 )*
                  TEMP = TAU*( H( JR, J )+V( 2 )*H( JR, J+1 )+V( 3 )*
     $                   A( JR, J+2 ) )
     $                   H( JR, J+2 ) )
                  A( JR, J ) = A( JR, J ) - TEMP
                  H( JR, J ) = H( JR, J ) - TEMP
                  A( JR, J+1 ) = A( JR, J+1 ) - TEMP*V( 2 )
                  H( JR, J+1 ) = H( JR, J+1 ) - TEMP*V( 2 )
                  A( JR, J+2 ) = A( JR, J+2 ) - TEMP*V( 3 )
                  H( JR, J+2 ) = H( JR, J+2 ) - TEMP*V( 3 )
  260          CONTINUE
  260          CONTINUE
               DO 270 JR = IFRSTM, J + 2
               DO 270 JR = IFRSTM, J + 2
                  TEMP = TAU*( B( JR, J )+V( 2 )*B( JR, J+1 )+V( 3 )*
                  TEMP = TAU*( T( JR, J )+V( 2 )*T( JR, J+1 )+V( 3 )*
     $                   B( JR, J+2 ) )
     $                   T( JR, J+2 ) )
                  B( JR, J ) = B( JR, J ) - TEMP
                  T( JR, J ) = T( JR, J ) - TEMP
                  B( JR, J+1 ) = B( JR, J+1 ) - TEMP*V( 2 )
                  T( JR, J+1 ) = T( JR, J+1 ) - TEMP*V( 2 )
                  B( JR, J+2 ) = B( JR, J+2 ) - TEMP*V( 3 )
                  T( JR, J+2 ) = T( JR, J+2 ) - TEMP*V( 3 )
  270          CONTINUE
  270          CONTINUE
               IF( ILZ ) THEN
               IF( ILZ ) THEN
                  DO 280 JR = 1, N
                  DO 280 JR = 1, N
 Lines 1130-1137    Link Here 
                     Z( JR, J+2 ) = Z( JR, J+2 ) - TEMP*V( 3 )
                     Z( JR, J+2 ) = Z( JR, J+2 ) - TEMP*V( 3 )
  280             CONTINUE
  280             CONTINUE
               END IF
               END IF
               B( J+1, J ) = ZERO
               T( J+1, J ) = ZERO
               B( J+2, J ) = ZERO
               T( J+2, J ) = ZERO
  290       CONTINUE
  290       CONTINUE
*
*
*           Last elements: Use Givens rotations
*           Last elements: Use Givens rotations
 Lines 1139-1155    Link Here 
*           Rotations from the left
*           Rotations from the left
*
*
            J = ILAST - 1
            J = ILAST - 1
            TEMP = A( J, J-1 )
            TEMP = H( J, J-1 )
            CALL DLARTG( TEMP, A( J+1, J-1 ), C, S, A( J, J-1 ) )
            CALL DLARTG( TEMP, H( J+1, J-1 ), C, S, H( J, J-1 ) )
            A( J+1, J-1 ) = ZERO
            H( J+1, J-1 ) = ZERO
*
*
            DO 300 JC = J, ILASTM
            DO 300 JC = J, ILASTM
               TEMP = C*A( J, JC ) + S*A( J+1, JC )
               TEMP = C*H( J, JC ) + S*H( J+1, JC )
               A( J+1, JC ) = -S*A( J, JC ) + C*A( J+1, JC )
               H( J+1, JC ) = -S*H( J, JC ) + C*H( J+1, JC )
               A( J, JC ) = TEMP
               H( J, JC ) = TEMP
               TEMP2 = C*B( J, JC ) + S*B( J+1, JC )
               TEMP2 = C*T( J, JC ) + S*T( J+1, JC )
               B( J+1, JC ) = -S*B( J, JC ) + C*B( J+1, JC )
               T( J+1, JC ) = -S*T( J, JC ) + C*T( J+1, JC )
               B( J, JC ) = TEMP2
               T( J, JC ) = TEMP2
  300       CONTINUE
  300       CONTINUE
            IF( ILQ ) THEN
            IF( ILQ ) THEN
               DO 310 JR = 1, N
               DO 310 JR = 1, N
 Lines 1161-1179    Link Here 
*
*
*           Rotations from the right.
*           Rotations from the right.
*
*
            TEMP = B( J+1, J+1 )
            TEMP = T( J+1, J+1 )
            CALL DLARTG( TEMP, B( J+1, J ), C, S, B( J+1, J+1 ) )
            CALL DLARTG( TEMP, T( J+1, J ), C, S, T( J+1, J+1 ) )
            B( J+1, J ) = ZERO
            T( J+1, J ) = ZERO
*
*
            DO 320 JR = IFRSTM, ILAST
            DO 320 JR = IFRSTM, ILAST
               TEMP = C*A( JR, J+1 ) + S*A( JR, J )
               TEMP = C*H( JR, J+1 ) + S*H( JR, J )
               A( JR, J ) = -S*A( JR, J+1 ) + C*A( JR, J )
               H( JR, J ) = -S*H( JR, J+1 ) + C*H( JR, J )
               A( JR, J+1 ) = TEMP
               H( JR, J+1 ) = TEMP
  320       CONTINUE
  320       CONTINUE
            DO 330 JR = IFRSTM, ILAST - 1
            DO 330 JR = IFRSTM, ILAST - 1
               TEMP = C*B( JR, J+1 ) + S*B( JR, J )
               TEMP = C*T( JR, J+1 ) + S*T( JR, J )
               B( JR, J ) = -S*B( JR, J+1 ) + C*B( JR, J )
               T( JR, J ) = -S*T( JR, J+1 ) + C*T( JR, J )
               B( JR, J+1 ) = TEMP
               T( JR, J+1 ) = TEMP
  330       CONTINUE
  330       CONTINUE
            IF( ILZ ) THEN
            IF( ILZ ) THEN
               DO 340 JR = 1, N
               DO 340 JR = 1, N
 Lines 1207-1221    Link Here 
*     Set Eigenvalues 1:ILO-1
*     Set Eigenvalues 1:ILO-1
*
*
      DO 410 J = 1, ILO - 1
      DO 410 J = 1, ILO - 1
         IF( B( J, J ).LT.ZERO ) THEN
         IF( T( J, J ).LT.ZERO ) THEN
            IF( ILSCHR ) THEN
            IF( ILSCHR ) THEN
               DO 390 JR = 1, J
               DO 390 JR = 1, J
                  A( JR, J ) = -A( JR, J )
                  H( JR, J ) = -H( JR, J )
                  B( JR, J ) = -B( JR, J )
                  T( JR, J ) = -T( JR, J )
  390          CONTINUE
  390          CONTINUE
            ELSE
            ELSE
               A( J, J ) = -A( J, J )
               H( J, J ) = -H( J, J )
               B( J, J ) = -B( J, J )
               T( J, J ) = -T( J, J )
            END IF
            END IF
            IF( ILZ ) THEN
            IF( ILZ ) THEN
               DO 400 JR = 1, N
               DO 400 JR = 1, N
 Lines 1223-1231    Link Here 
  400          CONTINUE
  400          CONTINUE
            END IF
            END IF
         END IF
         END IF
         ALPHAR( J ) = A( J, J )
         ALPHAR( J ) = H( J, J )
         ALPHAI( J ) = ZERO
         ALPHAI( J ) = ZERO
         BETA( J ) = B( J, J )
         BETA( J ) = T( J, J )
  410 CONTINUE
  410 CONTINUE
*
*
*     Normal Termination
*     Normal Termination
(-) LAPACK/SRC/dlasr.f (-50 / +87 lines)
 Lines 3-9    Link Here 
*  -- LAPACK auxiliary routine (version 3.0) --
*  -- LAPACK auxiliary routine (version 3.0) --
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Courant Institute, Argonne National Lab, and Rice University
*     Courant Institute, Argonne National Lab, and Rice University
*     October 31, 1992
*     May 3, 2001 
*
*
*     .. Scalar Arguments ..
*     .. Scalar Arguments ..
      CHARACTER          DIRECT, PIVOT, SIDE
      CHARACTER          DIRECT, PIVOT, SIDE
 Lines 16-59    Link Here 
*  Purpose
*  Purpose
*  =======
*  =======
*
*
*  DLASR   performs the transformation
*  DLASR applies a sequence of plane rotations to a real matrix A,
*
*  from either the left or the right.
*     A := P*A,   when SIDE = 'L' or 'l'  (  Left-hand side )
*  
*
*  When SIDE = 'L', the transformation takes the form
*     A := A*P',  when SIDE = 'R' or 'r'  ( Right-hand side )
*  
*
*     A := P*A
*  where A is an m by n real matrix and P is an orthogonal matrix,
*  
*  consisting of a sequence of plane rotations determined by the
*  and when SIDE = 'R', the transformation takes the form
*  parameters PIVOT and DIRECT as follows ( z = m when SIDE = 'L' or 'l'
*  
*  and z = n when SIDE = 'R' or 'r' ):
*     A := A*P**T
*
*  
*  When  DIRECT = 'F' or 'f'  ( Forward sequence ) then
*  where P is an orthogonal matrix consisting of a sequence of z plane
*
*  rotations, with z = M when SIDE = 'L' and z = N when SIDE = 'R',
*     P = P( z - 1 )*...*P( 2 )*P( 1 ),
*  and P**T is the transpose of P.
*
*  
*  and when DIRECT = 'B' or 'b'  ( Backward sequence ) then
*  When DIRECT = 'F' (Forward sequence), then
*
*  
*     P = P( 1 )*P( 2 )*...*P( z - 1 ),
*     P = P(z-1) * ... * P(2) * P(1)
*
*  
*  where  P( k ) is a plane rotation matrix for the following planes:
*  and when DIRECT = 'B' (Backward sequence), then
*
*  
*     when  PIVOT = 'V' or 'v'  ( Variable pivot ),
*     P = P(1) * P(2) * ... * P(z-1)
*        the plane ( k, k + 1 )
*  
*
*  where P(k) is a plane rotation matrix defined by the 2-by-2 rotation
*     when  PIVOT = 'T' or 't'  ( Top pivot ),
*  
*        the plane ( 1, k + 1 )
*     R(k) = (  c(k)  s(k) )
*
*          = ( -s(k)  c(k) ).
*     when  PIVOT = 'B' or 'b'  ( Bottom pivot ),
*  
*        the plane ( k, z )
*  When PIVOT = 'V' (Variable pivot), the rotation is performed
*
*  for the plane (k,k+1), i.e., P(k) has the form
*  c( k ) and s( k )  must contain the  cosine and sine that define the
*  
*  matrix  P( k ).  The two by two plane rotation part of the matrix
*     P(k) = (  1                                            )
*  P( k ), R( k ), is assumed to be of the form
*            (       ...                                     )
*
*            (              1                                )
*     R( k ) = (  c( k )  s( k ) ).
*            (                   c(k)  s(k)                  )
*              ( -s( k )  c( k ) )
*            (                  -s(k)  c(k)                  )
*
*            (                                1              )
*  This version vectorises across rows of the array A when SIDE = 'L'.
*            (                                     ...       )
*            (                                            1  )
*  
*  where R(k) appears as a rank-2 modification to the identity matrix in
*  rows and columns k and k+1.
*  
*  When PIVOT = 'T' (Top pivot), the rotation is performed for the
*  plane (1,k+1), so P(k) has the form
*  
*     P(k) = (  c(k)                    s(k)                 )
*            (         1                                     )
*            (              ...                              )
*            (                     1                         )
*            ( -s(k)                    c(k)                 )
*            (                                 1             )
*            (                                      ...      )
*            (                                             1 )
*  
*  where R(k) appears in rows and columns 1 and k+1.
*  
*  Similarly, when PIVOT = 'B' (Bottom pivot), the rotation is
*  performed for the plane (k,z), giving P(k) the form
*  
*     P(k) = ( 1                                             )
*            (      ...                                      )
*            (             1                                 )
*            (                  c(k)                    s(k) )
*            (                         1                     )
*            (                              ...              )
*            (                                     1         )
*            (                 -s(k)                    c(k) )
*  
*  where R(k) appears in rows and columns k and z.  The rotations are
*  performed without ever forming P(k) explicitly.
*
*
*  Arguments
*  Arguments
*  =========
*  =========
 Lines 62-74    Link Here 
*          Specifies whether the plane rotation matrix P is applied to
*          Specifies whether the plane rotation matrix P is applied to
*          A on the left or the right.
*          A on the left or the right.
*          = 'L':  Left, compute A := P*A
*          = 'L':  Left, compute A := P*A
*          = 'R':  Right, compute A:= A*P'
*          = 'R':  Right, compute A:= A*P**T
*
*
*  DIRECT  (input) CHARACTER*1
*  DIRECT  (input) CHARACTER*1
*          Specifies whether P is a forward or backward sequence of
*          Specifies whether P is a forward or backward sequence of
*          plane rotations.
*          plane rotations.
*          = 'F':  Forward, P = P( z - 1 )*...*P( 2 )*P( 1 )
*          = 'F':  Forward, P = P(z-1)*...*P(2)*P(1)
*          = 'B':  Backward, P = P( 1 )*P( 2 )*...*P( z - 1 )
*          = 'B':  Backward, P = P(1)*P(2)*...*P(z-1)
*
*
*  PIVOT   (input) CHARACTER*1
*  PIVOT   (input) CHARACTER*1
*          Specifies the plane for which P(k) is a plane rotation
*          Specifies the plane for which P(k) is a plane rotation
 Lines 85-102    Link Here 
*          The number of columns of the matrix A.  If n <= 1, an
*          The number of columns of the matrix A.  If n <= 1, an
*          immediate return is effected.
*          immediate return is effected.
*
*
*  C, S    (input) DOUBLE PRECISION arrays, dimension
*  C       (input) DOUBLE PRECISION array, dimension
*                  (M-1) if SIDE = 'L'
*                  (N-1) if SIDE = 'R'
*          The cosines c(k) of the plane rotations.
*
*  S       (input) DOUBLE PRECISION array, dimension
*                  (M-1) if SIDE = 'L'
*                  (M-1) if SIDE = 'L'
*                  (N-1) if SIDE = 'R'
*                  (N-1) if SIDE = 'R'
*          c(k) and s(k) contain the cosine and sine that define the
*          The sines s(k) of the plane rotations.  The 2-by-2 plane
*          matrix P(k).  The two by two plane rotation part of the
*          rotation part of the matrix P(k), R(k), has the form
*          matrix P(k), R(k), is assumed to be of the form
*          R(k) = (  c(k)  s(k) )
*          R( k ) = (  c( k )  s( k ) ).
*                 ( -s(k)  c(k) ).
*                   ( -s( k )  c( k ) )
*
*
*  A       (input/output) DOUBLE PRECISION array, dimension (LDA,N)
*  A       (input/output) DOUBLE PRECISION array, dimension (LDA,N)
*          The m by n matrix A.  On exit, A is overwritten by P*A if
*          The M-by-N matrix A.  On exit, A is overwritten by P*A if
*          SIDE = 'R' or by A*P' if SIDE = 'L'.
*          SIDE = 'R' or by A*P**T if SIDE = 'L'.
*
*
*  LDA     (input) INTEGER
*  LDA     (input) INTEGER
*          The leading dimension of the array A.  LDA >= max(1,M).
*          The leading dimension of the array A.  LDA >= max(1,M).
(-) LAPACK/SRC/dsbgst.f (-2 / +2 lines)
 Lines 4-10    Link Here 
*  -- LAPACK routine (version 3.0) --
*  -- LAPACK routine (version 3.0) --
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Courant Institute, Argonne National Lab, and Rice University
*     Courant Institute, Argonne National Lab, and Rice University
*     June 30, 1999
*     January 9, 2001
*
*
*     .. Scalar Arguments ..
*     .. Scalar Arguments ..
      CHARACTER          UPLO, VECT
      CHARACTER          UPLO, VECT
 Lines 125-131    Link Here 
         INFO = -3
         INFO = -3
      ELSE IF( KA.LT.0 ) THEN
      ELSE IF( KA.LT.0 ) THEN
         INFO = -4
         INFO = -4
      ELSE IF( KB.LT.0 ) THEN
      ELSE IF( KB.LT.0 .OR. KB.GT.KA ) THEN
         INFO = -5
         INFO = -5
      ELSE IF( LDAB.LT.KA+1 ) THEN
      ELSE IF( LDAB.LT.KA+1 ) THEN
         INFO = -7
         INFO = -7
(-) LAPACK/SRC/dstebz.f (-1 / +2 lines)
 Lines 6-11    Link Here 
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Courant Institute, Argonne National Lab, and Rice University
*     Courant Institute, Argonne National Lab, and Rice University
*     June 30, 1999
*     June 30, 1999
*     8-18-00:  Increase FUDGE factor for T3E (eca)
*
*
*     .. Scalar Arguments ..
*     .. Scalar Arguments ..
      CHARACTER          ORDER, RANGE
      CHARACTER          ORDER, RANGE
 Lines 175-181    Link Here 
      PARAMETER          ( ZERO = 0.0D0, ONE = 1.0D0, TWO = 2.0D0,
      PARAMETER          ( ZERO = 0.0D0, ONE = 1.0D0, TWO = 2.0D0,
     $                   HALF = 1.0D0 / TWO )
     $                   HALF = 1.0D0 / TWO )
      DOUBLE PRECISION   FUDGE, RELFAC
      DOUBLE PRECISION   FUDGE, RELFAC
      PARAMETER          ( FUDGE = 2.0D0, RELFAC = 2.0D0 )
      PARAMETER          ( FUDGE = 2.1D0, RELFAC = 2.0D0 )
*     ..
*     ..
*     .. Local Scalars ..
*     .. Local Scalars ..
      LOGICAL            NCNVRG, TOOFEW
      LOGICAL            NCNVRG, TOOFEW
(-) LAPACK/SRC/dtgevc.f (-159 / +161 lines)
 Lines 1-18    Link Here 
      SUBROUTINE DTGEVC( SIDE, HOWMNY, SELECT, N, A, LDA, B, LDB, VL,
      SUBROUTINE DTGEVC( SIDE, HOWMNY, SELECT, N, S, LDS, P, LDP, VL,
     $                   LDVL, VR, LDVR, MM, M, WORK, INFO )
     $                   LDVL, VR, LDVR, MM, M, WORK, INFO )
*
*
*  -- LAPACK routine (version 3.0) --
*  -- LAPACK routine (version 3.0) --
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Courant Institute, Argonne National Lab, and Rice University
*     Courant Institute, Argonne National Lab, and Rice University
*     June 30, 1999
*     May 4, 2001
*
*
*     .. Scalar Arguments ..
*     .. Scalar Arguments ..
      CHARACTER          HOWMNY, SIDE
      CHARACTER          HOWMNY, SIDE
      INTEGER            INFO, LDA, LDB, LDVL, LDVR, M, MM, N
      INTEGER            INFO, LDP, LDS, LDVL, LDVR, M, MM, N
*     ..
*     ..
*     .. Array Arguments ..
*     .. Array Arguments ..
      LOGICAL            SELECT( * )
      LOGICAL            SELECT( * )
      DOUBLE PRECISION   A( LDA, * ), B( LDB, * ), VL( LDVL, * ),
      DOUBLE PRECISION   P( LDP, * ), S( LDS, * ), VL( LDVL, * ),
     $                   VR( LDVR, * ), WORK( * )
     $                   VR( LDVR, * ), WORK( * )
*     ..
*     ..
*
*
 Lines 20-54    Link Here 
*  Purpose
*  Purpose
*  =======
*  =======
*
*
*  DTGEVC computes some or all of the right and/or left generalized
*  DTGEVC computes some or all of the right and/or left eigenvectors of
*  eigenvectors of a pair of real upper triangular matrices (A,B).
*  a pair of real matrices (S,P), where S is a quasi-triangular matrix
*
*  and P is upper triangular.  Matrix pairs of this type are produced by
*  The right generalized eigenvector x and the left generalized
*  the generalized Schur factorization of a matrix pair (A,B):
*  eigenvector y of (A,B) corresponding to a generalized eigenvalue
*
*  w are defined by:
*     A = Q*S*Z**T,  B = Q*P*Z**T
*
*
*          (A - wB) * x = 0  and  y**H * (A - wB) = 0
*  as computed by DGGHRD + DHGEQZ.
*
*
*  The right eigenvector x and the left eigenvector y of (S,P)
*  corresponding to an eigenvalue w are defined by:
*  
*     S*x = w*P*x,  (y**H)*S = w*(y**H)*P,
*  
*  where y**H denotes the conjugate tranpose of y.
*  where y**H denotes the conjugate tranpose of y.
*
*  The eigenvalues are not input to this routine, but are computed
*  If an eigenvalue w is determined by zero diagonal elements of both A
*  directly from the diagonal blocks of S and P.
*  and B, a unit vector is returned as the corresponding eigenvector.
*  
*
*  This routine returns the matrices X and/or Y of right and left
*  If all eigenvectors are requested, the routine may either return
*  eigenvectors of (S,P), or the products Z*X and/or Q*Y,
*  the matrices X and/or Y of right or left eigenvectors of (A,B), or
*  where Z and Q are input matrices.
*  the products Z*X and/or Q*Y, where Z and Q are input orthogonal
*  If Q and Z are the orthogonal factors from the generalized Schur
*  matrices.  If (A,B) was obtained from the generalized real-Schur
*  factorization of a matrix pair (A,B), then Z*X and Q*Y
*  factorization of an original pair of matrices
*  are the matrices of right and left eigenvectors of (A,B).
*     (A0,B0) = (Q*A*Z**H,Q*B*Z**H),
* 
*  then Z*X and Q*Y are the matrices of right or left eigenvectors of
*  A.
*
*  A must be block upper triangular, with 1-by-1 and 2-by-2 diagonal
*  blocks.  Corresponding to each 2-by-2 diagonal block is a complex
*  conjugate pair of eigenvalues and eigenvectors; only one
*  eigenvector of the pair is computed, namely the one corresponding
*  to the eigenvalue with positive imaginary part.
*
*  Arguments
*  Arguments
*  =========
*  =========
*
*
 Lines 59-136    Link Here 
*
*
*  HOWMNY  (input) CHARACTER*1
*  HOWMNY  (input) CHARACTER*1
*          = 'A': compute all right and/or left eigenvectors;
*          = 'A': compute all right and/or left eigenvectors;
*          = 'B': compute all right and/or left eigenvectors, and
*          = 'B': compute all right and/or left eigenvectors,
*                 backtransform them using the input matrices supplied
*                 backtransformed by the matrices in VR and/or VL;
*                 in VR and/or VL;
*          = 'S': compute selected right and/or left eigenvectors,
*          = 'S': compute selected right and/or left eigenvectors,
*                 specified by the logical array SELECT.
*                 specified by the logical array SELECT.
*
*
*  SELECT  (input) LOGICAL array, dimension (N)
*  SELECT  (input) LOGICAL array, dimension (N)
*          If HOWMNY='S', SELECT specifies the eigenvectors to be
*          If HOWMNY='S', SELECT specifies the eigenvectors to be
*          computed.
*          computed.  If w(j) is a real eigenvalue, the corresponding
*          If HOWMNY='A' or 'B', SELECT is not referenced.
*          real eigenvector is computed if SELECT(j) is .TRUE..
*          To select the real eigenvector corresponding to the real
*          If w(j) and w(j+1) are the real and imaginary parts of a
*          eigenvalue w(j), SELECT(j) must be set to .TRUE.  To select
*          complex eigenvalue, the corresponding complex eigenvector
*          the complex eigenvector corresponding to a complex conjugate
*          is computed if either SELECT(j) or SELECT(j+1) is .TRUE.,
*          pair w(j) and w(j+1), either SELECT(j) or SELECT(j+1) must
*          and on exit SELECT(j) is set to .TRUE. and SELECT(j+1) is
*          be set to .TRUE..
*          set to .FALSE..
*          Not referenced if HOWMNY = 'A' or 'B'.
*
*
*  N       (input) INTEGER
*  N       (input) INTEGER
*          The order of the matrices A and B.  N >= 0.
*          The order of the matrices S and P.  N >= 0.
*
*
*  A       (input) DOUBLE PRECISION array, dimension (LDA,N)
*  S       (input) DOUBLE PRECISION array, dimension (LDS,N)
*          The upper quasi-triangular matrix A.
*          The upper quasi-triangular matrix S from a generalized Schur
*          factorization, as computed by DHGEQZ.
*
*  LDS     (input) INTEGER
*          The leading dimension of array S.  LDS >= max(1,N).
*
*  P       (input) DOUBLE PRECISION array, dimension (LDP,N)
*          The upper triangular matrix P from a generalized Schur
*          factorization, as computed by DHGEQZ.
*          2-by-2 diagonal blocks of P corresponding to 2-by-2 blocks
*          of S must be in positive diagonal form.
*
*
*  LDA     (input) INTEGER
*  LDP     (input) INTEGER
*          The leading dimension of array A.  LDA >= max(1, N).
*          The leading dimension of array P.  LDP >= max(1,N).
*
*  B       (input) DOUBLE PRECISION array, dimension (LDB,N)
*          The upper triangular matrix B.  If A has a 2-by-2 diagonal
*          block, then the corresponding 2-by-2 block of B must be
*          diagonal with positive elements.
*
*  LDB     (input) INTEGER
*          The leading dimension of array B.  LDB >= max(1,N).
*
*
*  VL      (input/output) DOUBLE PRECISION array, dimension (LDVL,MM)
*  VL      (input/output) DOUBLE PRECISION array, dimension (LDVL,MM)
*          On entry, if SIDE = 'L' or 'B' and HOWMNY = 'B', VL must
*          On entry, if SIDE = 'L' or 'B' and HOWMNY = 'B', VL must
*          contain an N-by-N matrix Q (usually the orthogonal matrix Q
*          contain an N-by-N matrix Q (usually the orthogonal matrix Q
*          of left Schur vectors returned by DHGEQZ).
*          of left Schur vectors returned by DHGEQZ).
*          On exit, if SIDE = 'L' or 'B', VL contains:
*          On exit, if SIDE = 'L' or 'B', VL contains:
*          if HOWMNY = 'A', the matrix Y of left eigenvectors of (A,B);
*          if HOWMNY = 'A', the matrix Y of left eigenvectors of (S,P);
*          if HOWMNY = 'B', the matrix Q*Y;
*          if HOWMNY = 'B', the matrix Q*Y;
*          if HOWMNY = 'S', the left eigenvectors of (A,B) specified by
*          if HOWMNY = 'S', the left eigenvectors of (S,P) specified by
*                      SELECT, stored consecutively in the columns of
*                      SELECT, stored consecutively in the columns of
*                      VL, in the same order as their eigenvalues.
*                      VL, in the same order as their eigenvalues.
*          If SIDE = 'R', VL is not referenced.
*
*
*          A complex eigenvector corresponding to a complex eigenvalue
*          A complex eigenvector corresponding to a complex eigenvalue
*          is stored in two consecutive columns, the first holding the
*          is stored in two consecutive columns, the first holding the
*          real part, and the second the imaginary part.
*          real part, and the second the imaginary part.
*
*
*          Not referenced if SIDE = 'R'.
*
*  LDVL    (input) INTEGER
*  LDVL    (input) INTEGER
*          The leading dimension of array VL.
*          The leading dimension of array VL.  LDVL >= 1, and if
*          LDVL >= max(1,N) if SIDE = 'L' or 'B'; LDVL >= 1 otherwise.
*          SIDE = 'L' or 'B', LDVL >= N.
*
*
*  VR      (input/output) DOUBLE PRECISION array, dimension (LDVR,MM)
*  VR      (input/output) DOUBLE PRECISION array, dimension (LDVR,MM)
*          On entry, if SIDE = 'R' or 'B' and HOWMNY = 'B', VR must
*          On entry, if SIDE = 'R' or 'B' and HOWMNY = 'B', VR must
*          contain an N-by-N matrix Q (usually the orthogonal matrix Z
*          contain an N-by-N matrix Z (usually the orthogonal matrix Z
*          of right Schur vectors returned by DHGEQZ).
*          of right Schur vectors returned by DHGEQZ).
*
*          On exit, if SIDE = 'R' or 'B', VR contains:
*          On exit, if SIDE = 'R' or 'B', VR contains:
*          if HOWMNY = 'A', the matrix X of right eigenvectors of (A,B);
*          if HOWMNY = 'A', the matrix X of right eigenvectors of (S,P);
*          if HOWMNY = 'B', the matrix Z*X;
*          if HOWMNY = 'B' or 'b', the matrix Z*X;
*          if HOWMNY = 'S', the right eigenvectors of (A,B) specified by
*          if HOWMNY = 'S' or 's', the right eigenvectors of (S,P)
*                      SELECT, stored consecutively in the columns of
*                      specified by SELECT, stored consecutively in the
*                      VR, in the same order as their eigenvalues.
*                      columns of VR, in the same order as their
*          If SIDE = 'L', VR is not referenced.
*                      eigenvalues.
*
*
*          A complex eigenvector corresponding to a complex eigenvalue
*          A complex eigenvector corresponding to a complex eigenvalue
*          is stored in two consecutive columns, the first holding the
*          is stored in two consecutive columns, the first holding the
*          real part and the second the imaginary part.
*          real part and the second the imaginary part.
*          
*          Not referenced if SIDE = 'L'.
*
*
*  LDVR    (input) INTEGER
*  LDVR    (input) INTEGER
*          The leading dimension of the array VR.
*          The leading dimension of the array VR.  LDVR >= 1, and if
*          LDVR >= max(1,N) if SIDE = 'R' or 'B'; LDVR >= 1 otherwise.
*          SIDE = 'R' or 'B', LDVR >= N.
*
*
*  MM      (input) INTEGER
*  MM      (input) INTEGER
*          The number of columns in the arrays VL and/or VR. MM >= M.
*          The number of columns in the arrays VL and/or VR. MM >= M.
 Lines 199-205    Link Here 
*  partial sums.  Since FORTRAN arrays are stored columnwise, this has
*  partial sums.  Since FORTRAN arrays are stored columnwise, this has
*  the advantage that at each step, the elements of C that are accessed
*  the advantage that at each step, the elements of C that are accessed
*  are adjacent to one another, whereas with the rowwise method, the
*  are adjacent to one another, whereas with the rowwise method, the
*  elements accessed at a step are spaced LDA (and LDB) words apart.
*  elements accessed at a step are spaced LDS (and LDP) words apart.
*
*
*  When finding left eigenvectors, the matrix in question is the
*  When finding left eigenvectors, the matrix in question is the
*  transpose of the one in storage, so the rowwise method then
*  transpose of the one in storage, so the rowwise method then
 Lines 226-233    Link Here 
     $                   XSCALE
     $                   XSCALE
*     ..
*     ..
*     .. Local Arrays ..
*     .. Local Arrays ..
      DOUBLE PRECISION   BDIAG( 2 ), SUM( 2, 2 ), SUMA( 2, 2 ),
      DOUBLE PRECISION   BDIAG( 2 ), SUM( 2, 2 ), SUMS( 2, 2 ),
     $                   SUMB( 2, 2 )
     $                   SUMP( 2, 2 )
*     ..
*     ..
*     .. External Functions ..
*     .. External Functions ..
      LOGICAL            LSAME
      LOGICAL            LSAME
 Lines 235-241    Link Here 
      EXTERNAL           LSAME, DLAMCH
      EXTERNAL           LSAME, DLAMCH
*     ..
*     ..
*     .. External Subroutines ..
*     .. External Subroutines ..
      EXTERNAL           DGEMV, DLACPY, DLAG2, DLALN2, XERBLA
      EXTERNAL           DGEMV, DLABAD, DLACPY, DLAG2, DLALN2, XERBLA
*     ..
*     ..
*     .. Intrinsic Functions ..
*     .. Intrinsic Functions ..
      INTRINSIC          ABS, MAX, MIN
      INTRINSIC          ABS, MAX, MIN
 Lines 252-258    Link Here 
         IHWMNY = 2
         IHWMNY = 2
         ILALL = .FALSE.
         ILALL = .FALSE.
         ILBACK = .FALSE.
         ILBACK = .FALSE.
      ELSE IF( LSAME( HOWMNY, 'B' ) .OR. LSAME( HOWMNY, 'T' ) ) THEN
      ELSE IF( LSAME( HOWMNY, 'B' ) ) THEN
         IHWMNY = 3
         IHWMNY = 3
         ILALL = .TRUE.
         ILALL = .TRUE.
         ILBACK = .TRUE.
         ILBACK = .TRUE.
 Lines 284-292    Link Here 
         INFO = -2
         INFO = -2
      ELSE IF( N.LT.0 ) THEN
      ELSE IF( N.LT.0 ) THEN
         INFO = -4
         INFO = -4
      ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
      ELSE IF( LDS.LT.MAX( 1, N ) ) THEN
         INFO = -6
         INFO = -6
      ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
      ELSE IF( LDP.LT.MAX( 1, N ) ) THEN
         INFO = -8
         INFO = -8
      END IF
      END IF
      IF( INFO.NE.0 ) THEN
      IF( INFO.NE.0 ) THEN
 Lines 305-311    Link Here 
               GO TO 10
               GO TO 10
            END IF
            END IF
            IF( J.LT.N ) THEN
            IF( J.LT.N ) THEN
               IF( A( J+1, J ).NE.ZERO )
               IF( S( J+1, J ).NE.ZERO )
     $            ILCPLX = .TRUE.
     $            ILCPLX = .TRUE.
            END IF
            END IF
            IF( ILCPLX ) THEN
            IF( ILCPLX ) THEN
 Lines 325-335    Link Here 
      ILABAD = .FALSE.
      ILABAD = .FALSE.
      ILBBAD = .FALSE.
      ILBBAD = .FALSE.
      DO 20 J = 1, N - 1
      DO 20 J = 1, N - 1
         IF( A( J+1, J ).NE.ZERO ) THEN
         IF( S( J+1, J ).NE.ZERO ) THEN
            IF( B( J, J ).EQ.ZERO .OR. B( J+1, J+1 ).EQ.ZERO .OR.
            IF( P( J, J ).EQ.ZERO .OR. P( J+1, J+1 ).EQ.ZERO .OR.
     $          B( J, J+1 ).NE.ZERO )ILBBAD = .TRUE.
     $          P( J, J+1 ).NE.ZERO )ILBBAD = .TRUE.
            IF( J.LT.N-1 ) THEN
            IF( J.LT.N-1 ) THEN
               IF( A( J+2, J+1 ).NE.ZERO )
               IF( S( J+2, J+1 ).NE.ZERO )
     $            ILABAD = .TRUE.
     $            ILABAD = .TRUE.
            END IF
            END IF
         END IF
         END IF
 Lines 372-401    Link Here 
*     blocks) of A and B to check for possible overflow in the
*     blocks) of A and B to check for possible overflow in the
*     triangular solver.
*     triangular solver.
*
*
      ANORM = ABS( A( 1, 1 ) )
      ANORM = ABS( S( 1, 1 ) )
      IF( N.GT.1 )
      IF( N.GT.1 )
     $   ANORM = ANORM + ABS( A( 2, 1 ) )
     $   ANORM = ANORM + ABS( S( 2, 1 ) )
      BNORM = ABS( B( 1, 1 ) )
      BNORM = ABS( P( 1, 1 ) )
      WORK( 1 ) = ZERO
      WORK( 1 ) = ZERO
      WORK( N+1 ) = ZERO
      WORK( N+1 ) = ZERO
*
*
      DO 50 J = 2, N
      DO 50 J = 2, N
         TEMP = ZERO
         TEMP = ZERO
         TEMP2 = ZERO
         TEMP2 = ZERO
         IF( A( J, J-1 ).EQ.ZERO ) THEN
         IF( S( J, J-1 ).EQ.ZERO ) THEN
            IEND = J - 1
            IEND = J - 1
         ELSE
         ELSE
            IEND = J - 2
            IEND = J - 2
         END IF
         END IF
         DO 30 I = 1, IEND
         DO 30 I = 1, IEND
            TEMP = TEMP + ABS( A( I, J ) )
            TEMP = TEMP + ABS( S( I, J ) )
            TEMP2 = TEMP2 + ABS( B( I, J ) )
            TEMP2 = TEMP2 + ABS( P( I, J ) )
   30    CONTINUE
   30    CONTINUE
         WORK( J ) = TEMP
         WORK( J ) = TEMP
         WORK( N+J ) = TEMP2
         WORK( N+J ) = TEMP2
         DO 40 I = IEND + 1, MIN( J+1, N )
         DO 40 I = IEND + 1, MIN( J+1, N )
            TEMP = TEMP + ABS( A( I, J ) )
            TEMP = TEMP + ABS( S( I, J ) )
            TEMP2 = TEMP2 + ABS( B( I, J ) )
            TEMP2 = TEMP2 + ABS( P( I, J ) )
   40    CONTINUE
   40    CONTINUE
         ANORM = MAX( ANORM, TEMP )
         ANORM = MAX( ANORM, TEMP )
         BNORM = MAX( BNORM, TEMP2 )
         BNORM = MAX( BNORM, TEMP2 )
 Lines 425-431    Link Here 
            END IF
            END IF
            NW = 1
            NW = 1
            IF( JE.LT.N ) THEN
            IF( JE.LT.N ) THEN
               IF( A( JE+1, JE ).NE.ZERO ) THEN
               IF( S( JE+1, JE ).NE.ZERO ) THEN
                  ILCPLX = .TRUE.
                  ILCPLX = .TRUE.
                  NW = 2
                  NW = 2
               END IF
               END IF
 Lines 444-451    Link Here 
*           (c) complex eigenvalue.
*           (c) complex eigenvalue.
*
*
            IF( .NOT.ILCPLX ) THEN
            IF( .NOT.ILCPLX ) THEN
               IF( ABS( A( JE, JE ) ).LE.SAFMIN .AND.
               IF( ABS( S( JE, JE ) ).LE.SAFMIN .AND.
     $             ABS( B( JE, JE ) ).LE.SAFMIN ) THEN
     $             ABS( P( JE, JE ) ).LE.SAFMIN ) THEN
*
*
*                 Singular matrix pencil -- return unit eigenvector
*                 Singular matrix pencil -- return unit eigenvector
*
*
 Lines 472-481    Link Here 
*
*
*              Real eigenvalue
*              Real eigenvalue
*
*
               TEMP = ONE / MAX( ABS( A( JE, JE ) )*ASCALE,
               TEMP = ONE / MAX( ABS( S( JE, JE ) )*ASCALE,
     $                ABS( B( JE, JE ) )*BSCALE, SAFMIN )
     $                ABS( P( JE, JE ) )*BSCALE, SAFMIN )
               SALFAR = ( TEMP*A( JE, JE ) )*ASCALE
               SALFAR = ( TEMP*S( JE, JE ) )*ASCALE
               SBETA = ( TEMP*B( JE, JE ) )*BSCALE
               SBETA = ( TEMP*P( JE, JE ) )*BSCALE
               ACOEF = SBETA*ASCALE
               ACOEF = SBETA*ASCALE
               BCOEFR = SALFAR*BSCALE
               BCOEFR = SALFAR*BSCALE
               BCOEFI = ZERO
               BCOEFI = ZERO
 Lines 517-523    Link Here 
*
*
*              Complex eigenvalue
*              Complex eigenvalue
*
*
               CALL DLAG2( A( JE, JE ), LDA, B( JE, JE ), LDB,
               CALL DLAG2( S( JE, JE ), LDS, P( JE, JE ), LDP,
     $                     SAFMIN*SAFETY, ACOEF, TEMP, BCOEFR, TEMP2,
     $                     SAFMIN*SAFETY, ACOEF, TEMP, BCOEFR, TEMP2,
     $                     BCOEFI )
     $                     BCOEFI )
               BCOEFI = -BCOEFI
               BCOEFI = -BCOEFI
 Lines 549-557    Link Here 
*
*
*              Compute first two components of eigenvector
*              Compute first two components of eigenvector
*
*
               TEMP = ACOEF*A( JE+1, JE )
               TEMP = ACOEF*S( JE+1, JE )
               TEMP2R = ACOEF*A( JE, JE ) - BCOEFR*B( JE, JE )
               TEMP2R = ACOEF*S( JE, JE ) - BCOEFR*P( JE, JE )
               TEMP2I = -BCOEFI*B( JE, JE )
               TEMP2I = -BCOEFI*P( JE, JE )
               IF( ABS( TEMP ).GT.ABS( TEMP2R )+ABS( TEMP2I ) ) THEN
               IF( ABS( TEMP ).GT.ABS( TEMP2R )+ABS( TEMP2I ) ) THEN
                  WORK( 2*N+JE ) = ONE
                  WORK( 2*N+JE ) = ONE
                  WORK( 3*N+JE ) = ZERO
                  WORK( 3*N+JE ) = ZERO
 Lines 560-569    Link Here 
               ELSE
               ELSE
                  WORK( 2*N+JE+1 ) = ONE
                  WORK( 2*N+JE+1 ) = ONE
                  WORK( 3*N+JE+1 ) = ZERO
                  WORK( 3*N+JE+1 ) = ZERO
                  TEMP = ACOEF*A( JE, JE+1 )
                  TEMP = ACOEF*S( JE, JE+1 )
                  WORK( 2*N+JE ) = ( BCOEFR*B( JE+1, JE+1 )-ACOEF*
                  WORK( 2*N+JE ) = ( BCOEFR*P( JE+1, JE+1 )-ACOEF*
     $                             A( JE+1, JE+1 ) ) / TEMP
     $                             S( JE+1, JE+1 ) ) / TEMP
                  WORK( 3*N+JE ) = BCOEFI*B( JE+1, JE+1 ) / TEMP
                  WORK( 3*N+JE ) = BCOEFI*P( JE+1, JE+1 ) / TEMP
               END IF
               END IF
               XMAX = MAX( ABS( WORK( 2*N+JE ) )+ABS( WORK( 3*N+JE ) ),
               XMAX = MAX( ABS( WORK( 2*N+JE ) )+ABS( WORK( 3*N+JE ) ),
     $                ABS( WORK( 2*N+JE+1 ) )+ABS( WORK( 3*N+JE+1 ) ) )
     $                ABS( WORK( 2*N+JE+1 ) )+ABS( WORK( 3*N+JE+1 ) ) )
 Lines 586-596    Link Here 
               END IF
               END IF
*
*
               NA = 1
               NA = 1
               BDIAG( 1 ) = B( J, J )
               BDIAG( 1 ) = P( J, J )
               IF( J.LT.N ) THEN
               IF( J.LT.N ) THEN
                  IF( A( J+1, J ).NE.ZERO ) THEN
                  IF( S( J+1, J ).NE.ZERO ) THEN
                     IL2BY2 = .TRUE.
                     IL2BY2 = .TRUE.
                     BDIAG( 2 ) = B( J+1, J+1 )
                     BDIAG( 2 ) = P( J+1, J+1 )
                     NA = 2
                     NA = 2
                  END IF
                  END IF
               END IF
               END IF
 Lines 616-628    Link Here 
*              Compute dot products
*              Compute dot products
*
*
*                    j-1
*                    j-1
*              SUM = sum  conjg( a*A(k,j) - b*B(k,j) )*x(k)
*              SUM = sum  conjg( a*S(k,j) - b*P(k,j) )*x(k)
*                    k=je
*                    k=je
*
*
*              To reduce the op count, this is done as
*              To reduce the op count, this is done as
*
*
*              _        j-1                  _        j-1
*              _        j-1                  _        j-1
*              a*conjg( sum  A(k,j)*x(k) ) - b*conjg( sum  B(k,j)*x(k) )
*              a*conjg( sum  S(k,j)*x(k) ) - b*conjg( sum  P(k,j)*x(k) )
*                       k=je                          k=je
*                       k=je                          k=je
*
*
*              which may cause underflow problems if A or B are close
*              which may cause underflow problems if A or B are close
 Lines 659-673    Link Here 
*$PL$ CMCHAR='*'
*$PL$ CMCHAR='*'
*
*
                  DO 110 JA = 1, NA
                  DO 110 JA = 1, NA
                     SUMA( JA, JW ) = ZERO
                     SUMS( JA, JW ) = ZERO
                     SUMB( JA, JW ) = ZERO
                     SUMP( JA, JW ) = ZERO
*
*
                     DO 100 JR = JE, J - 1
                     DO 100 JR = JE, J - 1
                        SUMA( JA, JW ) = SUMA( JA, JW ) +
                        SUMS( JA, JW ) = SUMS( JA, JW ) +
     $                                   A( JR, J+JA-1 )*
     $                                   S( JR, J+JA-1 )*
     $                                   WORK( ( JW+1 )*N+JR )
     $                                   WORK( ( JW+1 )*N+JR )
                        SUMB( JA, JW ) = SUMB( JA, JW ) +
                        SUMP( JA, JW ) = SUMP( JA, JW ) +
     $                                   B( JR, J+JA-1 )*
     $                                   P( JR, J+JA-1 )*
     $                                   WORK( ( JW+1 )*N+JR )
     $                                   WORK( ( JW+1 )*N+JR )
  100                CONTINUE
  100                CONTINUE
  110             CONTINUE
  110             CONTINUE
 Lines 687-701    Link Here 
*
*
               DO 130 JA = 1, NA
               DO 130 JA = 1, NA
                  IF( ILCPLX ) THEN
                  IF( ILCPLX ) THEN
                     SUM( JA, 1 ) = -ACOEF*SUMA( JA, 1 ) +
                     SUM( JA, 1 ) = -ACOEF*SUMS( JA, 1 ) +
     $                              BCOEFR*SUMB( JA, 1 ) -
     $                              BCOEFR*SUMP( JA, 1 ) -
     $                              BCOEFI*SUMB( JA, 2 )
     $                              BCOEFI*SUMP( JA, 2 )
                     SUM( JA, 2 ) = -ACOEF*SUMA( JA, 2 ) +
                     SUM( JA, 2 ) = -ACOEF*SUMS( JA, 2 ) +
     $                              BCOEFR*SUMB( JA, 2 ) +
     $                              BCOEFR*SUMP( JA, 2 ) +
     $                              BCOEFI*SUMB( JA, 1 )
     $                              BCOEFI*SUMP( JA, 1 )
                  ELSE
                  ELSE
                     SUM( JA, 1 ) = -ACOEF*SUMA( JA, 1 ) +
                     SUM( JA, 1 ) = -ACOEF*SUMS( JA, 1 ) +
     $                              BCOEFR*SUMB( JA, 1 )
     $                              BCOEFR*SUMP( JA, 1 )
                  END IF
                  END IF
  130          CONTINUE
  130          CONTINUE
*
*
 Lines 703-709    Link Here 
*              Solve  ( a A - b B )  y = SUM(,)
*              Solve  ( a A - b B )  y = SUM(,)
*              with scaling and perturbation of the denominator
*              with scaling and perturbation of the denominator
*
*
               CALL DLALN2( .TRUE., NA, NW, DMIN, ACOEF, A( J, J ), LDA,
               CALL DLALN2( .TRUE., NA, NW, DMIN, ACOEF, S( J, J ), LDS,
     $                      BDIAG( 1 ), BDIAG( 2 ), SUM, 2, BCOEFR,
     $                      BDIAG( 1 ), BDIAG( 2 ), SUM, 2, BCOEFR,
     $                      BCOEFI, WORK( 2*N+J ), N, SCALE, TEMP,
     $                      BCOEFI, WORK( 2*N+J ), N, SCALE, TEMP,
     $                      IINFO )
     $                      IINFO )
 Lines 790-796    Link Here 
            END IF
            END IF
            NW = 1
            NW = 1
            IF( JE.GT.1 ) THEN
            IF( JE.GT.1 ) THEN
               IF( A( JE, JE-1 ).NE.ZERO ) THEN
               IF( S( JE, JE-1 ).NE.ZERO ) THEN
                  ILCPLX = .TRUE.
                  ILCPLX = .TRUE.
                  NW = 2
                  NW = 2
               END IF
               END IF
 Lines 809-816    Link Here 
*           (c) complex eigenvalue.
*           (c) complex eigenvalue.
*
*
            IF( .NOT.ILCPLX ) THEN
            IF( .NOT.ILCPLX ) THEN
               IF( ABS( A( JE, JE ) ).LE.SAFMIN .AND.
               IF( ABS( S( JE, JE ) ).LE.SAFMIN .AND.
     $             ABS( B( JE, JE ) ).LE.SAFMIN ) THEN
     $             ABS( P( JE, JE ) ).LE.SAFMIN ) THEN
*
*
*                 Singular matrix pencil -- unit eigenvector
*                 Singular matrix pencil -- unit eigenvector
*
*
 Lines 839-848    Link Here 
*
*
*              Real eigenvalue
*              Real eigenvalue
*
*
               TEMP = ONE / MAX( ABS( A( JE, JE ) )*ASCALE,
               TEMP = ONE / MAX( ABS( S( JE, JE ) )*ASCALE,
     $                ABS( B( JE, JE ) )*BSCALE, SAFMIN )
     $                ABS( P( JE, JE ) )*BSCALE, SAFMIN )
               SALFAR = ( TEMP*A( JE, JE ) )*ASCALE
               SALFAR = ( TEMP*S( JE, JE ) )*ASCALE
               SBETA = ( TEMP*B( JE, JE ) )*BSCALE
               SBETA = ( TEMP*P( JE, JE ) )*BSCALE
               ACOEF = SBETA*ASCALE
               ACOEF = SBETA*ASCALE
               BCOEFR = SALFAR*BSCALE
               BCOEFR = SALFAR*BSCALE
               BCOEFI = ZERO
               BCOEFI = ZERO
 Lines 885-898    Link Here 
*              (See "Further Details", above.)
*              (See "Further Details", above.)
*
*
               DO 260 JR = 1, JE - 1
               DO 260 JR = 1, JE - 1
                  WORK( 2*N+JR ) = BCOEFR*B( JR, JE ) -
                  WORK( 2*N+JR ) = BCOEFR*P( JR, JE ) -
     $                             ACOEF*A( JR, JE )
     $                             ACOEF*S( JR, JE )
  260          CONTINUE
  260          CONTINUE
            ELSE
            ELSE
*
*
*              Complex eigenvalue
*              Complex eigenvalue
*
*
               CALL DLAG2( A( JE-1, JE-1 ), LDA, B( JE-1, JE-1 ), LDB,
               CALL DLAG2( S( JE-1, JE-1 ), LDS, P( JE-1, JE-1 ), LDP,
     $                     SAFMIN*SAFETY, ACOEF, TEMP, BCOEFR, TEMP2,
     $                     SAFMIN*SAFETY, ACOEF, TEMP, BCOEFR, TEMP2,
     $                     BCOEFI )
     $                     BCOEFI )
               IF( BCOEFI.EQ.ZERO ) THEN
               IF( BCOEFI.EQ.ZERO ) THEN
 Lines 924-932    Link Here 
*              Compute first two components of eigenvector
*              Compute first two components of eigenvector
*              and contribution to sums
*              and contribution to sums
*
*
               TEMP = ACOEF*A( JE, JE-1 )
               TEMP = ACOEF*S( JE, JE-1 )
               TEMP2R = ACOEF*A( JE, JE ) - BCOEFR*B( JE, JE )
               TEMP2R = ACOEF*S( JE, JE ) - BCOEFR*P( JE, JE )
               TEMP2I = -BCOEFI*B( JE, JE )
               TEMP2I = -BCOEFI*P( JE, JE )
               IF( ABS( TEMP ).GE.ABS( TEMP2R )+ABS( TEMP2I ) ) THEN
               IF( ABS( TEMP ).GE.ABS( TEMP2R )+ABS( TEMP2I ) ) THEN
                  WORK( 2*N+JE ) = ONE
                  WORK( 2*N+JE ) = ONE
                  WORK( 3*N+JE ) = ZERO
                  WORK( 3*N+JE ) = ZERO
 Lines 935-944    Link Here 
               ELSE
               ELSE
                  WORK( 2*N+JE-1 ) = ONE
                  WORK( 2*N+JE-1 ) = ONE
                  WORK( 3*N+JE-1 ) = ZERO
                  WORK( 3*N+JE-1 ) = ZERO
                  TEMP = ACOEF*A( JE-1, JE )
                  TEMP = ACOEF*S( JE-1, JE )
                  WORK( 2*N+JE ) = ( BCOEFR*B( JE-1, JE-1 )-ACOEF*
                  WORK( 2*N+JE ) = ( BCOEFR*P( JE-1, JE-1 )-ACOEF*
     $                             A( JE-1, JE-1 ) ) / TEMP
     $                             S( JE-1, JE-1 ) ) / TEMP
                  WORK( 3*N+JE ) = BCOEFI*B( JE-1, JE-1 ) / TEMP
                  WORK( 3*N+JE ) = BCOEFI*P( JE-1, JE-1 ) / TEMP
               END IF
               END IF
*
*
               XMAX = MAX( ABS( WORK( 2*N+JE ) )+ABS( WORK( 3*N+JE ) ),
               XMAX = MAX( ABS( WORK( 2*N+JE ) )+ABS( WORK( 3*N+JE ) ),
 Lines 958-969    Link Here 
               CRE2B = BCOEFR*WORK( 2*N+JE ) - BCOEFI*WORK( 3*N+JE )
               CRE2B = BCOEFR*WORK( 2*N+JE ) - BCOEFI*WORK( 3*N+JE )
               CIM2B = BCOEFI*WORK( 2*N+JE ) + BCOEFR*WORK( 3*N+JE )
               CIM2B = BCOEFI*WORK( 2*N+JE ) + BCOEFR*WORK( 3*N+JE )
               DO 270 JR = 1, JE - 2
               DO 270 JR = 1, JE - 2
                  WORK( 2*N+JR ) = -CREALA*A( JR, JE-1 ) +
                  WORK( 2*N+JR ) = -CREALA*S( JR, JE-1 ) +
     $                             CREALB*B( JR, JE-1 ) -
     $                             CREALB*P( JR, JE-1 ) -
     $                             CRE2A*A( JR, JE ) + CRE2B*B( JR, JE )
     $                             CRE2A*S( JR, JE ) + CRE2B*P( JR, JE )
                  WORK( 3*N+JR ) = -CIMAGA*A( JR, JE-1 ) +
                  WORK( 3*N+JR ) = -CIMAGA*S( JR, JE-1 ) +
     $                             CIMAGB*B( JR, JE-1 ) -
     $                             CIMAGB*P( JR, JE-1 ) -
     $                             CIM2A*A( JR, JE ) + CIM2B*B( JR, JE )
     $                             CIM2A*S( JR, JE ) + CIM2B*P( JR, JE )
  270          CONTINUE
  270          CONTINUE
            END IF
            END IF
*
*
 Lines 978-1000    Link Here 
*              next iteration to process it (when it will be j:j+1)
*              next iteration to process it (when it will be j:j+1)
*
*
               IF( .NOT.IL2BY2 .AND. J.GT.1 ) THEN
               IF( .NOT.IL2BY2 .AND. J.GT.1 ) THEN
                  IF( A( J, J-1 ).NE.ZERO ) THEN
                  IF( S( J, J-1 ).NE.ZERO ) THEN
                     IL2BY2 = .TRUE.
                     IL2BY2 = .TRUE.
                     GO TO 370
                     GO TO 370
                  END IF
                  END IF
               END IF
               END IF
               BDIAG( 1 ) = B( J, J )
               BDIAG( 1 ) = P( J, J )
               IF( IL2BY2 ) THEN
               IF( IL2BY2 ) THEN
                  NA = 2
                  NA = 2
                  BDIAG( 2 ) = B( J+1, J+1 )
                  BDIAG( 2 ) = P( J+1, J+1 )
               ELSE
               ELSE
                  NA = 1
                  NA = 1
               END IF
               END IF
*
*
*              Compute x(j) (and x(j+1), if 2-by-2 block)
*              Compute x(j) (and x(j+1), if 2-by-2 block)
*
*
               CALL DLALN2( .FALSE., NA, NW, DMIN, ACOEF, A( J, J ),
               CALL DLALN2( .FALSE., NA, NW, DMIN, ACOEF, S( J, J ),
     $                      LDA, BDIAG( 1 ), BDIAG( 2 ), WORK( 2*N+J ),
     $                      LDS, BDIAG( 1 ), BDIAG( 2 ), WORK( 2*N+J ),
     $                      N, BCOEFR, BCOEFI, SUM, 2, SCALE, TEMP,
     $                      N, BCOEFR, BCOEFI, SUM, 2, SCALE, TEMP,
     $                      IINFO )
     $                      IINFO )
               IF( SCALE.LT.ONE ) THEN
               IF( SCALE.LT.ONE ) THEN
 Lines 1014-1020    Link Here 
  300             CONTINUE
  300             CONTINUE
  310          CONTINUE
  310          CONTINUE
*
*
*              w = w + x(j)*(a A(*,j) - b B(*,j) ) with scaling
*              w = w + x(j)*(a S(*,j) - b P(*,j) ) with scaling
*
*
               IF( J.GT.1 ) THEN
               IF( J.GT.1 ) THEN
*
*
 Lines 1052-1070    Link Here 
     $                           BCOEFR*WORK( 3*N+J+JA-1 )
     $                           BCOEFR*WORK( 3*N+J+JA-1 )
                        DO 340 JR = 1, J - 1
                        DO 340 JR = 1, J - 1
                           WORK( 2*N+JR ) = WORK( 2*N+JR ) -
                           WORK( 2*N+JR ) = WORK( 2*N+JR ) -
     $                                      CREALA*A( JR, J+JA-1 ) +
     $                                      CREALA*S( JR, J+JA-1 ) +
     $                                      CREALB*B( JR, J+JA-1 )
     $                                      CREALB*P( JR, J+JA-1 )
                           WORK( 3*N+JR ) = WORK( 3*N+JR ) -
                           WORK( 3*N+JR ) = WORK( 3*N+JR ) -
     $                                      CIMAGA*A( JR, J+JA-1 ) +
     $                                      CIMAGA*S( JR, J+JA-1 ) +
     $                                      CIMAGB*B( JR, J+JA-1 )
     $                                      CIMAGB*P( JR, J+JA-1 )
  340                   CONTINUE
  340                   CONTINUE
                     ELSE
                     ELSE
                        CREALA = ACOEF*WORK( 2*N+J+JA-1 )
                        CREALA = ACOEF*WORK( 2*N+J+JA-1 )
                        CREALB = BCOEFR*WORK( 2*N+J+JA-1 )
                        CREALB = BCOEFR*WORK( 2*N+J+JA-1 )
                        DO 350 JR = 1, J - 1
                        DO 350 JR = 1, J - 1
                           WORK( 2*N+JR ) = WORK( 2*N+JR ) -
                           WORK( 2*N+JR ) = WORK( 2*N+JR ) -
     $                                      CREALA*A( JR, J+JA-1 ) +
     $                                      CREALA*S( JR, J+JA-1 ) +
     $                                      CREALB*B( JR, J+JA-1 )
     $                                      CREALB*P( JR, J+JA-1 )
  350                   CONTINUE
  350                   CONTINUE
                     END IF
                     END IF
  360             CONTINUE
  360             CONTINUE
(-) LAPACK/SRC/dtrevc.f (-55 / +32 lines)
 Lines 4-10    Link Here 
*  -- LAPACK routine (version 3.0) --
*  -- LAPACK routine (version 3.0) --
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
*     Courant Institute, Argonne National Lab, and Rice University
*     Courant Institute, Argonne National Lab, and Rice University
*     June 30, 1999
*     May 7, 2001 
*
*
*     .. Scalar Arguments ..
*     .. Scalar Arguments ..
      CHARACTER          HOWMNY, SIDE
      CHARACTER          HOWMNY, SIDE
 Lines 21-48    Link Here 
*
*
*  DTREVC computes some or all of the right and/or left eigenvectors of
*  DTREVC computes some or all of the right and/or left eigenvectors of
*  a real upper quasi-triangular matrix T.
*  a real upper quasi-triangular matrix T.
*
*  Matrices of this type are produced by the Schur factorization of
*  a real general matrix:  A = Q*T*Q**T, as computed by DHSEQR.
*  
*  The right eigenvector x and the left eigenvector y of T corresponding
*  The right eigenvector x and the left eigenvector y of T corresponding
*  to an eigenvalue w are defined by:
*  to an eigenvalue w are defined by:
*
*  
*               T*x = w*x,     y'*T = w*y'
*     T*x = w*x,     (y**H)*T = w*(y**H)
*
*  
*  where y' denotes the conjugate transpose of the vector y.
*  where y**H denotes the conjugate transpose of y.
*
*  The eigenvalues are not input to this routine, but are read directly
*  If all eigenvectors are requested, the routine may either return the
*  from the diagonal blocks of T.
*  matrices X and/or Y of right or left eigenvectors of T, or the
*  
*  products Q*X and/or Q*Y, where Q is an input orthogonal
*  This routine returns the matrices X and/or Y of right and left
*  matrix. If T was obtained from the real-Schur factorization of an
*  eigenvectors of T, or the products Q*X and/or Q*Y, where Q is an
*  original matrix A = Q*T*Q', then Q*X and Q*Y are the matrices of
*  input matrix.  If Q is the orthogonal factor that reduces a matrix
*  right or left eigenvectors of A.
*  A to Schur form T, then Q*X and Q*Y are the matrices of right and
*
*  left eigenvectors of A.
*  T must be in Schur canonical form (as returned by DHSEQR), that is,
*  block upper triangular with 1-by-1 and 2-by-2 diagonal blocks; each
*  2-by-2 diagonal block has its diagonal elements equal and its
*  off-diagonal elements of opposite sign.  Corresponding to each 2-by-2
*  diagonal block is a complex conjugate pair of eigenvalues and
*  eigenvectors; only one eigenvector of the pair is computed, namely
*  the one corresponding to the eigenvalue with positive imaginary part.
*
*
*  Arguments
*  Arguments
*  =========
*  =========
 Lines 55-75    Link Here 
*  HOWMNY  (input) CHARACTER*1
*  HOWMNY  (input) CHARACTER*1
*          = 'A':  compute all right and/or left eigenvectors;
*          = 'A':  compute all right and/or left eigenvectors;
*          = 'B':  compute all right and/or left eigenvectors,
*          = 'B':  compute all right and/or left eigenvectors,
*                  and backtransform them using the input matrices
*                  backtransformed by the matrices in VR and/or VL;
*                  supplied in VR and/or VL;
*          = 'S':  compute selected right and/or left eigenvectors,
*          = 'S':  compute selected right and/or left eigenvectors,
*                  specified by the logical array SELECT.
*                  as indicated by the logical array SELECT.
*
*
*  SELECT  (input/output) LOGICAL array, dimension (N)
*  SELECT  (input/output) LOGICAL array, dimension (N)
*          If HOWMNY = 'S', SELECT specifies the eigenvectors to be
*          If HOWMNY = 'S', SELECT specifies the eigenvectors to be
*          computed.
*          computed.
*          If HOWMNY = 'A' or 'B', SELECT is not referenced.
*          If w(j) is a real eigenvalue, the corresponding real
*          To select the real eigenvector corresponding to a real
*          eigenvector is computed if SELECT(j) is .TRUE..
*          eigenvalue w(j), SELECT(j) must be set to .TRUE..  To select
*          If w(j) and w(j+1) are the real and imaginary parts of a
*          the complex eigenvector corresponding to a complex conjugate
*          complex eigenvalue, the corresponding complex eigenvector is
*          pair w(j) and w(j+1), either SELECT(j) or SELECT(j+1) must be
*          computed if either SELECT(j) or SELECT(j+1) is .TRUE., and
*          set to .TRUE.; then on exit SELECT(j) is .TRUE. and
*          on exit SELECT(j) is set to .TRUE. and SELECT(j+1) is set to
*          SELECT(j+1) is .FALSE..
*          .FALSE..
*          Not referenced if HOWMNY = 'A' or 'B'.
*
*
*  N       (input) INTEGER
*  N       (input) INTEGER
*          The order of the matrix T. N >= 0.
*          The order of the matrix T. N >= 0.
 Lines 86-100    Link Here 
*          of Schur vectors returned by DHSEQR).
*          of Schur vectors returned by DHSEQR).
*          On exit, if SIDE = 'L' or 'B', VL contains:
*          On exit, if SIDE = 'L' or 'B', VL contains:
*          if HOWMNY = 'A', the matrix Y of left eigenvectors of T;
*          if HOWMNY = 'A', the matrix Y of left eigenvectors of T;
*                           VL has the same quasi-lower triangular form
*                           as T'. If T(i,i) is a real eigenvalue, then
*                           the i-th column VL(i) of VL  is its
*                           corresponding eigenvector. If T(i:i+1,i:i+1)
*                           is a 2-by-2 block whose eigenvalues are
*                           complex-conjugate eigenvalues of T, then
*                           VL(i)+sqrt(-1)*VL(i+1) is the complex
*                           eigenvector corresponding to the eigenvalue
*                           with positive real part.
*          if HOWMNY = 'B', the matrix Q*Y;
*          if HOWMNY = 'B', the matrix Q*Y;
*          if HOWMNY = 'S', the left eigenvectors of T specified by
*          if HOWMNY = 'S', the left eigenvectors of T specified by
*                           SELECT, stored consecutively in the columns
*                           SELECT, stored consecutively in the columns
 Lines 103-113    Link Here 
*          A complex eigenvector corresponding to a complex eigenvalue
*          A complex eigenvector corresponding to a complex eigenvalue
*          is stored in two consecutive columns, the first holding the
*          is stored in two consecutive columns, the first holding the
*          real part, and the second the imaginary part.
*          real part, and the second the imaginary part.
*          If SIDE = 'R', VL is not referenced.
*          Not referenced if SIDE = 'R'.
*
*
*  LDVL    (input) INTEGER
*  LDVL    (input) INTEGER
*          The leading dimension of the array VL.  LDVL >= max(1,N) if
*          The leading dimension of the array VL.  LDVL >= 1, and if
*          SIDE = 'L' or 'B'; LDVL >= 1 otherwise.
*          SIDE = 'L' or 'B', LDVL >= N.
*
*
*  VR      (input/output) DOUBLE PRECISION array, dimension (LDVR,MM)
*  VR      (input/output) DOUBLE PRECISION array, dimension (LDVR,MM)
*          On entry, if SIDE = 'R' or 'B' and HOWMNY = 'B', VR must
*          On entry, if SIDE = 'R' or 'B' and HOWMNY = 'B', VR must
 Lines 115-129    Link Here 
*          of Schur vectors returned by DHSEQR).
*          of Schur vectors returned by DHSEQR).
*          On