1ZLAQR3(1) LAPACK auxiliary routine (version 3.2) ZLAQR3(1)
2
3
4
7 SUBROUTINE ZLAQR3( WANTT, WANTZ, N, KTOP, KBOT, NW, H, LDH, ILOZ, IHIZ,
8 Z, LDZ, NS, ND, SH, V, LDV, NH, T, LDT, NV, WV,
9 LDWV, WORK, LWORK )
10
11 INTEGER IHIZ, ILOZ, KBOT, KTOP, LDH, LDT, LDV, LDWV, LDZ,
12 LWORK, N, ND, NH, NS, NV, NW
13
14 LOGICAL WANTT, WANTZ
15
16 COMPLEX*16 H( LDH, * ), SH( * ), T( LDT, * ), V( LDV, * ),
17 WORK( * ), WV( LDWV, * ), Z( LDZ, * )
18
19 COMPLEX*16 ZERO, ONE
20
21 PARAMETER ( ZERO = ( 0.0d0, 0.0d0 ), ONE = ( 1.0d0, 0.0d0 ) )
22
23 DOUBLE PRECISION RZERO, RONE
24
25 PARAMETER ( RZERO = 0.0d0, RONE = 1.0d0 )
26
27 COMPLEX*16 BETA, CDUM, S, TAU
28
29 DOUBLE PRECISION FOO, SAFMAX, SAFMIN, SMLNUM, ULP
30
31 INTEGER I, IFST, ILST, INFO, INFQR, J, JW, KCOL, KLN, KNT,
32 KROW, KWTOP, LTOP, LWK1, LWK2, LWK3, LWKOPT, NMIN
33
34 DOUBLE PRECISION DLAMCH
35
36 INTEGER ILAENV
37
38 EXTERNAL DLAMCH, ILAENV
39
40 EXTERNAL DLABAD, ZCOPY, ZGEHRD, ZGEMM, ZLACPY, ZLAHQR,
41 ZLAQR4, ZLARF, ZLARFG, ZLASET, ZTREXC, ZUNMHR
42
43 INTRINSIC ABS, DBLE, DCMPLX, DCONJG, DIMAG, INT, MAX, MIN
44
45 DOUBLE PRECISION CABS1
46
47 CABS1( CDUM ) = ABS( DBLE( CDUM ) ) + ABS( DIMAG( CDUM ) )
48
49 JW = MIN( NW, KBOT-KTOP+1 )
50
51 IF( JW.LE.2 ) THEN
52
53 LWKOPT = 1
54
55 ELSE
56
57 CALL ZGEHRD( JW, 1, JW-1, T, LDT, WORK, WORK, -1, INFO )
58
59 LWK1 = INT( WORK( 1 ) )
60
61 CALL ZUNMHR( 'R', 'N', JW, JW, 1, JW-1, T, LDT, WORK, V,
62 LDV, WORK, -1, INFO )
63
64 LWK2 = INT( WORK( 1 ) )
65
66 CALL ZLAQR4( .true., .true., JW, 1, JW, T, LDT, SH, 1,
67 JW, V, LDV, WORK, -1, INFQR )
68
69 LWK3 = INT( WORK( 1 ) )
70
71 LWKOPT = MAX( JW+MAX( LWK1, LWK2 ), LWK3 )
72
73 END IF
74
75 IF( LWORK.EQ.-1 ) THEN
76
77 WORK( 1 ) = DCMPLX( LWKOPT, 0 )
78
79 RETURN
80
81 END IF
82
83 NS = 0
84
85 ND = 0
86
87 WORK( 1 ) = ONE
88
89 IF( KTOP.GT.KBOT ) RETURN
90
91 IF( NW.LT.1 ) RETURN
92
93 SAFMIN = DLAMCH( 'SAFE MINIMUM' )
94
95 SAFMAX = RONE / SAFMIN
96
97 CALL DLABAD( SAFMIN, SAFMAX )
98
99 ULP = DLAMCH( 'PRECISION' )
100
101 SMLNUM = SAFMIN*( DBLE( N ) / ULP )
102
103 JW = MIN( NW, KBOT-KTOP+1 )
104
105 KWTOP = KBOT - JW + 1
106
107 IF( KWTOP.EQ.KTOP ) THEN
108
109 S = ZERO
110
111 ELSE
112
113 S = H( KWTOP, KWTOP-1 )
114
115 END IF
116
117 IF( KBOT.EQ.KWTOP ) THEN
118
119 SH( KWTOP ) = H( KWTOP, KWTOP )
120
121 NS = 1
122
123 ND = 0
124
125 IF( CABS1( S ).LE.MAX( SMLNUM, ULP*CABS1( H( KWTOP,
126 KWTOP ) ) ) ) THEN
127
128 NS = 0
129
130 ND = 1
131
132 IF( KWTOP.GT.KTOP ) H( KWTOP, KWTOP-1 ) = ZERO
133
134 END IF
135
136 WORK( 1 ) = ONE
137
138 RETURN
139
140 END IF
141
142 CALL ZLACPY( 'U', JW, JW, H( KWTOP, KWTOP ), LDH, T, LDT
143 )
144
145 CALL ZCOPY( JW-1, H( KWTOP+1, KWTOP ), LDH+1, T( 2, 1 ),
146 LDT+1 )
147
148 CALL ZLASET( 'A', JW, JW, ZERO, ONE, V, LDV )
149
150 NMIN = ILAENV( 12, 'ZLAQR3', 'SV', JW, 1, JW, LWORK )
151
152 IF( JW.GT.NMIN ) THEN
153
154 CALL ZLAQR4( .true., .true., JW, 1, JW, T, LDT, SH( KWTOP
155 ), 1, JW, V, LDV, WORK, LWORK, INFQR )
156
157 ELSE
158
159 CALL ZLAHQR( .true., .true., JW, 1, JW, T, LDT, SH( KWTOP
160 ), 1, JW, V, LDV, INFQR )
161
162 END IF
163
164 NS = JW
165
166 ILST = INFQR + 1
167
168 DO 10 KNT = INFQR + 1, JW
169
170 FOO = CABS1( T( NS, NS ) )
171
172 IF( FOO.EQ.RZERO ) FOO = CABS1( S )
173
174 IF( CABS1( S )*CABS1( V( 1, NS ) ).LE.MAX( SMLNUM,
175 ULP*FOO ) ) THEN
176
177 NS = NS - 1
178
179 ELSE
180
181 IFST = NS
182
183 CALL ZTREXC( 'V', JW, T, LDT, V, LDV, IFST, ILST, INFO )
184
185 ILST = ILST + 1
186
187 END IF
188
189 10 CONTINUE
190
191 IF( NS.EQ.0 ) S = ZERO
192
193 IF( NS.LT.JW ) THEN
194
195 DO 30 I = INFQR + 1, NS
196
197 IFST = I
198
199 DO 20 J = I + 1, NS
200
201 IF( CABS1( T( J, J ) ).GT.CABS1( T( IFST, IFST ) ) )
202 IFST = J
203
204 20 CONTINUE
205
206 ILST = I
207
208 IF( IFST.NE.ILST ) CALL ZTREXC( 'V', JW, T, LDT, V, LDV,
209 IFST, ILST, INFO )
210
211 30 CONTINUE
212
213 END IF
214
215 DO 40 I = INFQR + 1, JW
216
217 SH( KWTOP+I-1 ) = T( I, I )
218
219 40 CONTINUE
220
221 IF( NS.LT.JW .OR. S.EQ.ZERO ) THEN
222
223 IF( NS.GT.1 .AND. S.NE.ZERO ) THEN
224
225 CALL ZCOPY( NS, V, LDV, WORK, 1 )
226
227 DO 50 I = 1, NS
228
229 WORK( I ) = DCONJG( WORK( I ) )
230
231 50 CONTINUE
232
233 BETA = WORK( 1 )
234
235 CALL ZLARFG( NS, BETA, WORK( 2 ), 1, TAU )
236
237 WORK( 1 ) = ONE
238
239 CALL ZLASET( 'L', JW-2, JW-2, ZERO, ZERO, T( 3, 1 ), LDT
240 )
241
242 CALL ZLARF( 'L', NS, JW, WORK, 1, DCONJG( TAU ), T, LDT,
243 WORK( JW+1 ) )
244
245 CALL ZLARF( 'R', NS, NS, WORK, 1, TAU, T, LDT, WORK( JW+1
246 ) )
247
248 CALL ZLARF( 'R', JW, NS, WORK, 1, TAU, V, LDV, WORK( JW+1
249 ) )
250
251 CALL ZGEHRD( JW, 1, NS, T, LDT, WORK, WORK( JW+1 ),
252 LWORK-JW, INFO )
253
254 END IF
255
256 IF( KWTOP.GT.1 ) H( KWTOP, KWTOP-1 ) = S*DCONJG( V( 1, 1
257 ) )
258
259 CALL ZLACPY( 'U', JW, JW, T, LDT, H( KWTOP, KWTOP ), LDH
260 )
261
262 CALL ZCOPY( JW-1, T( 2, 1 ), LDT+1, H( KWTOP+1, KWTOP ),
263 LDH+1 )
264
265 IF( NS.GT.1 .AND. S.NE.ZERO ) CALL ZUNMHR( 'R', 'N', JW,
266 NS, 1, NS, T, LDT, WORK, V, LDV, WORK( JW+1 ),
267 LWORK-JW, INFO )
268
269 IF( WANTT ) THEN
270
271 LTOP = 1
272
273 ELSE
274
275 LTOP = KTOP
276
277 END IF
278
279 DO 60 KROW = LTOP, KWTOP - 1, NV
280
281 KLN = MIN( NV, KWTOP-KROW )
282
283 CALL ZGEMM( 'N', 'N', KLN, JW, JW, ONE, H( KROW, KWTOP ),
284 LDH, V, LDV, ZERO, WV, LDWV )
285
286 CALL ZLACPY( 'A', KLN, JW, WV, LDWV, H( KROW, KWTOP ),
287 LDH )
288
289 60 CONTINUE
290
291 IF( WANTT ) THEN
292
293 DO 70 KCOL = KBOT + 1, N, NH
294
295 KLN = MIN( NH, N-KCOL+1 )
296
297 CALL ZGEMM( 'C', 'N', JW, KLN, JW, ONE, V, LDV, H( KWTOP,
298 KCOL ), LDH, ZERO, T, LDT )
299
300 CALL ZLACPY( 'A', JW, KLN, T, LDT, H( KWTOP, KCOL ), LDH
301 )
302
303 70 CONTINUE
304
305 END IF
306
307 IF( WANTZ ) THEN
308
309 DO 80 KROW = ILOZ, IHIZ, NV
310
311 KLN = MIN( NV, IHIZ-KROW+1 )
312
313 CALL ZGEMM( 'N', 'N', KLN, JW, JW, ONE, Z( KROW, KWTOP ),
314 LDZ, V, LDV, ZERO, WV, LDWV )
315
316 CALL ZLACPY( 'A', KLN, JW, WV, LDWV, Z( KROW, KWTOP ),
317 LDZ )
318
319 80 CONTINUE
320
321 END IF
322
323 END IF
324
325 ND = JW - NS
326
327 NS = NS - INFQR
328
329 WORK( 1 ) = DCMPLX( LWKOPT, 0 )
330
331 END
332
334 LAPACK auxiliary routine (versionNo3v.e2m)ber 2008 ZLAQR3(1)