exchqz.f

Go to the documentation of this file.
00001       SUBROUTINE EXCHQZ(NMAX, N, A, B, Z, L, LS1, LS2, EPS, FAIL)
00002       INTEGER NMAX, N, L, LS1, LS2
00003       DOUBLE PRECISION A(NMAX,N), B(NMAX,N), Z(NMAX,N), EPS
00004       LOGICAL FAIL
00005 c modified july 9, 1998 a.s.hodel@eng.auburn.edu:
00006 c     REAL changed to DOUBLE PRECISION
00007 c     calls to AMAX1 changed to call MAX instead.
00008 c     calls to SROT  changed to DROT  (both in BLAS)
00009 c     calls to giv changed to dlartg (LAPACK); required new variable tempr
00010 C*
00011 C* GIVEN THE UPPER TRIANGULAR MATRIX B AND UPPER HESSENBERG MATRIX A
00012 C* WITH CONSECUTIVE LS1XLS1 AND LS2XLS2 DIAGONAL BLOCKS (LS1,LS2.LE.2)
00013 C* STARTING AT ROW/COLUMN L, EXCHQZ PRODUCES EQUIVALENCE TRANSFORMA-
00014 C* TIONS QT AND ZT THAT EXCHANGE THE BLOCKS ALONG WITH THEIR GENERALIZED
00015 C* EIGENVALUES. EXCHQZ REQUIRES THE SUBROUTINES DROT (BLAS) AND GIV.
00016 C* THE PARAMETERS IN THE CALLING SEQUENCE ARE (STARRED PARAMETERS ARE
00017 C* ALTERED BY THE SUBROUTINE):
00018 C*
00019 C*    NMAX     THE FIRST DIMENSION OF A, B AND Z
00020 C*    N        THE ORDER OF A, B AND Z
00021 C*   *A,*B     THE MATRIX PAIR WHOSE BLOCKS ARE TO BE INTERCHANGED
00022 C*   *Z        UPON RETURN THIS ARRAY IS MULTIPLIED BY THE COLUMN
00023 C*             TRANSFORMATION ZT.
00024 C*    L        THE POSITION OF THE BLOCKS
00025 C*    LS1      THE SIZE OF THE FIRST BLOCK
00026 C*    LS2      THE SIZE OF THE SECOND BLOCK
00027 C*    EPS      THE REQUIRED ABSOLUTE ACCURACY OF THE RESULT
00028 C*   *FAIL     A LOGICAL VARIABLE WHICH IS FALSE ON A NORMAL RETURN,
00029 C*             TRUE OTHERWISE.
00030 C*
00031       INTEGER I, J, L1, L2, L3, LI, LJ, LL, IT1, IT2
00032       DOUBLE PRECISION U(3,3), D, E, F, G, SA, SB, A11B11, A21B11,
00033      * A12B22, B12B22,
00034      * A22B22, AMMBMM, ANMBMM, AMNBNN, BMNBNN, ANNBNN, TEMPR
00035       LOGICAL ALTB
00036       FAIL = .FALSE.
00037       L1 = L + 1
00038       LL = LS1 + LS2
00039       IF (LL.GT.2) GO TO 10
00040 C*** INTERCHANGE 1X1 AND 1X1 BLOCKS VIA AN EQUIVALENCE
00041 C*** TRANSFORMATION       A:=Q*A*Z , B:=Q*B*Z
00042 C*** WHERE Q AND Z ARE GIVENS ROTATIONS
00043       F = MAX(ABS(A(L1,L1)),ABS(B(L1,L1)))
00044       ALTB = .TRUE.
00045       IF (ABS(A(L1,L1)).GE.F) ALTB = .FALSE.
00046       SA = A(L1,L1)/F
00047       SB = B(L1,L1)/F
00048       F = SA*B(L,L) - SB*A(L,L)
00049 C* CONSTRUCT THE COLUMN TRANSFORMATION Z
00050       G = SA*B(L,L1) - SB*A(L,L1)
00051       CALL DLARTG(F, G, D, E,TEMPR)
00052       CALL DROT(L1, A(1,L), 1, A(1,L1), 1, E, -D)
00053       CALL DROT(L1, B(1,L), 1, B(1,L1), 1, E, -D)
00054       CALL DROT(N, Z(1,L), 1, Z(1,L1), 1, E, -D)
00055 C* CONSTRUCT THE ROW TRANSFORMATION Q
00056       IF (ALTB) CALL DLARTG(B(L,L), B(L1,L), D, E,TEMPR)
00057       IF (.NOT.ALTB) CALL DLARTG(A(L,L), A(L1,L), D, E,TEMPR)
00058       CALL DROT(N-L+1, A(L,L), NMAX, A(L1,L), NMAX, D, E)
00059       CALL DROT(N-L+1, B(L,L), NMAX, B(L1,L), NMAX, D, E)
00060       A(L1,L) = 0.
00061       B(L1,L) = 0.
00062       RETURN
00063 C*** INTERCHANGE 1X1 AND 2X2 BLOCKS VIA AN EQUIVALENCE
00064 C*** TRANSFORMATION  A:=Q2*Q1*A*Z1*Z2 , B:=Q2*Q1*B*Z1*Z2
00065 C*** WHERE EACH QI AND ZI IS A GIVENS ROTATION
00066    10 L2 = L + 2
00067       IF (LS1.EQ.2) GO TO 60
00068       G = MAX(ABS(A(L,L)),ABS(B(L,L)))
00069       ALTB = .TRUE.
00070       IF (ABS(A(L,L)).LT.G) GO TO 20
00071       ALTB = .FALSE.
00072       CALL DLARTG(A(L1,L1), A(L2,L1), D, E,TEMPR)
00073       CALL DROT(N-L, A(L1,L1), NMAX, A(L2,L1), NMAX, D, E)
00074       CALL DROT(N-L, B(L1,L1), NMAX, B(L2,L1), NMAX, D, E)
00075 C**  EVALUATE THE PENCIL AT THE EIGENVALUE CORRESPONDING
00076 C**  TO THE 1X1 BLOCK
00077    20 SA = A(L,L)/G
00078       SB = B(L,L)/G
00079       DO 40 J=1,2
00080         LJ = L + J
00081         DO 30 I=1,3
00082           LI = L + I - 1
00083           U(I,J) = SA*B(LI,LJ) - SB*A(LI,LJ)
00084    30   CONTINUE
00085    40 CONTINUE
00086       CALL DLARTG(U(3,1), U(3,2), D, E,TEMPR)
00087       CALL DROT(3, U(1,1), 1, U(1,2), 1, E, -D)
00088 C* PERFORM THE ROW TRANSFORMATION Q1
00089       CALL DLARTG(U(1,1), U(2,1), D, E,TEMPR)
00090       U(2,2) = -U(1,2)*E + U(2,2)*D
00091       CALL DROT(N-L+1, A(L,L), NMAX, A(L1,L), NMAX, D, E)
00092       CALL DROT(N-L+1, B(L,L), NMAX, B(L1,L), NMAX, D, E)
00093 C* PERFORM THE COLUMN TRANSFORMATION Z1
00094       IF (ALTB) CALL DLARTG(B(L1,L), B(L1,L1), D, E,TEMPR)
00095       IF (.NOT.ALTB) CALL DLARTG(A(L1,L), A(L1,L1), D, E,TEMPR)
00096       CALL DROT(L2, A(1,L), 1, A(1,L1), 1, E, -D)
00097       CALL DROT(L2, B(1,L), 1, B(1,L1), 1, E, -D)
00098       CALL DROT(N, Z(1,L), 1, Z(1,L1), 1, E, -D)
00099 C* PERFORM THE ROW TRANSFORMATION Q2
00100       CALL DLARTG(U(2,2), U(3,2), D, E,TEMPR)
00101       CALL DROT(N-L+1, A(L1,L), NMAX, A(L2,L), NMAX, D, E)
00102       CALL DROT(N-L+1, B(L1,L), NMAX, B(L2,L), NMAX, D, E)
00103 C* PERFORM THE COLUMN TRANSFORMATION Z2
00104       IF (ALTB) CALL DLARTG(B(L2,L1), B(L2,L2), D, E,TEMPR)
00105       IF (.NOT.ALTB) CALL DLARTG(A(L2,L1), A(L2,L2), D, E,TEMPR)
00106       CALL DROT(L2, A(1,L1), 1, A(1,L2), 1, E, -D)
00107       CALL DROT(L2, B(1,L1), 1, B(1,L2), 1, E, -D)
00108       CALL DROT(N, Z(1,L1), 1, Z(1,L2), 1, E, -D)
00109       IF (ALTB) GO TO 50
00110       CALL DLARTG(B(L,L), B(L1,L), D, E,TEMPR)
00111       CALL DROT(N-L+1, A(L,L), NMAX, A(L1,L), NMAX, D, E)
00112       CALL DROT(N-L+1, B(L,L), NMAX, B(L1,L), NMAX, D, E)
00113 C*  PUT THE NEGLECTABLE ELEMENTS EQUAL TO ZERO
00114    50 A(L2,L) = 0.
00115       A(L2,L1) = 0.
00116       B(L1,L) = 0.
00117       B(L2,L) = 0.
00118       B(L2,L1) = 0.
00119       RETURN
00120 C*** INTERCHANGE 2X2 AND 1X1 BLOCKS VIA AN EQUIVALENCE
00121 C*** TRANSFORMATION  A:=Q2*Q1*A*Z1*Z2 , B:=Q2*Q1*B*Z1*Z2
00122 C*** WHERE EACH QI AND ZI IS A GIVENS ROTATION
00123    60 IF (LS2.EQ.2) GO TO 110
00124       G = MAX(ABS(A(L2,L2)),ABS(B(L2,L2)))
00125       ALTB = .TRUE.
00126       IF (ABS(A(L2,L2)).LT.G) GO TO 70
00127       ALTB = .FALSE.
00128       CALL DLARTG(A(L,L), A(L1,L), D, E,TEMPR)
00129       CALL DROT(N-L+1, A(L,L), NMAX, A(L1,L), NMAX, D, E)
00130       CALL DROT(N-L+1, B(L,L), NMAX, B(L1,L), NMAX, D, E)
00131 C**  EVALUATE THE PENCIL AT THE EIGENVALUE CORRESPONDING
00132 C**  TO THE 1X1 BLOCK
00133    70 SA = A(L2,L2)/G
00134       SB = B(L2,L2)/G
00135       DO 90 I=1,2
00136         LI = L + I - 1
00137         DO 80 J=1,3
00138           LJ = L + J - 1
00139           U(I,J) = SA*B(LI,LJ) - SB*A(LI,LJ)
00140    80   CONTINUE
00141    90 CONTINUE
00142       CALL DLARTG(U(1,1), U(2,1), D, E,TEMPR)
00143       CALL DROT(3, U(1,1), 3, U(2,1), 3, D, E)
00144 C* PERFORM THE COLUMN TRANSFORMATION Z1
00145       CALL DLARTG(U(2,2), U(2,3), D, E,TEMPR)
00146       U(1,2) = U(1,2)*E - U(1,3)*D
00147       CALL DROT(L2, A(1,L1), 1, A(1,L2), 1, E, -D)
00148       CALL DROT(L2, B(1,L1), 1, B(1,L2), 1, E, -D)
00149       CALL DROT(N, Z(1,L1), 1, Z(1,L2), 1, E, -D)
00150 C* PERFORM THE ROW TRANSFORMATION Q1
00151       IF (ALTB) CALL DLARTG(B(L1,L1), B(L2,L1), D, E,TEMPR)
00152       IF (.NOT.ALTB) CALL DLARTG(A(L1,L1), A(L2,L1), D, E,TEMPR)
00153       CALL DROT(N-L+1, A(L1,L), NMAX, A(L2,L), NMAX, D, E)
00154       CALL DROT(N-L+1, B(L1,L), NMAX, B(L2,L), NMAX, D, E)
00155 C* PERFORM THE COLUMN TRANSFORMATION Z2
00156       CALL DLARTG(U(1,1), U(1,2), D, E,TEMPR)
00157       CALL DROT(L2, A(1,L), 1, A(1,L1), 1, E, -D)
00158       CALL DROT(L2, B(1,L), 1, B(1,L1), 1, E, -D)
00159       CALL DROT(N, Z(1,L), 1, Z(1,L1), 1, E, -D)
00160 C* PERFORM THE ROW TRANSFORMATION Q2
00161       IF (ALTB) CALL DLARTG(B(L,L), B(L1,L), D, E,TEMPR)
00162       IF (.NOT.ALTB) CALL DLARTG(A(L,L), A(L1,L), D, E,TEMPR)
00163       CALL DROT(N-L+1, A(L,L), NMAX, A(L1,L), NMAX, D, E)
00164       CALL DROT(N-L+1, B(L,L), NMAX, B(L1,L), NMAX, D, E)
00165       IF (ALTB) GO TO 100
00166       CALL DLARTG(B(L1,L1), B(L2,L1), D, E,TEMPR)
00167       CALL DROT(N-L, A(L1,L1), NMAX, A(L2,L1), NMAX, D, E)
00168       CALL DROT(N-L, B(L1,L1), NMAX, B(L2,L1), NMAX, D, E)
00169 C*  PUT THE NEGLECTABLE ELEMENTS EQUAL TO ZERO
00170   100 A(L1,L) = 0.
00171       A(L2,L) = 0.
00172       B(L1,L) = 0.
00173       B(L2,1) = 0.
00174       B(L2,L1) = 0.
00175       RETURN
00176 C*** INTERCHANGE 2X2 AND 2X2 BLOCKS VIA A SEQUENCE OF
00177 C*** QZ-STEPS REALIZED BY THE EQUIVALENCE TRANSFORMATIONS
00178 C***          A:=Q5*Q4*Q3*Q2*Q1*A*Z1*Z2*Z3*Z4*Z5
00179 C***          B:=Q5*Q4*Q3*Q2*Q1*B*Z1*Z2*Z3*Z4*Z5
00180 C*** WHERE EACH QI AND ZI IS A GIVENS ROTATION
00181   110 L3 = L + 3
00182 C* COMPUTE IMPLICIT SHIFT
00183       AMMBMM = A(L,L)/B(L,L)
00184       ANMBMM = A(L1,L)/B(L,L)
00185       AMNBNN = A(L,L1)/B(L1,L1)
00186       ANNBNN = A(L1,L1)/B(L1,L1)
00187       BMNBNN = B(L,L1)/B(L1,L1)
00188       DO 130 IT1=1,3
00189         U(1,1) = 1.
00190         U(2,1) = 1.
00191         U(3,1) = 1.
00192         DO 120 IT2=1,10
00193 C* PERFORM ROW TRANSFORMATIONS Q1 AND Q2
00194           CALL DLARTG(U(2,1), U(3,1), D, E,TEMPR)
00195           CALL DROT(N-L+1, A(L1,L), NMAX, A(L2,L), NMAX, D, E)
00196           CALL DROT(N-L, B(L1,L1), NMAX, B(L2,L1), NMAX, D, E)
00197           U(2,1) = D*U(2,1) + E*U(3,1)
00198           CALL DLARTG(U(1,1), U(2,1), D, E,TEMPR)
00199           CALL DROT(N-L+1, A(L,L), NMAX, A(L1,L), NMAX, D, E)
00200           CALL DROT(N-L+1, B(L,L), NMAX, B(L1,L), NMAX, D, E)
00201 C* PERFORM COLUMN TRANSFORMATIONS Z1 AND Z2
00202           CALL DLARTG(B(L2,L1), B(L2,L2), D, E,TEMPR)
00203           CALL DROT(L3, A(1,L1), 1, A(1,L2), 1, E, -D)
00204           CALL DROT(L2, B(1,L1), 1, B(1,L2), 1, E, -D)
00205           CALL DROT(N, Z(1,L1), 1, Z(1,L2), 1, E, -D)
00206           CALL DLARTG(B(L1,L), B(L1,L1), D, E,TEMPR)
00207           CALL DROT(L3, A(1,L), 1, A(1,L1), 1, E, -D)
00208           CALL DROT(L1, B(1,L), 1, B(1,L1), 1, E, -D)
00209           CALL DROT(N, Z(1,L), 1, Z(1,L1), 1, E, -D)
00210 C* PERFORM TRANSFORMATIONS Q3,Z3,Q4,Z4,Q5 AND Z5 IN
00211 C* ORDER TO REDUCE THE PENCIL TO HESSENBERG FORM
00212           CALL DLARTG(A(L2,L), A(L3,L), D, E,TEMPR)
00213           CALL DROT(N-L+1, A(L2,L), NMAX, A(L3,L), NMAX, D, E)
00214           CALL DROT(N-L1, B(L2,L2), NMAX, B(L3,L2), NMAX, D, E)
00215           CALL DLARTG(B(L3,L2), B(L3,L3), D, E,TEMPR)
00216           CALL DROT(L3, A(1,L2), 1, A(1,L3), 1, E, -D)
00217           CALL DROT(L3, B(1,L2), 1, B(1,L3), 1, E, -D)
00218           CALL DROT(N, Z(1,L2), 1, Z(1,L3), 1, E, -D)
00219           CALL DLARTG(A(L1,L), A(L2,L), D, E,TEMPR)
00220           CALL DROT(N-L+1, A(L1,L), NMAX, A(L2,L), NMAX, D, E)
00221           CALL DROT(N-L, B(L1,L1), NMAX, B(L2,L1), NMAX, D, E)
00222           CALL DLARTG(B(L2,L1), B(L2,L2), D, E,TEMPR)
00223           CALL DROT(L3, A(1,L1), 1, A(1,L2), 1, E, -D)
00224           CALL DROT(L2, B(1,L1), 1, B(1,L2), 1, E, -D)
00225           CALL DROT(N, Z(1,L1), 1, Z(1,L2), 1, E, -D)
00226           CALL DLARTG(A(L2,L1), A(L3,L1), D, E,TEMPR)
00227           CALL DROT(N-L, A(L2,L1), NMAX, A(L3,L1), NMAX, D, E)
00228           CALL DROT(N-L1, B(L2,L2), NMAX, B(L3,L2), NMAX, D, E)
00229           CALL DLARTG(B(L3,L2), B(L3,L3), D, E,TEMPR)
00230           CALL DROT(L3, A(1,L2), 1, A(1,L3), 1, E, -D)
00231           CALL DROT(L3, B(1,L2), 1, B(1,L3), 1, E, -D)
00232           CALL DROT(N, Z(1,L2), 1, Z(1,L3), 1, E, -D)
00233 C* TEST OF CONVERGENCE ON THE ELEMENT SEPARATING THE BLOCKS
00234           IF (ABS(A(L2,L1)).LE.EPS) GO TO 140
00235 C* COMPUTE A NEW SHIFT IN CASE OF NO CONVERGENCE
00236           A11B11 = A(L,L)/B(L,L)
00237           A12B22 = A(L,L1)/B(L1,L1)
00238           A21B11 = A(L1,L)/B(L,L)
00239           A22B22 = A(L1,L1)/B(L1,L1)
00240           B12B22 = B(L,L1)/B(L1,L1)
00241           U(1,1) = ((AMMBMM-A11B11)*(ANNBNN-A11B11)-AMNBNN*
00242      *     ANMBMM+ANMBMM*BMNBNN*A11B11)/A21B11 + A12B22 - A11B11*B12B22
00243           U(2,1) = (A22B22-A11B11) - A21B11*B12B22 - (AMMBMM-A11B11) -
00244      *     (ANNBNN-A11B11) + ANMBMM*BMNBNN
00245           U(3,1) = A(L2,L1)/B(L1,L1)
00246   120   CONTINUE
00247   130 CONTINUE
00248       FAIL = .TRUE.
00249       RETURN
00250 C*  PUT THE NEGLECTABLE ELEMENTS EQUAL TO ZERO IN
00251 C*  CASE OF CONVERGENCE
00252   140 A(L2,L) = 0.
00253       A(L2,L1) = 0.
00254       A(L3,L) = 0.
00255       A(L3,L1) = 0.
00256       B(L1,L) = 0.
00257       B(L2,L) = 0.
00258       B(L2,L1) = 0.
00259       B(L3,L) = 0.
00260       B(L3,L1) = 0.
00261       B(L3,L2) = 0.
00262       RETURN
00263       END
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines