3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
9 *> Download CHSEIN + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/chsein.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/chsein.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/chsein.f">
21 * SUBROUTINE CHSEIN( SIDE, EIGSRC, INITV, SELECT, N, H, LDH, W, VL,
22 * LDVL, VR, LDVR, MM, M, WORK, RWORK, 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( * )
33 * COMPLEX H( LDH, * ), VL( LDVL, * ), VR( LDVR, * ),
43 *> CHSEIN uses inverse iteration to find specified right and/or left
44 *> eigenvectors of a complex upper Hessenberg matrix H.
46 *> The right eigenvector x and the left eigenvector y of the matrix H
47 *> corresponding to an eigenvalue w are defined by:
49 *> H * x = w * x, y**h * H = w * y**h
51 *> where y**h denotes the conjugate transpose of the vector y.
59 *> SIDE is CHARACTER*1
60 *> = 'R': compute right eigenvectors only;
61 *> = 'L': compute left eigenvectors only;
62 *> = 'B': compute both right and left eigenvectors.
67 *> EIGSRC is CHARACTER*1
68 *> Specifies the source of eigenvalues supplied in W:
69 *> = 'Q': the eigenvalues were found using CHSEQR; thus, if
70 *> H has zero subdiagonal elements, and so is
71 *> block-triangular, then the j-th eigenvalue can be
72 *> assumed to be an eigenvalue of the block containing
73 *> the j-th row/column. This property allows CHSEIN to
74 *> perform inverse iteration on just one diagonal block.
75 *> = 'N': no assumptions are made on the correspondence
76 *> between eigenvalues and diagonal blocks. In this
77 *> case, CHSEIN must always perform inverse iteration
78 *> using the whole matrix H.
83 *> INITV is CHARACTER*1
84 *> = 'N': no initial vectors are supplied;
85 *> = 'U': user-supplied initial vectors are stored in the arrays
91 *> SELECT is LOGICAL array, dimension (N)
92 *> Specifies the eigenvectors to be computed. To select the
93 *> eigenvector corresponding to the eigenvalue W(j),
94 *> SELECT(j) must be set to .TRUE..
100 *> The order of the matrix H. N >= 0.
105 *> H is COMPLEX array, dimension (LDH,N)
106 *> The upper Hessenberg matrix H.
107 *> If a NaN is detected in H, the routine will return with INFO=-6.
113 *> The leading dimension of the array H. LDH >= max(1,N).
118 *> W is COMPLEX array, dimension (N)
119 *> On entry, the eigenvalues of H.
120 *> On exit, the real parts of W may have been altered since
121 *> close eigenvalues are perturbed slightly in searching for
122 *> independent eigenvectors.
127 *> VL is COMPLEX array, dimension (LDVL,MM)
128 *> On entry, if INITV = 'U' and SIDE = 'L' or 'B', VL must
129 *> contain starting vectors for the inverse iteration for the
130 *> left eigenvectors; the starting vector for each eigenvector
131 *> must be in the same column in which the eigenvector will be
133 *> On exit, if SIDE = 'L' or 'B', the left eigenvectors
134 *> specified by SELECT will be stored consecutively in the
135 *> columns of VL, in the same order as their eigenvalues.
136 *> If SIDE = 'R', VL is not referenced.
142 *> The leading dimension of the array VL.
143 *> LDVL >= max(1,N) if SIDE = 'L' or 'B'; LDVL >= 1 otherwise.
148 *> VR is COMPLEX array, dimension (LDVR,MM)
149 *> On entry, if INITV = 'U' and SIDE = 'R' or 'B', VR must
150 *> contain starting vectors for the inverse iteration for the
151 *> right eigenvectors; the starting vector for each eigenvector
152 *> must be in the same column in which the eigenvector will be
154 *> On exit, if SIDE = 'R' or 'B', the right eigenvectors
155 *> specified by SELECT will be stored consecutively in the
156 *> columns of VR, in the same order as their eigenvalues.
157 *> If SIDE = 'L', VR is not referenced.
163 *> The leading dimension of the array VR.
164 *> LDVR >= max(1,N) if SIDE = 'R' or 'B'; LDVR >= 1 otherwise.
170 *> The number of columns in the arrays VL and/or VR. MM >= M.
176 *> The number of columns in the arrays VL and/or VR required to
177 *> store the eigenvectors (= the number of .TRUE. elements in
183 *> WORK is COMPLEX array, dimension (N*N)
188 *> RWORK is REAL array, dimension (N)
191 *> \param[out] IFAILL
193 *> IFAILL is INTEGER array, dimension (MM)
194 *> If SIDE = 'L' or 'B', IFAILL(i) = j > 0 if the left
195 *> eigenvector in the i-th column of VL (corresponding to the
196 *> eigenvalue w(j)) failed to converge; IFAILL(i) = 0 if the
197 *> eigenvector converged satisfactorily.
198 *> If SIDE = 'R', IFAILL is not referenced.
201 *> \param[out] IFAILR
203 *> IFAILR is INTEGER array, dimension (MM)
204 *> If SIDE = 'R' or 'B', IFAILR(i) = j > 0 if the right
205 *> eigenvector in the i-th column of VR (corresponding to the
206 *> eigenvalue w(j)) failed to converge; IFAILR(i) = 0 if the
207 *> eigenvector converged satisfactorily.
208 *> If SIDE = 'L', IFAILR is not referenced.
214 *> = 0: successful exit
215 *> < 0: if INFO = -i, the i-th argument had an illegal value
216 *> > 0: if INFO = i, i is the number of eigenvectors which
217 *> failed to converge; see IFAILL and IFAILR for further
224 *> \author Univ. of Tennessee
225 *> \author Univ. of California Berkeley
226 *> \author Univ. of Colorado Denver
229 *> \date November 2013
231 *> \ingroup complexOTHERcomputational
233 *> \par Further Details:
234 * =====================
238 *> Each eigenvector is normalized so that the element of largest
239 *> magnitude has magnitude 1; here the magnitude of a complex number
240 *> (x,y) is taken to be |x|+|y|.
243 * =====================================================================
244 SUBROUTINE CHSEIN( SIDE, EIGSRC, INITV, SELECT, N, H, LDH, W, VL,
245 $ LDVL, VR, LDVR, MM, M, WORK, RWORK, IFAILL,
248 * -- LAPACK computational routine (version 3.5.0) --
249 * -- LAPACK is a software package provided by Univ. of Tennessee, --
250 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
253 * .. Scalar Arguments ..
254 CHARACTER EIGSRC, INITV, SIDE
255 INTEGER INFO, LDH, LDVL, LDVR, M, MM, N
257 * .. Array Arguments ..
259 INTEGER IFAILL( * ), IFAILR( * )
261 COMPLEX H( LDH, * ), VL( LDVL, * ), VR( LDVR, * ),
265 * =====================================================================
269 PARAMETER ( ZERO = ( 0.0E+0, 0.0E+0 ) )
271 PARAMETER ( RZERO = 0.0E+0 )
273 * .. Local Scalars ..
274 LOGICAL BOTHV, FROMQR, LEFTV, NOINIT, RIGHTV
275 INTEGER I, IINFO, K, KL, KLN, KR, KS, LDWORK
276 REAL EPS3, HNORM, SMLNUM, ULP, UNFL
279 * .. External Functions ..
280 LOGICAL LSAME, SISNAN
282 EXTERNAL LSAME, CLANHS, SLAMCH, SISNAN
284 * .. External Subroutines ..
285 EXTERNAL CLAEIN, XERBLA
287 * .. Intrinsic Functions ..
288 INTRINSIC ABS, AIMAG, MAX, REAL
290 * .. Statement Functions ..
293 * .. Statement Function definitions ..
294 CABS1( CDUM ) = ABS( REAL( CDUM ) ) + ABS( AIMAG( CDUM ) )
296 * .. Executable Statements ..
298 * Decode and test the input parameters.
300 BOTHV = LSAME( SIDE, 'B' )
301 RIGHTV = LSAME( SIDE, 'R' ) .OR. BOTHV
302 LEFTV = LSAME( SIDE, 'L' ) .OR. BOTHV
304 FROMQR = LSAME( EIGSRC, 'Q' )
306 NOINIT = LSAME( INITV, 'N' )
308 * Set M to the number of columns required to store the selected
318 IF( .NOT.RIGHTV .AND. .NOT.LEFTV ) THEN
320 ELSE IF( .NOT.FROMQR .AND. .NOT.LSAME( EIGSRC, 'N' ) ) THEN
322 ELSE IF( .NOT.NOINIT .AND. .NOT.LSAME( INITV, 'U' ) ) THEN
324 ELSE IF( N.LT.0 ) THEN
326 ELSE IF( LDH.LT.MAX( 1, N ) ) THEN
328 ELSE IF( LDVL.LT.1 .OR. ( LEFTV .AND. LDVL.LT.N ) ) THEN
330 ELSE IF( LDVR.LT.1 .OR. ( RIGHTV .AND. LDVR.LT.N ) ) THEN
332 ELSE IF( MM.LT.M ) THEN
336 CALL XERBLA( 'CHSEIN', -INFO )
340 * Quick return if possible.
345 * Set machine-dependent constants.
347 UNFL = SLAMCH( 'Safe minimum' )
348 ULP = SLAMCH( 'Precision' )
349 SMLNUM = UNFL*( N / ULP )
363 IF( SELECT( K ) ) THEN
365 * Compute eigenvector(s) corresponding to W(K).
369 * If affiliation of eigenvalues is known, check whether
372 * Determine KL and KR such that 1 <= KL <= K <= KR <= N
373 * and H(KL,KL-1) and H(KR+1,KR) are zero (or KL = 1 or
376 * Then inverse iteration can be performed with the
377 * submatrix H(KL:N,KL:N) for a left eigenvector, and with
378 * the submatrix H(1:KR,1:KR) for a right eigenvector.
380 DO 20 I = K, KL + 1, -1
381 IF( H( I, I-1 ).EQ.ZERO )
388 IF( H( I+1, I ).EQ.ZERO )
399 * Compute infinity-norm of submatrix H(KL:KR,KL:KR) if it
400 * has not ben computed before.
402 HNORM = CLANHS( 'I', KR-KL+1, H( KL, KL ), LDH, RWORK )
403 IF( SISNAN( HNORM ) ) THEN
406 ELSE IF( (HNORM.GT.RZERO) ) THEN
413 * Perturb eigenvalue if it is close to any previous
414 * selected eigenvalues affiliated to the submatrix
415 * H(KL:KR,KL:KR). Close roots are modified by EPS3.
419 DO 70 I = K - 1, KL, -1
420 IF( SELECT( I ) .AND. CABS1( W( I )-WK ).LT.EPS3 ) THEN
429 * Compute left eigenvector.
431 CALL CLAEIN( .FALSE., NOINIT, N-KL+1, H( KL, KL ), LDH,
432 $ WK, VL( KL, KS ), WORK, LDWORK, RWORK, EPS3,
434 IF( IINFO.GT.0 ) THEN
446 * Compute right eigenvector.
448 CALL CLAEIN( .TRUE., NOINIT, KR, H, LDH, WK, VR( 1, KS ),
449 $ WORK, LDWORK, RWORK, EPS3, SMLNUM, IINFO )
450 IF( IINFO.GT.0 ) THEN