3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
9 *> Download SHSEIN + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/shsein.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/shsein.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/shsein.f">
21 * SUBROUTINE SHSEIN( SIDE, EIGSRC, INITV, SELECT, N, H, LDH, WR, WI,
22 * VL, LDVL, VR, LDVR, MM, M, WORK, IFAILL,
25 * .. Scalar Arguments ..
26 * CHARACTER EIGSRC, INITV, SIDE
27 * INTEGER INFO, LDH, LDVL, LDVR, M, MM, N
29 * .. Array Arguments ..
31 * INTEGER IFAILL( * ), IFAILR( * )
32 * REAL H( LDH, * ), VL( LDVL, * ), VR( LDVR, * ),
33 * $ WI( * ), WORK( * ), WR( * )
42 *> SHSEIN uses inverse iteration to find specified right and/or left
43 *> eigenvectors of a real upper Hessenberg matrix H.
45 *> The right eigenvector x and the left eigenvector y of the matrix H
46 *> corresponding to an eigenvalue w are defined by:
48 *> H * x = w * x, y**h * H = w * y**h
50 *> where y**h denotes the conjugate transpose of the vector y.
58 *> SIDE is CHARACTER*1
59 *> = 'R': compute right eigenvectors only;
60 *> = 'L': compute left eigenvectors only;
61 *> = 'B': compute both right and left eigenvectors.
66 *> EIGSRC is CHARACTER*1
67 *> Specifies the source of eigenvalues supplied in (WR,WI):
68 *> = 'Q': the eigenvalues were found using SHSEQR; thus, if
69 *> H has zero subdiagonal elements, and so is
70 *> block-triangular, then the j-th eigenvalue can be
71 *> assumed to be an eigenvalue of the block containing
72 *> the j-th row/column. This property allows SHSEIN to
73 *> perform inverse iteration on just one diagonal block.
74 *> = 'N': no assumptions are made on the correspondence
75 *> between eigenvalues and diagonal blocks. In this
76 *> case, SHSEIN must always perform inverse iteration
77 *> using the whole matrix H.
82 *> INITV is CHARACTER*1
83 *> = 'N': no initial vectors are supplied;
84 *> = 'U': user-supplied initial vectors are stored in the arrays
88 *> \param[in,out] SELECT
90 *> SELECT is LOGICAL array, dimension (N)
91 *> Specifies the eigenvectors to be computed. To select the
92 *> real eigenvector corresponding to a real eigenvalue WR(j),
93 *> SELECT(j) must be set to .TRUE.. To select the complex
94 *> eigenvector corresponding to a complex eigenvalue
95 *> (WR(j),WI(j)), with complex conjugate (WR(j+1),WI(j+1)),
96 *> either SELECT(j) or SELECT(j+1) or both must be set to
97 *> .TRUE.; then on exit SELECT(j) is .TRUE. and SELECT(j+1) is
104 *> The order of the matrix H. N >= 0.
109 *> H is REAL array, dimension (LDH,N)
110 *> The upper Hessenberg matrix H.
111 *> If a NaN is detected in H, the routine will return with INFO=-6.
117 *> The leading dimension of the array H. LDH >= max(1,N).
122 *> WR is REAL array, dimension (N)
127 *> WI is REAL array, dimension (N)
129 *> On entry, the real and imaginary parts of the eigenvalues of
130 *> H; a complex conjugate pair of eigenvalues must be stored in
131 *> consecutive elements of WR and WI.
132 *> On exit, WR may have been altered since close eigenvalues
133 *> are perturbed slightly in searching for independent
139 *> VL is REAL array, dimension (LDVL,MM)
140 *> On entry, if INITV = 'U' and SIDE = 'L' or 'B', VL must
141 *> contain starting vectors for the inverse iteration for the
142 *> left eigenvectors; the starting vector for each eigenvector
143 *> must be in the same column(s) in which the eigenvector will
145 *> On exit, if SIDE = 'L' or 'B', the left eigenvectors
146 *> specified by SELECT will be stored consecutively in the
147 *> columns of VL, in the same order as their eigenvalues. A
148 *> complex eigenvector corresponding to a complex eigenvalue is
149 *> stored in two consecutive columns, the first holding the real
150 *> part and the second the imaginary part.
151 *> If SIDE = 'R', VL is not referenced.
157 *> The leading dimension of the array VL.
158 *> LDVL >= max(1,N) if SIDE = 'L' or 'B'; LDVL >= 1 otherwise.
163 *> VR is REAL array, dimension (LDVR,MM)
164 *> On entry, if INITV = 'U' and SIDE = 'R' or 'B', VR must
165 *> contain starting vectors for the inverse iteration for the
166 *> right eigenvectors; the starting vector for each eigenvector
167 *> must be in the same column(s) in which the eigenvector will
169 *> On exit, if SIDE = 'R' or 'B', the right eigenvectors
170 *> specified by SELECT will be stored consecutively in the
171 *> columns of VR, in the same order as their eigenvalues. A
172 *> complex eigenvector corresponding to a complex eigenvalue is
173 *> stored in two consecutive columns, the first holding the real
174 *> part and the second the imaginary part.
175 *> If SIDE = 'L', VR is not referenced.
181 *> The leading dimension of the array VR.
182 *> LDVR >= max(1,N) if SIDE = 'R' or 'B'; LDVR >= 1 otherwise.
188 *> The number of columns in the arrays VL and/or VR. MM >= M.
194 *> The number of columns in the arrays VL and/or VR required to
195 *> store the eigenvectors; each selected real eigenvector
196 *> occupies one column and each selected complex eigenvector
197 *> occupies two columns.
202 *> WORK is REAL array, dimension ((N+2)*N)
205 *> \param[out] IFAILL
207 *> IFAILL is INTEGER array, dimension (MM)
208 *> If SIDE = 'L' or 'B', IFAILL(i) = j > 0 if the left
209 *> eigenvector in the i-th column of VL (corresponding to the
210 *> eigenvalue w(j)) failed to converge; IFAILL(i) = 0 if the
211 *> eigenvector converged satisfactorily. If the i-th and (i+1)th
212 *> columns of VL hold a complex eigenvector, then IFAILL(i) and
213 *> IFAILL(i+1) are set to the same value.
214 *> If SIDE = 'R', IFAILL is not referenced.
217 *> \param[out] IFAILR
219 *> IFAILR is INTEGER array, dimension (MM)
220 *> If SIDE = 'R' or 'B', IFAILR(i) = j > 0 if the right
221 *> eigenvector in the i-th column of VR (corresponding to the
222 *> eigenvalue w(j)) failed to converge; IFAILR(i) = 0 if the
223 *> eigenvector converged satisfactorily. If the i-th and (i+1)th
224 *> columns of VR hold a complex eigenvector, then IFAILR(i) and
225 *> IFAILR(i+1) are set to the same value.
226 *> If SIDE = 'L', IFAILR is not referenced.
232 *> = 0: successful exit
233 *> < 0: if INFO = -i, the i-th argument had an illegal value
234 *> > 0: if INFO = i, i is the number of eigenvectors which
235 *> failed to converge; see IFAILL and IFAILR for further
242 *> \author Univ. of Tennessee
243 *> \author Univ. of California Berkeley
244 *> \author Univ. of Colorado Denver
247 *> \date November 2013
249 *> \ingroup realOTHERcomputational
251 *> \par Further Details:
252 * =====================
256 *> Each eigenvector is normalized so that the element of largest
257 *> magnitude has magnitude 1; here the magnitude of a complex number
258 *> (x,y) is taken to be |x|+|y|.
261 * =====================================================================
262 SUBROUTINE SHSEIN( SIDE, EIGSRC, INITV, SELECT, N, H, LDH, WR, WI,
263 $ VL, LDVL, VR, LDVR, MM, M, WORK, IFAILL,
266 * -- LAPACK computational routine (version 3.5.0) --
267 * -- LAPACK is a software package provided by Univ. of Tennessee, --
268 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
271 * .. Scalar Arguments ..
272 CHARACTER EIGSRC, INITV, SIDE
273 INTEGER INFO, LDH, LDVL, LDVR, M, MM, N
275 * .. Array Arguments ..
277 INTEGER IFAILL( * ), IFAILR( * )
278 REAL H( LDH, * ), VL( LDVL, * ), VR( LDVR, * ),
279 $ WI( * ), WORK( * ), WR( * )
282 * =====================================================================
286 PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0 )
288 * .. Local Scalars ..
289 LOGICAL BOTHV, FROMQR, LEFTV, NOINIT, PAIR, RIGHTV
290 INTEGER I, IINFO, K, KL, KLN, KR, KSI, KSR, LDWORK
291 REAL BIGNUM, EPS3, HNORM, SMLNUM, ULP, UNFL, WKI,
294 * .. External Functions ..
295 LOGICAL LSAME, SISNAN
297 EXTERNAL LSAME, SLAMCH, SLANHS, SISNAN
299 * .. External Subroutines ..
300 EXTERNAL SLAEIN, XERBLA
302 * .. Intrinsic Functions ..
305 * .. Executable Statements ..
307 * Decode and test the input parameters.
309 BOTHV = LSAME( SIDE, 'B' )
310 RIGHTV = LSAME( SIDE, 'R' ) .OR. BOTHV
311 LEFTV = LSAME( SIDE, 'L' ) .OR. BOTHV
313 FROMQR = LSAME( EIGSRC, 'Q' )
315 NOINIT = LSAME( INITV, 'N' )
317 * Set M to the number of columns required to store the selected
318 * eigenvectors, and standardize the array SELECT.
325 SELECT( K ) = .FALSE.
327 IF( WI( K ).EQ.ZERO ) THEN
332 IF( SELECT( K ) .OR. SELECT( K+1 ) ) THEN
341 IF( .NOT.RIGHTV .AND. .NOT.LEFTV ) THEN
343 ELSE IF( .NOT.FROMQR .AND. .NOT.LSAME( EIGSRC, 'N' ) ) THEN
345 ELSE IF( .NOT.NOINIT .AND. .NOT.LSAME( INITV, 'U' ) ) THEN
347 ELSE IF( N.LT.0 ) THEN
349 ELSE IF( LDH.LT.MAX( 1, N ) ) THEN
351 ELSE IF( LDVL.LT.1 .OR. ( LEFTV .AND. LDVL.LT.N ) ) THEN
353 ELSE IF( LDVR.LT.1 .OR. ( RIGHTV .AND. LDVR.LT.N ) ) THEN
355 ELSE IF( MM.LT.M ) THEN
359 CALL XERBLA( 'SHSEIN', -INFO )
363 * Quick return if possible.
368 * Set machine-dependent constants.
370 UNFL = SLAMCH( 'Safe minimum' )
371 ULP = SLAMCH( 'Precision' )
372 SMLNUM = UNFL*( N / ULP )
373 BIGNUM = ( ONE-ULP ) / SMLNUM
387 IF( SELECT( K ) ) THEN
389 * Compute eigenvector(s) corresponding to W(K).
393 * If affiliation of eigenvalues is known, check whether
396 * Determine KL and KR such that 1 <= KL <= K <= KR <= N
397 * and H(KL,KL-1) and H(KR+1,KR) are zero (or KL = 1 or
400 * Then inverse iteration can be performed with the
401 * submatrix H(KL:N,KL:N) for a left eigenvector, and with
402 * the submatrix H(1:KR,1:KR) for a right eigenvector.
404 DO 20 I = K, KL + 1, -1
405 IF( H( I, I-1 ).EQ.ZERO )
412 IF( H( I+1, I ).EQ.ZERO )
423 * Compute infinity-norm of submatrix H(KL:KR,KL:KR) if it
424 * has not ben computed before.
426 HNORM = SLANHS( 'I', KR-KL+1, H( KL, KL ), LDH, WORK )
427 IF( SISNAN( HNORM ) ) THEN
430 ELSE IF( HNORM.GT.ZERO ) THEN
437 * Perturb eigenvalue if it is close to any previous
438 * selected eigenvalues affiliated to the submatrix
439 * H(KL:KR,KL:KR). Close roots are modified by EPS3.
444 DO 70 I = K - 1, KL, -1
445 IF( SELECT( I ) .AND. ABS( WR( I )-WKR )+
446 $ ABS( WI( I )-WKI ).LT.EPS3 ) THEN
461 * Compute left eigenvector.
463 CALL SLAEIN( .FALSE., NOINIT, N-KL+1, H( KL, KL ), LDH,
464 $ WKR, WKI, VL( KL, KSR ), VL( KL, KSI ),
465 $ WORK, LDWORK, WORK( N*N+N+1 ), EPS3, SMLNUM,
467 IF( IINFO.GT.0 ) THEN
490 * Compute right eigenvector.
492 CALL SLAEIN( .TRUE., NOINIT, KR, H, LDH, WKR, WKI,
493 $ VR( 1, KSR ), VR( 1, KSI ), WORK, LDWORK,
494 $ WORK( N*N+N+1 ), EPS3, SMLNUM, BIGNUM,
496 IF( IINFO.GT.0 ) THEN