An Algorithm For The Generalized Matrix Eigenvalue
An Algorithm For The Generalized Matrix Eigenvalue
net/publication/235012188
CITATIONS READS
79 1,584
2 authors, including:
Cleve Moler
The MathWorks, Inc
133 PUBLICATIONS 13,457 CITATIONS
SEE PROFILE
All content following this page was uploaded by Cleve Moler on 02 January 2014.
MU,
AN ALGORITHM FOR THE GENERALIZED MATRIX
by
C. B. Moler
Stanford University
G. W. Stewart
jDJ3TiT~~h SA~ii1r A
o r .:u*-,ic rcle0se;
Reprocluced by U.- C e;
NATIONAL TECHNICAL £r;. " '..i...
INFORMATION SERVICE
UDpartmort
of Commerce CENTER FOR NUMERICAL ANALYSIS
Springfild VA 22151
sl"OOO/c%$7.d o/0 2-
AN ALGORITHM FOR THE GENERALIZED
Ax =%Bx
by
C. B. Moler
Computer Science Department
Stanford University
Department of Mathematics
University of Michigan
and
G. W. Stewart
Departments of Computer Science and Mathematics
University of Texas at Austin
Abstract
i
AN ALGORITHM FOR THE GENERALIZED
C. B. Moler:/
-
G. W. Stewartf.
1. Introduction
Ax = Bx,
where A and B are real matrices of order n . When B is nonsingular
"infinite". In other cases the entire problem may be poorly posed. The
as "ill-disposed" problems.
1
In numerical work the sharp distinction between singular and non-
Theorem. There are unitary matrices Q and Z so that WAZ and QBZ
We say that the eigenvalue problems QAZy = XQBZy and Ax = %Bx are
unitarily equivalent. The two problems obviously have the same eigenvalues,
the fourth stage khe eigenvectors are ob ined from the triangular matrices
2
transformations [11] shows that the computed matrices are exactly unitarily
that the computed eigenvalues, which are the ratios of the diagonal elements
of the final matrices, are the exact eigenvalues of the perturbed proble5
Our computer program does not actually- produce the eigenvalues ,X.
but instead returns a.' and i , the diagonal elements of the triangular
our algorithm.
approach for the case when B is nearly singular. In their method onp
computes an approximate null space for B and removes it from the problem..
conditioned problem is obtained. The method has the crucial drawback that
one must determine the rank of B If a wrong decision is reached,
been given by Fix and Heiberger [ 2 1. Although our method does not
semidefinite.
ih
2. Reduction to Hessenberg-Triangular Form
form. While a treatment of the reductions in this and the following sections
the form
I+ vu
T
where v u = -2 , v is a scalar multiple of u , only components
k,k+l,...,ktr-i of u are nonzero, and u = 1 . Given any vector x ,
QX x + (u X)v
has its k+l,...,k+r-1 components equal to zero, its k-th component changed
some row has elements k , k*1 , and k+2 zero, then they remain zero
i
various subscripts. The Q's will always be premultpliers, that is
this reduction are well known (e.g. see [4,11]) and we confine ourselves
to a brief description to illustrate our notation. At the k-th stage of
x x x x x
0 x x x x
S0 0 x x x
i0 0 x1 x x
O 0 x x x
x x x x x
0 x x x x
0 0 0 x x
0 0 0 xI x
by6
After this reduction, A and B have the form
A B
x x x x x x x x x
x x x x x 0 x x x x
x x x x x 0 0 x x
x x x x x 0 0 0 x
1
x x x x x 0 0 0 0 x
x x x x x x x x x x
x x x x x 0 x x x x
x x x x x 0 0 x x x
x x x x x 0 0 0 x x
0 x x x x 0 0 0 xi
x x x x x
x x x x x
X3 x5 x x x
x2 x x x x
x6 x x
7
As each element of A
is annihilated, it introduces
a nonzero element
on the subdiagonal of B , which
is immediately annihilated by
a suitably
chosen Z . The entire algorithm,
including the Householder triangulari-
zation of B may be summed up
as follows.
1) For k = 1,2,n-1
3) Choose Zkr'V
2 (e) to annihilate b
4~) B - BZk1 , A- 7k
8
3. The Explicit QZ Step
(3.1) R = Q(C-kI)
is upper triangular. The next iterate C' is defined as
If we set
At = QAZ
and
B' = QBZ
AB' T C
'I7
iiA
1) Determine Q so that QC is upper triangular,
triangular,
3) A-WQAZ, B-QBZ.
(3.2) Q(A-kB) = RB = S
= . ,Q 1
(5.3)¢ n-lQn-. . '
where Q e (k).
xx x x x
1
x x x X X
0 0 x x x
0 0 0 x x
0 0 0 0 x
below the diagonal can be removed. Similarly Q2QBZI has the form.
10
0 x x x x
0 x x x x
0 x1 x x x
0 0 0 X x
0 0 0 0 x
Z = ZIZ 2...Zn_1
in the form
From the particular form of Z and the fact that S is upper triangular,
We summarize as follows.
is upper triangula -
3) A: = SZ+ kB'
T
CV+ 1 = QCVQ Cv = AVBV
and the B are upper triangular. The C are the upper Hessenberg
matrices that would result from applying the QR algorithm with shifts
approximates the eigenvalue current]y being found and the problem may
so that by the time a large shift emerges the small eigenvalues will have
12
and cannot be computed accurately.) To be safe one might perform, the
13
4. Implicit Shifts
* the fact that we have used formula (3.4) rather than unitary equivalences
both A' and B' are computed by unitary equivalences. The implicit
shift technique has the additional advantage that it can be adapted to
perform two shifts at a time. For real matrices this means that a double
shift in which the shifts are conjugate pairs can be performed in real
arithmetic.
by its first row. In fact, AB-1 and QABQH are both upper Hessenberg,
first row.
Thus we must do two things. First, find the first row of 1Q•
is relatively easy. The first row of Q is the first row that would be
first two columns of AB . aut these, along with the shifts, completely
14i
submatrix of B is actually required here. If either bll or b22
The second part is a little more difficult, and is really the crux
Only the first three elements of the first row of Q are nonzero. Thus,
x x x x x x x x x x x x
2
x x x x X X x x x x x x
1 1
x x x x x x x x x x x x
O 0 x x x x C 0 0 x x x
0 0 0 x x x 0 0 0 0 x x
0 0 0 0 x x 0 0 0 0 0 x
affects the first row. This is done as follows. The matrix Q1 B has
elements and then a Z' which annihilates the resulting (2,1) element.
15
x x x x x
x1 x x x x x
x x x x x x
0 ) 0 x x x
0 0 0 0 x x
x x x x x x x x x X x x
x x x x x x 0 x x x x x
0 x x x x x 0 x2 x x x x
0 x x x x x 0 xI x1 x x x
0 0 0 x x x 0 0 0 0 ii x
0 0 0 0 x x 0 0 0 0 0 x
The first columns are now in the desired form. The nonzero elements
outside the desired structure have been "chased" into the lower 5-by-5
submatrices.
16
The fictitious zeroth column of A is determined in part by the
shifts. In analogy with the implicit double shift algorithm, we take the
det(A-kB) 0
where
n -l n - I n
nln
,n-lfn- n1,n
aa b
an,n-i an, n 0b n, n
1
the three nonzero elements of the first column of (AB-1 -k) (AB- -k 2 I)
elements are not lost in the shift calculation. The formulas are
(m n-1)
aa a a a a a b al •(bl)
mm nn 11 nn mm mmn
22 n
ll 22 1
n nn bb nn
M2
22 al 1 a a all a__) )
a2. a aa
i2i.
a -)- ~
a32
M_ U)+
141
+ a30l
1 7 ~
We are now in a position to summarize the double implicit shift
2) For k = l,2,...,n-2
5) Determine QnEY(
2 (n-l) to annihilate a
n-l 2n, n-2
4) Determine Zn_! ?2 (n-I) to annihilate bn,n_ 1
The number of additions is about the samie. Summing these for k from
in ,k in
" hqZ bcoessipl
b k and
an Z"
k is not used. Furthermore, the
a.18
In order to obtain eigenvectors, the Q's are ignored and the Z's
2 2
accuinulated. This requires about 8n more multiplications and 8n
and B (n= 4)
x x x x 0 x x x
x x x x 0 x x x
0 x x x 0 0 x x
C 0 x x 0 0 0 x
The rest of the solution lies in recognizing that there J *'O Unr-
of a problem. If b and b22 are small then the problem has 3]So-e
to emerge at the upper left, and the larger the figenvalne, t,'e swi'ter
a large eigenvalue.
19
1/
the original problem decomposes into one by one and two by two subproblems.
The eigenvalues of the one by one problems are the ratios of the corres-
There are two good reasons for not using the quadratic directly,
but instead reducing the two by two problems. First, when A and I3
nport.-t second reason is that the one by one problems contain more
two by two problems be reduced to one by one problems and that t-.e
'Ipper triangular.
then a QcW1
2 (1) may be chosen to reduce a21 to zero. The ze!ro elements
20
of QB are not disturbed. Similarly, if b22 is zero, a ZE 2 (1)
formulas for the elements of A' = QAZ and B' = QBZ for any Q and Z
or b'
23. is effectively zero. It is not obvious, however, that the other
Since the first column of QEZ is zero and QEZ = QAZ -XQBZ , it follows
that, however Q is chosen, both QAZ and QBZ must be upper triangular.
We assume that all computations are done in floating point arithmetic with
t base 3 digits and that the problem has been so scaled that underflows
and overflows do not occur. 'Wef-ther assume that a21 is not negligible
in the sense that ja2 1 j < 3-tilAil , where 11-1 denotes, say, the row
sum norm.
21
Al................................................................................
The algorithm for computing X amounts to making an appropriate
It goes as follows.
all
=bl
12 = a - bl12
22
p = ( b1
a21a12
q =b11b22
2
r = p +q
det(A' -XB') = 0
where IIA-A'II < aAMI and IIB-B'11 -<a B 1B 11 with cA and aB small
E = f(A-XB)
Then
E, = E+H
22
First we note that
Hence
jdet(E) I < PlI!EII max(lIA1I, I%I BIJ }+ p2[m -IfIAIl, JXI II!BII
-t
where p, and p2 axe.of order p From (5.2) it then follows that
of E is larger than the first. Then Zc2(2 (l) is chosen to annihilate e21
But If 2 2 1 - Iell11
2 and, since e2 was assumed to be the larger row,
To choose Q , let
C=AZ , D=BZ ,
23
and let fl cl and dI be the first columns of F, C ,and D•
T1
Let q. denote the second row of Q . If JAil _ 1 I1JIBII , we choose Q
is negligible. But
q Tc1 qT f + XqT l
2 ~2 c1
< (p + a)ljAlI
If, on the other hand, IXI IIIJ > IIII, we choose Q so that
q2 Cl11 olIAII•
< (p + a)"l"
the first element of the larger of the two rows of A-%B and Q is chosen
and %BZ . In this way, we can be sure that the computed (2,1) elements
real, they are applied to the entire matrices. If the transformations are
24
......... -___-_- -I
rz MM1PT -- p F7
complex, they are used to compute the diagonal elements that would result,
eigenvalues.
methock used in " hqr2 " 8 ]. The vectors of the original problem are
25
6. Some Numerical Results
eigenvector are not too "ill-disposed", then they produce a small relative
residual.
Wilkinson.
A .1 .2 B .1i 1
A= . 0 P
!:ere p is about the square root of the machine precision, that is, L is
2
not negligible compared to 1 , but 12 is. There is one eigenvalue
solving this problem so that the mild instability of the one eigenvalue
does not cause an inaccurate result for the other, stable eigenvalue.
26
Of course, the use of unitary transformations makes our technique
somewhat slower than others which might be considered. But the added
been run, but these become somewhat expensive when they are merely tests.
IBM 360 model 67. Of this, 13 seconds are spent in the initial reduction
29 seconds are used for the 61 double iterations required, and 3 seconds
are needed for the diagonal elements and eigenvectors. If the eigenvectors
are not needed and so the transformations not saved, the total time is
a la Peters and Wilkinson [9] and use of Fortran versions (12] of "lortl.es"l
"
[5] and " hqr2 [8] requires a total of 27 seconds for this example.
(All of these times are for code generated by the IBM Fortran IV comnniler,
rule of thumb, for a matrix of order n the time required on the model -7
27
The example in Table 1 is not typical, but it does illustrate
The companion matrices were chosen so that the resulting problem has
3 5 2
4 6T
The double root at c results from the fact that B has a double zero
eigenvalue. All three roots are associated with quadratic elementar-j
divisors; i.e., each root has only one corresponding eigenvector. The
computed diagonals of the triangularized matrices are given in the table.
Note that the four finite eigenvalues are obtained with a relative accuracy
of about 10-8 . This is about the square root of the machine precision
the reciprocals of quantities which are roughly the square root of the
28
50 -60 50 -27 6 6 16 5 5 5 -6 5
38 -28 27 -17 5 5 5 16 5 5 -6 5
27 -17 27 -17 5 5 5 5 16 5 -6 5
A= B-
27 -28 38 -17 5 5 5 5 5 16 -6 5
27 -28 27 -17 16 5 5 5 5 5 -6 16
27 -28 27 -17 5 16 6 6 6 6 -5 6
a
25- (68670843143 .2637605112.10-6
-12.821841071323 .1312405807.106
5.814535434181 + 10.071071345641 i 11.629071028730
5.800765071150 - 10.047220375909 i 1. 601530502268
5.736511506410 + 9.935928843473 i 11.473022854605
5.510879468089 - 9.545122710676 i 11.021758784186
0.976972281.108
-0.976972290.108
0.49999999310489 + 0.86602543924271 i
0.49999999310489 - 0.66602543924271 i
0.5000000689511 + 0.86602536832617 i
O. 50000000689511 - 0.86602536832617 i
Table 1
29
-a *
Acknowledgments
Stewart received support at the University of Texas from NSF grant GP-2:':-5.
Linda Kaufman of Stanford -has recently shown how to carry out the
30
References
51
Part II
FORTRAIr PROGRAM
32
SUBROUTINE OZ(NOtNABtEPSALFRALFIBETAITERgWANTXX)
DIMENSION A(NDND)tB(NDND),ALFR(N),ALFI(N),BETA(N,XND.ND)
UIMENSION ITER(N)
LOGICAL WANTX
Sc
C A AND 8 ARE N-BY-N REAL MATRICES, STORED IN ARRAYS WITH ND ROWS.
SC EPS IS THE RELATIVE PRECISION OF ELEMENTS OF A AND B.
C FINDS N PAIRS OF SCALARS, (ALFA(M),BETA(M)) SO THAT
C BETA(M)*A - ALFA(M)*B IS SINGULAR.
C THE EIGENVALUES OF A*X - LAMBDA*B*X CAN BE OBTAINED BY
C DIVIOING ALFA(M) BY BETA(M), EXCEPT BETA(M) MIGHT RE ZERO.
C IF (wANTX) ALSO FINDS CORRESPONDING EIGENVECTORS.
C USES ONLY UNITARY TRANSFORMATIONS, NO INVERSES,
C SO EITHER A OR B (OR BOTH) MAY BE SINGULAR.
C
C BETA(M) IS REAL.
C ALFA(M) IS COMPLEX, REAL AND IMAGINARY PARTS IN ALFR(M) AND ALFI(M).
33
-J
SUBROUTINE QZHES(NDNA,8,WANTXX)
DIMENSION A(NDND),B(NDND),XtNOND)
LOGICAL WANTX
C
C INITIALIZE Xg USED TO SAVE TRANSFORMATIONS
C
IF (oNOT.WANTX) GO TO 10
00 3 1=19N
DO 2 J=lN
X(IIJ) =0.
*2 CONTINUE
x(I)=1
3 CONTINUE
S =0.
DO 20 I=LltN
IF (ASc8(IL))*GTS) S ABS(B(1,L)
20
iIF
CONTINUE
IF (S*EQo0.) GO TO 100
(ABS(B(LtL))*GT*S) S
=0.
DO 25 I=LvN
=ABS(B(LgL))
8(1,L) 8 (IL)/S
R =R 8 (1,L)**2
25 CONTINUE
R = SQRT(R)
IF (P(LqL)*LTo0*p R =-R
8(L*L) = B(LqL) * R
RHO = R*RfLL)
DO 50 J=LIN
T =0.
00 30 I=LN
T = T * 19*81J
30 CONTINUE
T =-T/RHO
DO 40 I=LN
8(19j) = B(I*J) *T0(1L)
40 CONTINUE
50 CONTINUE
DO 80 J=19N
T = 0.
I.60 *
00 60 I=LoN
T = T * 8(1,L)*A(1,J)
CONTINUE
T =-T/RHO
00 70 I=L*N
A(I*J) = A(IJ) + T*8(1,L)
*70 CONTINUE
80 CON~TINUE
H~(L#L) = -~
(C)90) =LlN
8(I9L) = 0.
90 CONTINUE
34
C100 CONTINUE
C REDUCE A TO UPPER HESSENBERG, KEEP B TRIANGULAR
IF (N*LE.2) GO TO 170
NM2=N-2
DO 160 K=iNM2
Ki = t(I
NKI N-K-i
0O 150 LB=iNKi
CALL HSI2(A(LK),A(LiK),UitU2,ViV2)
IF (UidNF~lo) 6O TO 125
DO 110 J=KoN
T = A(L9J) * U2*A(LI#J)
A(LoJ) A(L9J) * T*Vi
A(L1,J) =A(LiJ) * T*V2
110 CONTINUE
A(LiK) = 0.
DO 120 J=L*N
T = B(LqJ) * U2*B(LlJ)
B(LtJ) =B(L*J) * T*Vi
B(LI9J) =8(L1,J) + T*V2
120 CONTINUE
* 125 CALL HSt2(B(LlLl),B(LiL),UlU2,ViV2)
IF (UI.NE*i.) GO TO 150
DO 130 I=I*Ll
T = 8(IqL1) * U2*B(1,L)
8(I,11) B (1911) * T*Vi
8(19L) 0 (19L) * T*V2
130 CONTINUE
t3(LI*L) = 0.
DO 140 1=19N
T = A(I9LI) * U2*A(IL)
A(I9LI) =A(IqLI) * T*Vl
A(IL) =A(IL) * T*V2
140 CONTINUE
IF (*NOT.WANTX) GO TO 150
DO 145 1=19N
T = X(IqLi) * U2*X(IL)
X(I*Ll) =X(I#Ll) +T*Vl
X( 19 L) X(IL) *T*V2
145 CONTINUE
150 CONTINUE
160 CONTINUE
170 CONWINUE I
RETURN
END
C
C
35
SUBROUTINE WZIT (NDNA,8,EPSEPSAEPSB, ITERWANTX.X)
DIMENSION A(NOND),8(ND9ND),X(NDND)
[ C
DIMENSION ITER(N)
LOGICAL WANTXqMID
C INITIAL1717 ITER9 COMPUTE EPSA9EPSB
C
ANORM =0,
8NORM = 0.
00O 185 1=19N
ITEkHj) =0
ANI = 0.
IF (I.NE.1) ANI =ABS(A(J.I-1)
HN1 = 0.
00 180 J=I*N
ANI = ANI + ASS(A(I,J))
ONI = BNI + ABS(BU,9J))
180 CONTINUE
IF (ANI.GT*ANORM) ANORM = AN!
IF (8N1.GTo8NORM) BNOiRM = ONI
185 CONTINUE
EPSA =EPS*ANORM
EPSH = EPS*BNORM
C
C REDUCE A TO QUASI-TRIANGULAR, KEEP B TRIANGULAR
C
M =N
200 IF (M.LE*2) GO TO 390
C
C Ch-ECK FOR CONVERGENCE OR REDUC161LITY
DO 220 LH=19M
L = M+1-LB
IF (LoEQ.1) GO TO 260
IF (A8S(A(LL-1)) *LE* EPSA) GO TO 230
220 CONTINUE
230 A(LqL-1) = 0.
IF (L.LT.M-1) GO TO 260
M L-I
GO TO 200
C
C CI-ECK FOR SMALL TOP OF 8
C
260 IF (ABS(B(LL))*GT*EPSO) GO TO 300
8(LgL) =0.
Li = .1
CALL HSI2(A(LL),A(Ll.L),UIU2,V1,V2)
IF (U1.NE.1.) 60 TO 280
00 270 J=L9N
7 = A(LJ) * U2*A(LlqJ)
A(LvJ) =A(L9J) + T*Vl
A(LltJ) =A(Ll9J) # T*V2
T= B(LqJ) + U2*8(LlgJ)
8(Lqj) =B(Ltj) + T*Vl
H(LI*J) B (L19J) + TOV2
270 CONTINUE
280 L =Li
6O T0 230
36
* C
C BEGIN ONE QZ STEP, ITERATION STRATEGY
c
300 Ml = M I
IITER(M)
LiI
IF
IF
1
CONST =0.75
= ITER(M) I
(ITER(M).EG*1) GO TO 305
(ABS(A(t4M-1))LTeCONST*OLDI) GO TO 305
IF (ABS(A(M-lM-2))*LT*CONST*0LU2) GO TO 305
IF (ITER(M).EQ.lO) GO TO 310
IF (ITER(M).GT*30) GO TO 380
C ZEROTH COLUMN OF A
A22 = A(L.2Ll)/B22
A33 = A34A43lgA384*A/8)A3
M812
=BK.NE.Ml2
834 = BKI9)l 4
I 2 A1 -K.261
A30 = K.32L)/2
GO TO 37
IF (K3.GT.fI) K3 M
KMI K-1
IF (KM1.L7.L) KM1 =I
IF (K.EU.L) CALL HSH3(AlOA20,A3catUlU2,U3,yIV2,y
IF (K.GT.L.AND.K.LT-M1) 3)
CALL H'SH3(A(K9MI)AKlKMI),A(K2,KMl),UltU2,U
IF (KEQ.M 3 9 Vl V2 V3)
1 ) CALL HSH2(AiK9KMI),A(KlK14l),IIU
2 9vvl# 2 )
IF (Ul.NE.I.) GO TO 325
* DO 320 J=KM1,MORN
T = A(KJ) + U2*A(KIJ)
IF (MID) T =T *U3*A(K2,J)
A(KvJ) A(K*J) *T*VI
A(KIJ) =A(KlJ) *T*V2
IF (MID) A(K29J) A(K29J) *T*V3
T = B(Ktj) + U2*8(Kl,j)
IF (MID) T = T U3*8(K29J)
B(KgJ) B (KtJ) *T*VI
B(KlJ) =B(KlJ) + T*V2
IF (MID) 8(K2,J) = (K2,PJ) +' T*V3
320 CONTINUE
IF (K.EQ*L) GO TO 325
A(KIK-1) =0.
IF (MID) A(K2,K-1) = 0.
325 IF (K.FQ.M1) GO TO 340
CALL HSH3(8(K2,K2),B(K2,KI) ,9K2,K),ul9U29U
3 9 VlVtV3)
IF (U1.NE.I.) GO TO 340
00 330 I=LORI9K3
T = A(IK2) + U2*A(IKl) +U3*A(1,K)
A(IK2) = A(IK2) + *V
A(IKI) =A(I9Kl) + T*V,2
A(1,K) = A(IK) * T*V3
f = B(IK2) * U2*8(iKl) *U3*B(I1t9)
8(lK2) = (lK2) * T*VI
B(I*Kl) = t8(IKl) + T*V2
8(19K~) = B(IK) + J*V3
330 CONTINUE
H(K2*KJ) =0.
IF (.NOT.WANTA) GO TO 340
0)0 335 1=1,tJ
T = X(IK2) + U2*X(IKI) + U3*X(I*K)
x(IleK2) = X(IK2) + T*VI
X(IK1) =X(IKI) * T*V2
X(IK) = XdIK) * T*V3
335 CONTINUE
340 CALL HSH2(B(KIKl),B(KlK),ultu2,vl9V2)
IF (UlhNE.1.) GO TO .360
0)0 350 I=LOHI.K3
T = A(1,Kl) + L2*A(1,K)
A(I*Kl) A(I,Kl) * T'*Vl
A(1,K) =A(IK) * T*V2
T = B(I,Kl) + U2*b(I,K)
B3(19KJ) B(I,~l) * T*V1
83(19K) 8(1#r:) * T*V?
350 CONTINUE
R(KlK) =0.
IF (.NOT.WANTX) GO TO 36(;
DO 355 IzIoiN
T = (IKI) .U2*X(JK)
X(I*Kfl X(I*Kl) . T*Vl
X(IqK) =X(~,K) . *V?
355 CONTINUE
360 CCNTINUE
C
C END MAIN LOOP
c
GO TO 200
39
SUBROUTINE QZVAL(NDNABEPSAEPS8,ALFRALFIBETAWANTXX)
DIMENSION A(NDND),B(NDND),ALFR(N),ALFI(N),BETA(N),X(NCND)
LOGICAL wANTXqFLIP
GO TO 490
C TWO-BY-Two SUBMATRIX
C
420 L =M-1
IF (ABS(B(L9L))oGT.EPSB) GO TO 425
3(LtL) = 0o
CALL HSH2(A(LL )9A(ML)9U1,U2,VlV2)
GO TO 460
425 IF (A8S(8(MvM)).GToEPSB) GO TO 430
t3(mom) = 0.
CALL HSh2(A(MM),A(ML),UIU2,VlV2)
HN= 0.
GO TO 435
430 AN = ABS(A(LL) ).ABS(A(LM) ).ABS(A(ML) ).ABS(A(MM))
BN =ABS(B(LL)),ABS(B(LM))+ABS(B(MM))
Al) =A(L*L)/AN
A12 = A(LqH)/AN
A21 =A(M*L)/AN
A22 = A(M*M)/AN
811 = 8(L*L)/BN
d12 = B(Lg,!)/BN
b22 = 8(MgM)/BN
C = (AI1'B22 *A22*Bll - A21*812)/2,
D9 (A22*Bll Al1*B22 - A2!*B12)**2/4o
1 * A21*822*(A12*Bll - AI1R812)
IF 0.oLT.0.) GO TO 480
C
C TWO REAL ROOTS
C ZERO BOTH A(MoL) AND B(M9L)
IF (C.GE.0.) E = (C + SORT(D))/(811*b22)
IF (C*LT*0.) E = (C - SORT(D))/8~11*822)
All =All - E*Rll
A12 = AlIZ - E*H12
A22 =A22 - E*B22
FLIP = !AHS(All)*AHS(A12))*(iE*(AbS(A21)A3S(A22))
17 (FLIP) CALL H-SH2(A2AllUIU2#VlV2)
IF (.NOT.FLIP) CALL HSH2(A22,A21,U1,U2,VlV2)
440
mA435 IF (U1.NE*.1. GO TO 450-
DO 440 I=l,M
T = ..(19M) t.U2*A(19L)
A(IA) = A(IM) * V1*T
A(19L) =A(I9L) +V2*T
T = (19 M) * U2*6(IL)
B(1,M) = 83(19M) * Vl'*T
13(1,L) = 8(19L) + V2*r
* --
440 CONTINUE
IF (oNOToWANTX) GO TO 450
00 445 1=19N
T =X(IM) * U2*X(I1,L)
X(IM) = X(h-M) *V1*T
X(IL) = X(IL) + V2*I
445 CONTINUE
450 IF (HN.EU.0.) GO TO 475
FLIP = AN *GE. ABS(E)*BN
IF (FLIP) CALL HSH2(B(LqL),13(ML),UI9U2,VlV2)
IF (.NOT*FLIP) CALL HSH2(A(LvL)9A(M9L)9U1,U2,VlvV2)
460 IF (Ul.NE.919) GO TO 475
DO 470 J=LqN
T = A(L*J) + U2*A(MJ)
A(LJ) = A(LqJ * V*
A(MJ) =A(MJ) * V2*T
T = B(L*J) + U2013(MJ)
t3(LqJ) = I3(L9J) + V1'*T
B(MJ) =B(MJ) + V2*T
470) CONTINUE
475 A(MvL) = 0.
"(t)= 0.
ALFR(L) = A(LvL)
ALFR(M) =A(MM)
BETA(L = B(L*L)
BETA(M) = 8 (MeM)
ALA 1(M) =0.
ALFI(L) =0.
m = M-2
41
IF (.NOT.FLIP) CALL CHSH2(CZ*AIISZR*A12, SZI*A129
I
I CZ*A21+SZR*A22, SZI*A22, CO, SOR9 S01)
SSR =SQR*SZR *SQI*SZI
SS1 = SQR*SZI -SQI*SZR
CQ*CZ*All + CO*SZR*AI2 + SQR*CZ*A21
= *SSR*A22
TI = CQ*SZI*A12 - SQI*CZ*A21 + SSI*A22
BOR = CQ*CZ*Bl1 + CQ*SZR*B12 * SSR*822
BDI = CQ*SZI*B12 + SSI*822
R = SURT(BOR*BDR + BDI*BDI)
BETAL) = BN*R
ALFR(L) = AN*(TR*BOR + TI*8D1)/R
ALEj'.- = AN*(TR*BDI - TI*BDR)/R
TR = SSR*All - SQR*CZ*A12 - CQ*SZR*A21 + CQ*CZ*A22
TI = - SSI*All - SGl*C-Z*A12 + CQ*SZI*A21
8DR =. SSR*81l - SQR*CZ*812 * CQ*CZ*B22
t3DI = - SSI*BIl -SQI*CZ*812
R = SQRT(BDR*B0R *BDI*BDI)
BETA(M) = BN*H
ALFR(M) = AN*(TR*BDR + TI*BDI)/R
ALFJ(M) = Ai-,(TR*BDI -TI*BDR)/R
M =M-
* 42
SUBROUTINE QZVEC (NDNABEPSAEPSBALFRALFI ,BETAX)
DIMENSION A(NOND),B(NDND),ALFR(N),ALFI(N),BETA(N),X(NOND)
LOGICAL WANTXFLIP
C
C FINU EIGENVECTORS OF QUASI-TRIANGULAR MATRICES
C USE 8 FOR INTERM'EDIATE STORAGE
t
C,
c DC 500 THRU 590 fOR M = N STEP (-I OR -2) UNTIL 1
C to =N
500 CONTINUE
IF (ALFI(M).NE0 o.) GO TO 550
CC REAL VECTOR
ALFM = ALFR(M)
BETM = t3ETA(M)
IF (ABS(ALFM)*LT*EPSA) ALFM = 0.
4 IF (ABS(8ETM).LTLEPSB) BETM =0.
c
~1C 00 510 THRU 540 FOR L M-1 STEP (-I OR -2) UNTIL I
IF (L.EQ.0) GO TO 540
510 CONTINUE
SL = 0.
00 515 J=LI.M
SL = SL + (BETM*A(LJ)-ALFM*B(LJ))*B(JoM)
515 CONTINUE
IF (L*EQ*1) GO TO 520
IF (A(LvL-1)*NE.0.) GO TO 530
520 D, BETM*A(LL)-ALFM*B(LgL)
IF (D.EQ,0,) D =(EPSA.EPSB)/2,
b(LM) = -SL/D
L =L-I
60 TO 540
530 K =L-1
=> 0 .
0)0 535 J=LloM
SK=SK + (BETM*A(KJ)-AL-FM*B(KJ))*B(JM)
5315 CCNTINUL
TKK = BETM4'A(KtK) - ALFM*B(KK)
TrL_ = BETM*A(KgL) - ALFM4*8(KrL)
TLK = BETM*A(L,K)
TLL = BETM*A(LgL) - ALFM*BCLtL)
D TKK*TLL - TKL*TL(
IF UX.EC.C.) D0 (EPSA+EPSB)/?*
H(LtM) =(TLK*SK - TKK*SL)/D
FLIP = ABS(TKK) .GE. ABS(TLK)
IF (FLIP) B(KtM) = -(SK + TKL*B(LM))/TKK
IF (.NOT.FLIP) H(KoM) = -(SL + TLL*B(LoM))/TLK
43
C
C COMPLEX VECTOR
C
5'90 ALMR = ALFR(M-1)
ALMI = ALFI CM-i)
BErM = BLTA(M-I)
MR = M-1
MI =M
C
C NORMALIZE SO THAT M-TH COMPONENT =,-I~
C (M-I)ST = (8ETM*A(MM)-ALFM*B(M,M))*(M-Yh)/(BETM*A(M9M-1))
B(M-1.MR) = ALMI*B(MgN)/ibEfM*A(MM-1))
B(M-1,MI) = (BETM*A(MM)-ALMR*B(MM))/(BETM*A(MM-1))
i4(MMR) = 0.
H(mMI) = -I.
C
C DO 560 THRU 585 FOR L =M-2 STEP (-I OR -2) UNTIL 1
C
L =M-2
IF (L.EO.O) GO TO 585
960 CONTINUE
iiSLI
- ITR
SLR =0.
DO 565 J=LlM
0.
= BETM*A(LJ) -ALMR*BCLJ)
T; = -ALMIt3(LgJ)
SLR = SLR + TR*8(JgMH) -Tl*B(JMl)
TI = -ALMI*B(K*J)
SKR = SKR * TR*B(JMR) -TI*B(JMl)
600 CNTINUE
M =M01
iF (M.t.O)
GO TO60
655 CON4TINUE
00 660 I=1,N
CALL CDIV(X(I9M-1),X(IM),DRDlgX~iM-1 ),X(IM) )
660 CONTINUE
45
= M-2
f90 IF (M.GT.0) GO TO 630
C
700 RETURN
END
46
..........
''' .. ...
* ...-
- -*"
-," -
" ' ' : =-
-- - -
" '
"'""--4' -*-- =
*
SUBROUTINE HStH3(AlA2,A3,UI ,U29U3,VlV?,V3)
C
* C FINDS HOUSEHOLDER TRANSFORMATION THAT
WILL ZERO A2 AND A3
C P 1*(V1,V2,V3)*(UlU2,U3)**T
10 U! = 0.
RETURN
47
SLBROUTINE HSIH2(AlA2oUltU2tVltV2)
IF (A2.EQ.0.) GO TO 10
S = ABS(Al) 4 ABS(A2)
Ul = A2/S
U2l= A2/S
R SuRT(U1*Ul+U2*U2)
IF (Ul-LT.O.) R -R
VI = -(Ul *R)/R
V2 = -U2/R
ul = I.
U2 = V21VI
RETURN
10 ul= 0.
RE~T U RN
48
SU8ROUTINE CHSH2(A1R*AjIA2R9A21,C.SR#SI)
SR= (AxR*A2R.AI'A21)/R
SI = (AIR*A21-A1I*A2R)/R
R SURT(C*C*SR*SR+SI*SI)
C =C/R
SR = S/
SI = SI/R
RE TURN
10 C = 1.
St1 0.
RETURN
20 C =0.
Sp 1.
SI 0.
RET UR N
49
rv efl I .. 1 * 1"9 .
SUBROUTINE CDIV(RXIYRYIZRZI)
4 F (ABS(YR).LT*ABS(YI)) GO TO 10
7WR= XRY
WI = XI/YR
VI = Yl/YR
D) = 1. * VI*VI
Zk = (WR *WI*VI)/D
ZI = (WI -WR'VI)/D
1RETURN
/l ENDV
= -WR
50