LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
dhseqr.f
Go to the documentation of this file.
1*> \brief \b DHSEQR
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8*> Download DHSEQR + dependencies
9*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dhseqr.f">
10*> [TGZ]</a>
11*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dhseqr.f">
12*> [ZIP]</a>
13*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dhseqr.f">
14*> [TXT]</a>
15*
16* Definition:
17* ===========
18*
19* SUBROUTINE DHSEQR( JOB, COMPZ, N, ILO, IHI, H, LDH, WR, WI, Z,
20* LDZ, WORK, LWORK, INFO )
21*
22* .. Scalar Arguments ..
23* INTEGER IHI, ILO, INFO, LDH, LDZ, LWORK, N
24* CHARACTER COMPZ, JOB
25* ..
26* .. Array Arguments ..
27* DOUBLE PRECISION H( LDH, * ), WI( * ), WORK( * ), WR( * ),
28* $ Z( LDZ, * )
29* ..
30*
31*
32*> \par Purpose:
33* =============
34*>
35*> \verbatim
36*>
37*> DHSEQR computes the eigenvalues of a Hessenberg matrix H
38*> and, optionally, the matrices T and Z from the Schur decomposition
39*> H = Z T Z**T, where T is an upper quasi-triangular matrix (the
40*> Schur form), and Z is the orthogonal matrix of Schur vectors.
41*>
42*> Optionally Z may be postmultiplied into an input orthogonal
43*> matrix Q so that this routine can give the Schur factorization
44*> of a matrix A which has been reduced to the Hessenberg form H
45*> by the orthogonal matrix Q: A = Q*H*Q**T = (QZ)*T*(QZ)**T.
46*> \endverbatim
47*
48* Arguments:
49* ==========
50*
51*> \param[in] JOB
52*> \verbatim
53*> JOB is CHARACTER*1
54*> = 'E': compute eigenvalues only;
55*> = 'S': compute eigenvalues and the Schur form T.
56*> \endverbatim
57*>
58*> \param[in] COMPZ
59*> \verbatim
60*> COMPZ is CHARACTER*1
61*> = 'N': no Schur vectors are computed;
62*> = 'I': Z is initialized to the unit matrix and the matrix Z
63*> of Schur vectors of H is returned;
64*> = 'V': Z must contain an orthogonal matrix Q on entry, and
65*> the product Q*Z is returned.
66*> \endverbatim
67*>
68*> \param[in] N
69*> \verbatim
70*> N is INTEGER
71*> The order of the matrix H. N >= 0.
72*> \endverbatim
73*>
74*> \param[in] ILO
75*> \verbatim
76*> ILO is INTEGER
77*> \endverbatim
78*>
79*> \param[in] IHI
80*> \verbatim
81*> IHI is INTEGER
82*>
83*> It is assumed that H is already upper triangular in rows
84*> and columns 1:ILO-1 and IHI+1:N. ILO and IHI are normally
85*> set by a previous call to DGEBAL, and then passed to ZGEHRD
86*> when the matrix output by DGEBAL is reduced to Hessenberg
87*> form. Otherwise ILO and IHI should be set to 1 and N
88*> respectively. If N > 0, then 1 <= ILO <= IHI <= N.
89*> If N = 0, then ILO = 1 and IHI = 0.
90*> \endverbatim
91*>
92*> \param[in,out] H
93*> \verbatim
94*> H is DOUBLE PRECISION array, dimension (LDH,N)
95*> On entry, the upper Hessenberg matrix H.
96*> On exit, if INFO = 0 and JOB = 'S', then H contains the
97*> upper quasi-triangular matrix T from the Schur decomposition
98*> (the Schur form); 2-by-2 diagonal blocks (corresponding to
99*> complex conjugate pairs of eigenvalues) are returned in
100*> standard form, with H(i,i) = H(i+1,i+1) and
101*> H(i+1,i)*H(i,i+1) < 0. If INFO = 0 and JOB = 'E', the
102*> contents of H are unspecified on exit. (The output value of
103*> H when INFO > 0 is given under the description of INFO
104*> below.)
105*>
106*> Unlike earlier versions of DHSEQR, this subroutine may
107*> explicitly H(i,j) = 0 for i > j and j = 1, 2, ... ILO-1
108*> or j = IHI+1, IHI+2, ... N.
109*> \endverbatim
110*>
111*> \param[in] LDH
112*> \verbatim
113*> LDH is INTEGER
114*> The leading dimension of the array H. LDH >= max(1,N).
115*> \endverbatim
116*>
117*> \param[out] WR
118*> \verbatim
119*> WR is DOUBLE PRECISION array, dimension (N)
120*> \endverbatim
121*>
122*> \param[out] WI
123*> \verbatim
124*> WI is DOUBLE PRECISION array, dimension (N)
125*>
126*> The real and imaginary parts, respectively, of the computed
127*> eigenvalues. If two eigenvalues are computed as a complex
128*> conjugate pair, they are stored in consecutive elements of
129*> WR and WI, say the i-th and (i+1)th, with WI(i) > 0 and
130*> WI(i+1) < 0. If JOB = 'S', the eigenvalues are stored in
131*> the same order as on the diagonal of the Schur form returned
132*> in H, with WR(i) = H(i,i) and, if H(i:i+1,i:i+1) is a 2-by-2
133*> diagonal block, WI(i) = sqrt(-H(i+1,i)*H(i,i+1)) and
134*> WI(i+1) = -WI(i).
135*> \endverbatim
136*>
137*> \param[in,out] Z
138*> \verbatim
139*> Z is DOUBLE PRECISION array, dimension (LDZ,N)
140*> If COMPZ = 'N', Z is not referenced.
141*> If COMPZ = 'I', on entry Z need not be set and on exit,
142*> if INFO = 0, Z contains the orthogonal matrix Z of the Schur
143*> vectors of H. If COMPZ = 'V', on entry Z must contain an
144*> N-by-N matrix Q, which is assumed to be equal to the unit
145*> matrix except for the submatrix Z(ILO:IHI,ILO:IHI). On exit,
146*> if INFO = 0, Z contains Q*Z.
147*> Normally Q is the orthogonal matrix generated by DORGHR
148*> after the call to DGEHRD which formed the Hessenberg matrix
149*> H. (The output value of Z when INFO > 0 is given under
150*> the description of INFO below.)
151*> \endverbatim
152*>
153*> \param[in] LDZ
154*> \verbatim
155*> LDZ is INTEGER
156*> The leading dimension of the array Z. if COMPZ = 'I' or
157*> COMPZ = 'V', then LDZ >= MAX(1,N). Otherwise, LDZ >= 1.
158*> \endverbatim
159*>
160*> \param[out] WORK
161*> \verbatim
162*> WORK is DOUBLE PRECISION array, dimension (LWORK)
163*> On exit, if INFO = 0, WORK(1) returns an estimate of
164*> the optimal value for LWORK.
165*> \endverbatim
166*>
167*> \param[in] LWORK
168*> \verbatim
169*> LWORK is INTEGER
170*> The dimension of the array WORK. LWORK >= max(1,N)
171*> is sufficient and delivers very good and sometimes
172*> optimal performance. However, LWORK as large as 11*N
173*> may be required for optimal performance. A workspace
174*> query is recommended to determine the optimal workspace
175*> size.
176*>
177*> If LWORK = -1, then DHSEQR does a workspace query.
178*> In this case, DHSEQR checks the input parameters and
179*> estimates the optimal workspace size for the given
180*> values of N, ILO and IHI. The estimate is returned
181*> in WORK(1). No error message related to LWORK is
182*> issued by XERBLA. Neither H nor Z are accessed.
183*> \endverbatim
184*>
185*> \param[out] INFO
186*> \verbatim
187*> INFO is INTEGER
188*> = 0: successful exit
189*> < 0: if INFO = -i, the i-th argument had an illegal
190*> value
191*> > 0: if INFO = i, DHSEQR failed to compute all of
192*> the eigenvalues. Elements 1:ilo-1 and i+1:n of WR
193*> and WI contain those eigenvalues which have been
194*> successfully computed. (Failures are rare.)
195*>
196*> If INFO > 0 and JOB = 'E', then on exit, the
197*> remaining unconverged eigenvalues are the eigen-
198*> values of the upper Hessenberg matrix rows and
199*> columns ILO through INFO of the final, output
200*> value of H.
201*>
202*> If INFO > 0 and JOB = 'S', then on exit
203*>
204*> (*) (initial value of H)*U = U*(final value of H)
205*>
206*> where U is an orthogonal matrix. The final
207*> value of H is upper Hessenberg and quasi-triangular
208*> in rows and columns INFO+1 through IHI.
209*>
210*> If INFO > 0 and COMPZ = 'V', then on exit
211*>
212*> (final value of Z) = (initial value of Z)*U
213*>
214*> where U is the orthogonal matrix in (*) (regard-
215*> less of the value of JOB.)
216*>
217*> If INFO > 0 and COMPZ = 'I', then on exit
218*> (final value of Z) = U
219*> where U is the orthogonal matrix in (*) (regard-
220*> less of the value of JOB.)
221*>
222*> If INFO > 0 and COMPZ = 'N', then Z is not
223*> accessed.
224*> \endverbatim
225*
226* Authors:
227* ========
228*
229*> \author Univ. of Tennessee
230*> \author Univ. of California Berkeley
231*> \author Univ. of Colorado Denver
232*> \author NAG Ltd.
233*
234*> \ingroup hseqr
235*
236*> \par Contributors:
237* ==================
238*>
239*> Karen Braman and Ralph Byers, Department of Mathematics,
240*> University of Kansas, USA
241*
242*> \par Further Details:
243* =====================
244*>
245*> \verbatim
246*>
247*> Default values supplied by
248*> ILAENV(ISPEC,'DHSEQR',JOB(:1)//COMPZ(:1),N,ILO,IHI,LWORK).
249*> It is suggested that these defaults be adjusted in order
250*> to attain best performance in each particular
251*> computational environment.
252*>
253*> ISPEC=12: The DLAHQR vs DLAQR0 crossover point.
254*> Default: 75. (Must be at least 11.)
255*>
256*> ISPEC=13: Recommended deflation window size.
257*> This depends on ILO, IHI and NS. NS is the
258*> number of simultaneous shifts returned
259*> by ILAENV(ISPEC=15). (See ISPEC=15 below.)
260*> The default for (IHI-ILO+1) <= 500 is NS.
261*> The default for (IHI-ILO+1) > 500 is 3*NS/2.
262*>
263*> ISPEC=14: Nibble crossover point. (See IPARMQ for
264*> details.) Default: 14% of deflation window
265*> size.
266*>
267*> ISPEC=15: Number of simultaneous shifts in a multishift
268*> QR iteration.
269*>
270*> If IHI-ILO+1 is ...
271*>
272*> greater than ...but less ... the
273*> or equal to ... than default is
274*>
275*> 1 30 NS = 2(+)
276*> 30 60 NS = 4(+)
277*> 60 150 NS = 10(+)
278*> 150 590 NS = **
279*> 590 3000 NS = 64
280*> 3000 6000 NS = 128
281*> 6000 infinity NS = 256
282*>
283*> (+) By default some or all matrices of this order
284*> are passed to the implicit double shift routine
285*> DLAHQR and this parameter is ignored. See
286*> ISPEC=12 above and comments in IPARMQ for
287*> details.
288*>
289*> (**) The asterisks (**) indicate an ad-hoc
290*> function of N increasing from 10 to 64.
291*>
292*> ISPEC=16: Select structured matrix multiply.
293*> If the number of simultaneous shifts (specified
294*> by ISPEC=15) is less than 14, then the default
295*> for ISPEC=16 is 0. Otherwise the default for
296*> ISPEC=16 is 2.
297*> \endverbatim
298*
299*> \par References:
300* ================
301*>
302*> K. Braman, R. Byers and R. Mathias, The Multi-Shift QR
303*> Algorithm Part I: Maintaining Well Focused Shifts, and Level 3
304*> Performance, SIAM Journal of Matrix Analysis, volume 23, pages
305*> 929--947, 2002.
306*> \n
307*> K. Braman, R. Byers and R. Mathias, The Multi-Shift QR
308*> Algorithm Part II: Aggressive Early Deflation, SIAM Journal
309*> of Matrix Analysis, volume 23, pages 948--973, 2002.
310*
311* =====================================================================
312 SUBROUTINE dhseqr( JOB, COMPZ, N, ILO, IHI, H, LDH, WR, WI, Z,
313 $ LDZ, WORK, LWORK, INFO )
314*
315* -- LAPACK computational routine --
316* -- LAPACK is a software package provided by Univ. of Tennessee, --
317* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
318*
319* .. Scalar Arguments ..
320 INTEGER IHI, ILO, INFO, LDH, LDZ, LWORK, N
321 CHARACTER COMPZ, JOB
322* ..
323* .. Array Arguments ..
324 DOUBLE PRECISION H( LDH, * ), WI( * ), WORK( * ), WR( * ),
325 $ z( ldz, * )
326* ..
327*
328* =====================================================================
329*
330* .. Parameters ..
331*
332* ==== Matrices of order NTINY or smaller must be processed by
333* . DLAHQR because of insufficient subdiagonal scratch space.
334* . (This is a hard limit.) ====
335 INTEGER NTINY
336 parameter( ntiny = 15 )
337*
338* ==== NL allocates some local workspace to help small matrices
339* . through a rare DLAHQR failure. NL > NTINY = 15 is
340* . required and NL <= NMIN = ILAENV(ISPEC=12,...) is recom-
341* . mended. (The default value of NMIN is 75.) Using NL = 49
342* . allows up to six simultaneous shifts and a 16-by-16
343* . deflation window. ====
344 INTEGER NL
345 parameter( nl = 49 )
346 DOUBLE PRECISION ZERO, ONE
347 parameter( zero = 0.0d0, one = 1.0d0 )
348* ..
349* .. Local Arrays ..
350 DOUBLE PRECISION HL( NL, NL ), WORKL( NL )
351* ..
352* .. Local Scalars ..
353 INTEGER I, KBOT, NMIN
354 LOGICAL INITZ, LQUERY, WANTT, WANTZ
355* ..
356* .. External Functions ..
357 INTEGER ILAENV
358 LOGICAL LSAME
359 EXTERNAL ilaenv, lsame
360* ..
361* .. External Subroutines ..
362 EXTERNAL dlacpy, dlahqr, dlaqr0, dlaset,
363 $ xerbla
364* ..
365* .. Intrinsic Functions ..
366 INTRINSIC dble, max, min
367* ..
368* .. Executable Statements ..
369*
370* ==== Decode and check the input parameters. ====
371*
372 wantt = lsame( job, 'S' )
373 initz = lsame( compz, 'I' )
374 wantz = initz .OR. lsame( compz, 'V' )
375 work( 1 ) = dble( max( 1, n ) )
376 lquery = lwork.EQ.-1
377*
378 info = 0
379 IF( .NOT.lsame( job, 'E' ) .AND. .NOT.wantt ) THEN
380 info = -1
381 ELSE IF( .NOT.lsame( compz, 'N' ) .AND. .NOT.wantz ) THEN
382 info = -2
383 ELSE IF( n.LT.0 ) THEN
384 info = -3
385 ELSE IF( ilo.LT.1 .OR. ilo.GT.max( 1, n ) ) THEN
386 info = -4
387 ELSE IF( ihi.LT.min( ilo, n ) .OR. ihi.GT.n ) THEN
388 info = -5
389 ELSE IF( ldh.LT.max( 1, n ) ) THEN
390 info = -7
391 ELSE IF( ldz.LT.1 .OR. ( wantz .AND. ldz.LT.max( 1, n ) ) ) THEN
392 info = -11
393 ELSE IF( lwork.LT.max( 1, n ) .AND. .NOT.lquery ) THEN
394 info = -13
395 END IF
396*
397 IF( info.NE.0 ) THEN
398*
399* ==== Quick return in case of invalid argument. ====
400*
401 CALL xerbla( 'DHSEQR', -info )
402 RETURN
403*
404 ELSE IF( n.EQ.0 ) THEN
405*
406* ==== Quick return in case N = 0; nothing to do. ====
407*
408 RETURN
409*
410 ELSE IF( lquery ) THEN
411*
412* ==== Quick return in case of a workspace query ====
413*
414 CALL dlaqr0( wantt, wantz, n, ilo, ihi, h, ldh, wr, wi, ilo,
415 $ ihi, z, ldz, work, lwork, info )
416* ==== Ensure reported workspace size is backward-compatible with
417* . previous LAPACK versions. ====
418 work( 1 ) = max( dble( max( 1, n ) ), work( 1 ) )
419 RETURN
420*
421 ELSE
422*
423* ==== copy eigenvalues isolated by DGEBAL ====
424*
425 DO 10 i = 1, ilo - 1
426 wr( i ) = h( i, i )
427 wi( i ) = zero
428 10 CONTINUE
429 DO 20 i = ihi + 1, n
430 wr( i ) = h( i, i )
431 wi( i ) = zero
432 20 CONTINUE
433*
434* ==== Initialize Z, if requested ====
435*
436 IF( initz )
437 $ CALL dlaset( 'A', n, n, zero, one, z, ldz )
438*
439* ==== Quick return if possible ====
440*
441 IF( ilo.EQ.ihi ) THEN
442 wr( ilo ) = h( ilo, ilo )
443 wi( ilo ) = zero
444 RETURN
445 END IF
446*
447* ==== DLAHQR/DLAQR0 crossover point ====
448*
449 nmin = ilaenv( 12, 'DHSEQR', job( : 1 ) // compz( : 1 ), n,
450 $ ilo, ihi, lwork )
451 nmin = max( ntiny, nmin )
452*
453* ==== DLAQR0 for big matrices; DLAHQR for small ones ====
454*
455 IF( n.GT.nmin ) THEN
456 CALL dlaqr0( wantt, wantz, n, ilo, ihi, h, ldh, wr, wi,
457 $ ilo,
458 $ ihi, z, ldz, work, lwork, info )
459 ELSE
460*
461* ==== Small matrix ====
462*
463 CALL dlahqr( wantt, wantz, n, ilo, ihi, h, ldh, wr, wi,
464 $ ilo,
465 $ ihi, z, ldz, info )
466*
467 IF( info.GT.0 ) THEN
468*
469* ==== A rare DLAHQR failure! DLAQR0 sometimes succeeds
470* . when DLAHQR fails. ====
471*
472 kbot = info
473*
474 IF( n.GE.nl ) THEN
475*
476* ==== Larger matrices have enough subdiagonal scratch
477* . space to call DLAQR0 directly. ====
478*
479 CALL dlaqr0( wantt, wantz, n, ilo, kbot, h, ldh,
480 $ wr,
481 $ wi, ilo, ihi, z, ldz, work, lwork, info )
482*
483 ELSE
484*
485* ==== Tiny matrices don't have enough subdiagonal
486* . scratch space to benefit from DLAQR0. Hence,
487* . tiny matrices must be copied into a larger
488* . array before calling DLAQR0. ====
489*
490 CALL dlacpy( 'A', n, n, h, ldh, hl, nl )
491 hl( n+1, n ) = zero
492 CALL dlaset( 'A', nl, nl-n, zero, zero, hl( 1,
493 $ n+1 ),
494 $ nl )
495 CALL dlaqr0( wantt, wantz, nl, ilo, kbot, hl, nl,
496 $ wr,
497 $ wi, ilo, ihi, z, ldz, workl, nl, info )
498 IF( wantt .OR. info.NE.0 )
499 $ CALL dlacpy( 'A', n, n, hl, nl, h, ldh )
500 END IF
501 END IF
502 END IF
503*
504* ==== Clear out the trash, if necessary. ====
505*
506 IF( ( wantt .OR. info.NE.0 ) .AND. n.GT.2 )
507 $ CALL dlaset( 'L', n-2, n-2, zero, zero, h( 3, 1 ), ldh )
508*
509* ==== Ensure reported workspace size is backward-compatible with
510* . previous LAPACK versions. ====
511*
512 work( 1 ) = max( dble( max( 1, n ) ), work( 1 ) )
513 END IF
514*
515* ==== End of DHSEQR ====
516*
517 END
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine dhseqr(job, compz, n, ilo, ihi, h, ldh, wr, wi, z, ldz, work, lwork, info)
DHSEQR
Definition dhseqr.f:314
subroutine dlacpy(uplo, m, n, a, lda, b, ldb)
DLACPY copies all or part of one two-dimensional array to another.
Definition dlacpy.f:101
subroutine dlahqr(wantt, wantz, n, ilo, ihi, h, ldh, wr, wi, iloz, ihiz, z, ldz, info)
DLAHQR computes the eigenvalues and Schur factorization of an upper Hessenberg matrix,...
Definition dlahqr.f:205
subroutine dlaqr0(wantt, wantz, n, ilo, ihi, h, ldh, wr, wi, iloz, ihiz, z, ldz, work, lwork, info)
DLAQR0 computes the eigenvalues of a Hessenberg matrix, and optionally the matrices from the Schur de...
Definition dlaqr0.f:254
subroutine dlaset(uplo, m, n, alpha, beta, a, lda)
DLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values.
Definition dlaset.f:108