|
|
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), |
|
|
* ========= | * ========= |
* | * |
* 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. |
|
|
* 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 |
* =============== | * =============== |
|
|
$ 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 |
|
|
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 |
|
|
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 ) |
|
|
* 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 |
|
|
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 |
|
|
* 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 |
* | * |
|
|
* | * |
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 |
* | * |
|
|
* | * |
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 |
* | * |
|
|
* | * |
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 |
|
|
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 ) |
|
|
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 |
|
|
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. |
* | * |
|
|
* 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 |
|
|
* 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 |
|
|
* 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 ) ) ) |
|
|
* | * |
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 |
* | * |
|
|
* | * |
* 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 |
|
|
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 |
|
|
* 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 |
|
|
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, |
|
|
$ 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 |
|
|
* | * |
* 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, |
|
|
* | * |
* 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 ) |
|
|
* | * |
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 |
|
|
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 |
* | * |
|
|
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 |
* | * |
|
|
* | * |
* 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 |
|
|
* 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 |
|
|
* 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. |
|
|
* | * |
* 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 |
|
|
* 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 |
|
|
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 |
|
|
* 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 |
|
|
* | * |
* 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 |
|
|
* 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 |
|
|
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 |