1
C/MEMBR ADD NAME=QVECZ,SSI=0
2
subroutine qvecz(nm,n,a,b,epsb,alfr,alfi,beta,z)
4
integer i,j,k,m,n,en,ii,jj,na,nm,nn,isw,enm2
5
double precision a(nm,n),b(nm,n),alfr(n),alfi(n),beta(n)
6
double precision z(nm,n)
7
double precision d,q,r,s,t,w,x,y,di,dr,ra,rr,sa,ti,tr,t1,t2,w1,
8
x x1,zz,z1,alfm,almi,almr,betm,epsb
11
c this subroutine accepts a pair of real matrices, one of them in
12
c quasi-triangular form (in which each 2-by-2 block corresponds to
13
c a pair of complex eigenvalues) and the other in upper triangular
14
c form. it computes the eigenvectors of the triangular problem and
15
c transforms the results back to the original coordinate system.
16
c it is usually preceded by qzhes, qzit, and qzval.
19
c subroutine qzvec(nm,n,a,b,epsb,alfr,alfi,beta,z)
24
c nm must be set to the row dimension of two-dimensional
25
c array parameters as declared in the calling program
26
c dimension statement;
28
c n is the order of the matrices;
30
c a contains a real upper quasi-triangular matrix;
32
c b contains a real upper triangular matrix.
33
c computed and saved in qzit;
35
c alfr, alfi, and beta are vectors with components whose
36
c ratios ((alfr+i*alfi)/beta) are the generalized
37
c eigenvalues. they are usually obtained from qzval;
39
c z contains the transformation matrix produced in the
40
c reductions by qzhes, qzit, and qzval, if performed.
41
c if the eigenvectors of the triangular problem are
42
c desired, z must contain the identity matrix.
46
c a is unaltered. its subdiagonal elements provide information
47
c about the storage of the complex eigenvectors;
49
c b has been destroyed;
51
c alfr, alfi, and beta are unaltered;
53
c z contains the real and imaginary parts of the eigenvectors.
54
c if alfi(i) .eq. 0.0, the i-th eigenvalue is real and
55
c the i-th column of z contains its eigenvector.
56
c if alfi(i) .ne. 0.0, the i-th eigenvalue is complex.
57
c if alfi(i) .gt. 0.0, the eigenvalue is the first of
58
c a complex pair and the i-th and (i+1)-th columns
59
c of z contain its eigenvector.
60
c if alfi(i) .lt. 0.0, the eigenvalue is the second of
61
c a complex pair and the (i-1)-th and i-th columns
62
c of z contain the conjugate of its eigenvector.
63
c each eigenvector is normalized so that the modulus
64
c of its largest component is 1.0 .
68
c this subroutine is the optional fourth step of the qz algorithm
69
c for solving generalized matrix eigenvalue problems,
70
c siam j. numer. anal. 10, 241-256(1973) by moler and stewart.
71
c modification de la routine qzvec de eispack concernant le
72
c passage de l'argument epsb.
75
c questions and comments should be directed to b. s. garbow,
76
c applied mathematics division, argonne national laboratory
78
c ------------------------------------------------------------------
81
c :::::::::: for en=n step -1 until 1 do -- ::::::::::
85
if (isw .eq. 2) go to 795
86
if (alfi(en) .ne. 0.0d+0) go to 710
87
c :::::::::: real vector ::::::::::
90
if (na .eq. 0) go to 800
93
c :::::::::: for i=en-1 step -1 until 1 do -- ::::::::::
96
w = betm * a(i,i) - alfm * b(i,i)
100
610 r = r + (betm * a(i,j) - alfm * b(i,j)) * b(j,en)
102
if (i .eq. 1 .or. isw .eq. 2) go to 630
103
if (betm * a(i,i-1) .eq. 0.0d+0) go to 630
108
if (isw .eq. 2) go to 640
109
c :::::::::: real 1-by-1 block ::::::::::
111
if (w .eq. 0.0d+0) t = epsb
114
c :::::::::: real 2-by-2 block ::::::::::
115
640 x = betm * a(i,i+1) - alfm * b(i,i+1)
118
t = (x * s - zz * r) / q
120
if (abs(x) .le. abs(zz)) go to 650
121
b(i+1,en) = (-r - w * t) / x
123
650 b(i+1,en) = (-s - y * t) / zz
126
c :::::::::: end real vector ::::::::::
128
c :::::::::: complex vector ::::::::::
133
c :::::::::: last vector component chosen imaginary so that
134
c eigenvector matrix is triangular ::::::::::
136
b(na,na) = -almi * b(en,en) / y
137
b(na,en) = (almr * b(en,en) - betm * a(en,en)) / y
141
if (enm2 .eq. 0) go to 795
142
c :::::::::: for i=en-2 step -1 until 1 do -- ::::::::::
145
w = betm * a(i,i) - almr * b(i,i)
151
x = betm * a(i,j) - almr * b(i,j)
153
ra = ra + x * b(j,na) - x1 * b(j,en)
154
sa = sa + x * b(j,en) + x1 * b(j,na)
157
if (i .eq. 1 .or. isw .eq. 2) go to 770
158
if (betm * a(i,i-1) .eq. 0.0d+0) go to 770
166
if (isw .eq. 2) go to 780
167
c :::::::::: complex 1-by-1 block ::::::::::
172
c :::::::::: complex divide (t1,t2) = (tr,ti) / (dr,di) ::::::::::
173
775 if (abs(di) .gt. abs(dr)) go to 777
176
t1 = (tr + ti * rr) / d
177
t2 = (ti - tr * rr) / d
181
t1 = (tr * rr + ti) / d
182
t2 = (ti * rr - tr) / d
184
c :::::::::: complex 2-by-2 block ::::::::::
185
780 x = betm * a(i,i+1) - almr * b(i,i+1)
186
x1 = -almi * b(i,i+1)
188
tr = y * ra - w * r + w1 * s
189
ti = y * sa - w * s - w1 * r
190
dr = w * zz - w1 * z1 - x * y
191
di = w * z1 + w1 * zz - x1 * y
192
if (dr .eq. 0.0d+0 .and. di .eq. 0.0d+0) dr = epsb
197
if (abs(y) .gt. abs(w) + abs(w1)) go to 785
198
tr = -ra - x * b(i+1,na) + x1 * b(i+1,en)
199
ti = -sa - x * b(i+1,en) - x1 * b(i+1,na)
201
785 t1 = (-r - zz * b(i+1,na) + z1 * b(i+1,en)) / y
202
t2 = (-s - zz * b(i+1,en) - z1 * b(i+1,na)) / y
206
c :::::::::: end complex vector ::::::::::
209
c :::::::::: end back substitution.
210
c transform to original coordinate system.
211
c for j=n step -1 until 1 do -- ::::::::::
219
860 zz = zz + z(i,k) * b(k,j)
223
c :::::::::: normalize so that modulus of largest
224
c component of each vector is 1.
225
c (isw is 1 initially from before) ::::::::::
228
if (isw .eq. 2) go to 920
229
if (alfi(j) .ne. 0.0d+0) go to 945
232
if (abs(z(i,j)) .gt. d) d = abs(z(i,j))
236
900 z(i,j) = z(i,j) / d
241
r = abs(z(i,j-1)) + abs(z(i,j))
242
if (r .ne. 0.0d+0) r = r * sqrt((z(i,j-1)/r)**2
248
z(i,j-1) = z(i,j-1) / d
256
c :::::::::: last card of qzvec ::::::::::