LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
claein.f
Go to the documentation of this file.
1*> \brief \b CLAEIN computes a specified right or left eigenvector of an upper Hessenberg matrix by inverse iteration.
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8*> Download CLAEIN + dependencies
9*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/claein.f">
10*> [TGZ]</a>
11*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/claein.f">
12*> [ZIP]</a>
13*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/claein.f">
14*> [TXT]</a>
15*
16* Definition:
17* ===========
18*
19* SUBROUTINE CLAEIN( RIGHTV, NOINIT, N, H, LDH, W, V, B, LDB, RWORK,
20* EPS3, SMLNUM, INFO )
21*
22* .. Scalar Arguments ..
23* LOGICAL NOINIT, RIGHTV
24* INTEGER INFO, LDB, LDH, N
25* REAL EPS3, SMLNUM
26* COMPLEX W
27* ..
28* .. Array Arguments ..
29* REAL RWORK( * )
30* COMPLEX B( LDB, * ), H( LDH, * ), V( * )
31* ..
32*
33*
34*> \par Purpose:
35* =============
36*>
37*> \verbatim
38*>
39*> CLAEIN uses inverse iteration to find a right or left eigenvector
40*> corresponding to the eigenvalue W of a complex upper Hessenberg
41*> matrix H.
42*> \endverbatim
43*
44* Arguments:
45* ==========
46*
47*> \param[in] RIGHTV
48*> \verbatim
49*> RIGHTV is LOGICAL
50*> = .TRUE. : compute right eigenvector;
51*> = .FALSE.: compute left eigenvector.
52*> \endverbatim
53*>
54*> \param[in] NOINIT
55*> \verbatim
56*> NOINIT is LOGICAL
57*> = .TRUE. : no initial vector supplied in V
58*> = .FALSE.: initial vector supplied in V.
59*> \endverbatim
60*>
61*> \param[in] N
62*> \verbatim
63*> N is INTEGER
64*> The order of the matrix H. N >= 0.
65*> \endverbatim
66*>
67*> \param[in] H
68*> \verbatim
69*> H is COMPLEX array, dimension (LDH,N)
70*> The upper Hessenberg matrix H.
71*> \endverbatim
72*>
73*> \param[in] LDH
74*> \verbatim
75*> LDH is INTEGER
76*> The leading dimension of the array H. LDH >= max(1,N).
77*> \endverbatim
78*>
79*> \param[in] W
80*> \verbatim
81*> W is COMPLEX
82*> The eigenvalue of H whose corresponding right or left
83*> eigenvector is to be computed.
84*> \endverbatim
85*>
86*> \param[in,out] V
87*> \verbatim
88*> V is COMPLEX array, dimension (N)
89*> On entry, if NOINIT = .FALSE., V must contain a starting
90*> vector for inverse iteration; otherwise V need not be set.
91*> On exit, V contains the computed eigenvector, normalized so
92*> that the component of largest magnitude has magnitude 1; here
93*> the magnitude of a complex number (x,y) is taken to be
94*> |x| + |y|.
95*> \endverbatim
96*>
97*> \param[out] B
98*> \verbatim
99*> B is COMPLEX array, dimension (LDB,N)
100*> \endverbatim
101*>
102*> \param[in] LDB
103*> \verbatim
104*> LDB is INTEGER
105*> The leading dimension of the array B. LDB >= max(1,N).
106*> \endverbatim
107*>
108*> \param[out] RWORK
109*> \verbatim
110*> RWORK is REAL array, dimension (N)
111*> \endverbatim
112*>
113*> \param[in] EPS3
114*> \verbatim
115*> EPS3 is REAL
116*> A small machine-dependent value which is used to perturb
117*> close eigenvalues, and to replace zero pivots.
118*> \endverbatim
119*>
120*> \param[in] SMLNUM
121*> \verbatim
122*> SMLNUM is REAL
123*> A machine-dependent value close to the underflow threshold.
124*> \endverbatim
125*>
126*> \param[out] INFO
127*> \verbatim
128*> INFO is INTEGER
129*> = 0: successful exit
130*> = 1: inverse iteration did not converge; V is set to the
131*> last iterate.
132*> \endverbatim
133*
134* Authors:
135* ========
136*
137*> \author Univ. of Tennessee
138*> \author Univ. of California Berkeley
139*> \author Univ. of Colorado Denver
140*> \author NAG Ltd.
141*
142*> \ingroup laein
143*
144* =====================================================================
145 SUBROUTINE claein( RIGHTV, NOINIT, N, H, LDH, W, V, B, LDB,
146 $ RWORK,
147 $ EPS3, SMLNUM, INFO )
148*
149* -- LAPACK auxiliary routine --
150* -- LAPACK is a software package provided by Univ. of Tennessee, --
151* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
152*
153* .. Scalar Arguments ..
154 LOGICAL NOINIT, RIGHTV
155 INTEGER INFO, LDB, LDH, N
156 REAL EPS3, SMLNUM
157 COMPLEX W
158* ..
159* .. Array Arguments ..
160 REAL RWORK( * )
161 COMPLEX B( LDB, * ), H( LDH, * ), V( * )
162* ..
163*
164* =====================================================================
165*
166* .. Parameters ..
167 REAL ONE, TENTH
168 PARAMETER ( ONE = 1.0e+0, tenth = 1.0e-1 )
169 COMPLEX ZERO
170 parameter( zero = ( 0.0e+0, 0.0e+0 ) )
171* ..
172* .. Local Scalars ..
173 CHARACTER NORMIN, TRANS
174 INTEGER I, IERR, ITS, J
175 REAL GROWTO, NRMSML, ROOTN, RTEMP, SCALE, VNORM
176 COMPLEX CDUM, EI, EJ, TEMP, X
177* ..
178* .. External Functions ..
179 INTEGER ICAMAX
180 REAL SCASUM, SCNRM2
181 COMPLEX CLADIV
182 EXTERNAL icamax, scasum, scnrm2, cladiv
183* ..
184* .. External Subroutines ..
185 EXTERNAL clatrs, csscal
186* ..
187* .. Intrinsic Functions ..
188 INTRINSIC abs, aimag, max, real, sqrt
189* ..
190* .. Statement Functions ..
191 REAL CABS1
192* ..
193* .. Statement Function definitions ..
194 cabs1( cdum ) = abs( real( cdum ) ) + abs( aimag( cdum ) )
195* ..
196* .. Executable Statements ..
197*
198 info = 0
199*
200* GROWTO is the threshold used in the acceptance test for an
201* eigenvector.
202*
203 rootn = sqrt( real( n ) )
204 growto = tenth / rootn
205 nrmsml = max( one, eps3*rootn )*smlnum
206*
207* Form B = H - W*I (except that the subdiagonal elements are not
208* stored).
209*
210 DO 20 j = 1, n
211 DO 10 i = 1, j - 1
212 b( i, j ) = h( i, j )
213 10 CONTINUE
214 b( j, j ) = h( j, j ) - w
215 20 CONTINUE
216*
217 IF( noinit ) THEN
218*
219* Initialize V.
220*
221 DO 30 i = 1, n
222 v( i ) = eps3
223 30 CONTINUE
224 ELSE
225*
226* Scale supplied initial vector.
227*
228 vnorm = scnrm2( n, v, 1 )
229 CALL csscal( n, ( eps3*rootn ) / max( vnorm, nrmsml ), v,
230 $ 1 )
231 END IF
232*
233 IF( rightv ) THEN
234*
235* LU decomposition with partial pivoting of B, replacing zero
236* pivots by EPS3.
237*
238 DO 60 i = 1, n - 1
239 ei = h( i+1, i )
240 IF( cabs1( b( i, i ) ).LT.cabs1( ei ) ) THEN
241*
242* Interchange rows and eliminate.
243*
244 x = cladiv( b( i, i ), ei )
245 b( i, i ) = ei
246 DO 40 j = i + 1, n
247 temp = b( i+1, j )
248 b( i+1, j ) = b( i, j ) - x*temp
249 b( i, j ) = temp
250 40 CONTINUE
251 ELSE
252*
253* Eliminate without interchange.
254*
255 IF( b( i, i ).EQ.zero )
256 $ b( i, i ) = eps3
257 x = cladiv( ei, b( i, i ) )
258 IF( x.NE.zero ) THEN
259 DO 50 j = i + 1, n
260 b( i+1, j ) = b( i+1, j ) - x*b( i, j )
261 50 CONTINUE
262 END IF
263 END IF
264 60 CONTINUE
265 IF( b( n, n ).EQ.zero )
266 $ b( n, n ) = eps3
267*
268 trans = 'N'
269*
270 ELSE
271*
272* UL decomposition with partial pivoting of B, replacing zero
273* pivots by EPS3.
274*
275 DO 90 j = n, 2, -1
276 ej = h( j, j-1 )
277 IF( cabs1( b( j, j ) ).LT.cabs1( ej ) ) THEN
278*
279* Interchange columns and eliminate.
280*
281 x = cladiv( b( j, j ), ej )
282 b( j, j ) = ej
283 DO 70 i = 1, j - 1
284 temp = b( i, j-1 )
285 b( i, j-1 ) = b( i, j ) - x*temp
286 b( i, j ) = temp
287 70 CONTINUE
288 ELSE
289*
290* Eliminate without interchange.
291*
292 IF( b( j, j ).EQ.zero )
293 $ b( j, j ) = eps3
294 x = cladiv( ej, b( j, j ) )
295 IF( x.NE.zero ) THEN
296 DO 80 i = 1, j - 1
297 b( i, j-1 ) = b( i, j-1 ) - x*b( i, j )
298 80 CONTINUE
299 END IF
300 END IF
301 90 CONTINUE
302 IF( b( 1, 1 ).EQ.zero )
303 $ b( 1, 1 ) = eps3
304*
305 trans = 'C'
306*
307 END IF
308*
309 normin = 'N'
310 DO 110 its = 1, n
311*
312* Solve U*x = scale*v for a right eigenvector
313* or U**H *x = scale*v for a left eigenvector,
314* overwriting x on v.
315*
316 CALL clatrs( 'Upper', trans, 'Nonunit', normin, n, b, ldb,
317 $ v,
318 $ scale, rwork, ierr )
319 normin = 'Y'
320*
321* Test for sufficient growth in the norm of v.
322*
323 vnorm = scasum( n, v, 1 )
324 IF( vnorm.GE.growto*scale )
325 $ GO TO 120
326*
327* Choose new orthogonal starting vector and try again.
328*
329 rtemp = eps3 / ( rootn+one )
330 v( 1 ) = eps3
331 DO 100 i = 2, n
332 v( i ) = rtemp
333 100 CONTINUE
334 v( n-its+1 ) = v( n-its+1 ) - eps3*rootn
335 110 CONTINUE
336*
337* Failure to find eigenvector in N iterations.
338*
339 info = 1
340*
341 120 CONTINUE
342*
343* Normalize eigenvector.
344*
345 i = icamax( n, v, 1 )
346 CALL csscal( n, one / cabs1( v( i ) ), v, 1 )
347*
348 RETURN
349*
350* End of CLAEIN
351*
352 END
subroutine claein(rightv, noinit, n, h, ldh, w, v, b, ldb, rwork, eps3, smlnum, info)
CLAEIN computes a specified right or left eigenvector of an upper Hessenberg matrix by inverse iterat...
Definition claein.f:148
subroutine clatrs(uplo, trans, diag, normin, n, a, lda, x, scale, cnorm, info)
CLATRS solves a triangular system of equations with the scale factor set to prevent overflow.
Definition clatrs.f:238
subroutine csscal(n, sa, cx, incx)
CSSCAL
Definition csscal.f:78