sexchqz.f

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