3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
9 *> Download ZSTEIN + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zstein.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zstein.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zstein.f">
21 * SUBROUTINE ZSTEIN( N, D, E, M, W, IBLOCK, ISPLIT, Z, LDZ, WORK,
22 * IWORK, IFAIL, INFO )
24 * .. Scalar Arguments ..
25 * INTEGER INFO, LDZ, M, N
27 * .. Array Arguments ..
28 * INTEGER IBLOCK( * ), IFAIL( * ), ISPLIT( * ),
30 * DOUBLE PRECISION D( * ), E( * ), W( * ), WORK( * )
31 * COMPLEX*16 Z( LDZ, * )
40 *> ZSTEIN computes the eigenvectors of a real symmetric tridiagonal
41 *> matrix T corresponding to specified eigenvalues, using inverse
44 *> The maximum number of iterations allowed for each eigenvector is
45 *> specified by an internal parameter MAXITS (currently set to 5).
47 *> Although the eigenvectors are real, they are stored in a complex
48 *> array, which may be passed to ZUNMTR or ZUPMTR for back
49 *> transformation to the eigenvectors of a complex Hermitian matrix
50 *> which was reduced to tridiagonal form.
60 *> The order of the matrix. N >= 0.
65 *> D is DOUBLE PRECISION array, dimension (N)
66 *> The n diagonal elements of the tridiagonal matrix T.
71 *> E is DOUBLE PRECISION array, dimension (N-1)
72 *> The (n-1) subdiagonal elements of the tridiagonal matrix
73 *> T, stored in elements 1 to N-1.
79 *> The number of eigenvectors to be found. 0 <= M <= N.
84 *> W is DOUBLE PRECISION array, dimension (N)
85 *> The first M elements of W contain the eigenvalues for
86 *> which eigenvectors are to be computed. The eigenvalues
87 *> should be grouped by split-off block and ordered from
88 *> smallest to largest within the block. ( The output array
89 *> W from DSTEBZ with ORDER = 'B' is expected here. )
94 *> IBLOCK is INTEGER array, dimension (N)
95 *> The submatrix indices associated with the corresponding
96 *> eigenvalues in W; IBLOCK(i)=1 if eigenvalue W(i) belongs to
97 *> the first submatrix from the top, =2 if W(i) belongs to
98 *> the second submatrix, etc. ( The output array IBLOCK
99 *> from DSTEBZ is expected here. )
104 *> ISPLIT is INTEGER array, dimension (N)
105 *> The splitting points, at which T breaks up into submatrices.
106 *> The first submatrix consists of rows/columns 1 to
107 *> ISPLIT( 1 ), the second of rows/columns ISPLIT( 1 )+1
108 *> through ISPLIT( 2 ), etc.
109 *> ( The output array ISPLIT from DSTEBZ is expected here. )
114 *> Z is COMPLEX*16 array, dimension (LDZ, M)
115 *> The computed eigenvectors. The eigenvector associated
116 *> with the eigenvalue W(i) is stored in the i-th column of
117 *> Z. Any vector which fails to converge is set to its current
118 *> iterate after MAXITS iterations.
119 *> The imaginary parts of the eigenvectors are set to zero.
125 *> The leading dimension of the array Z. LDZ >= max(1,N).
130 *> WORK is DOUBLE PRECISION array, dimension (5*N)
135 *> IWORK is INTEGER array, dimension (N)
140 *> IFAIL is INTEGER array, dimension (M)
141 *> On normal exit, all elements of IFAIL are zero.
142 *> If one or more eigenvectors fail to converge after
143 *> MAXITS iterations, then their indices are stored in
150 *> = 0: successful exit
151 *> < 0: if INFO = -i, the i-th argument had an illegal value
152 *> > 0: if INFO = i, then i eigenvectors failed to converge
153 *> in MAXITS iterations. Their indices are stored in
157 *> \par Internal Parameters:
158 * =========================
161 *> MAXITS INTEGER, default = 5
162 *> The maximum number of iterations performed.
164 *> EXTRA INTEGER, default = 2
165 *> The number of iterations performed after norm growth
166 *> criterion is satisfied, should be at least 1.
172 *> \author Univ. of Tennessee
173 *> \author Univ. of California Berkeley
174 *> \author Univ. of Colorado Denver
177 *> \date November 2015
179 *> \ingroup complex16OTHERcomputational
181 * =====================================================================
182 SUBROUTINE ZSTEIN( N, D, E, M, W, IBLOCK, ISPLIT, Z, LDZ, WORK,
183 $ IWORK, IFAIL, INFO )
185 * -- LAPACK computational routine (version 3.6.0) --
186 * -- LAPACK is a software package provided by Univ. of Tennessee, --
187 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
190 * .. Scalar Arguments ..
191 INTEGER INFO, LDZ, M, N
193 * .. Array Arguments ..
194 INTEGER IBLOCK( * ), IFAIL( * ), ISPLIT( * ),
196 DOUBLE PRECISION D( * ), E( * ), W( * ), WORK( * )
197 COMPLEX*16 Z( LDZ, * )
200 * =====================================================================
203 COMPLEX*16 CZERO, CONE
204 PARAMETER ( CZERO = ( 0.0D+0, 0.0D+0 ),
205 $ CONE = ( 1.0D+0, 0.0D+0 ) )
206 DOUBLE PRECISION ZERO, ONE, TEN, ODM3, ODM1
207 PARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0, TEN = 1.0D+1,
208 $ ODM3 = 1.0D-3, ODM1 = 1.0D-1 )
209 INTEGER MAXITS, EXTRA
210 PARAMETER ( MAXITS = 5, EXTRA = 2 )
212 * .. Local Scalars ..
213 INTEGER B1, BLKSIZ, BN, GPIND, I, IINFO, INDRV1,
214 $ INDRV2, INDRV3, INDRV4, INDRV5, ITS, J, J1,
215 $ JBLK, JMAX, JR, NBLK, NRMCHK
216 DOUBLE PRECISION DTPCRT, EPS, EPS1, NRM, ONENRM, ORTOL, PERTOL,
217 $ SCL, SEP, TOL, XJ, XJM, ZTR
222 * .. External Functions ..
224 DOUBLE PRECISION DASUM, DLAMCH, DNRM2
225 EXTERNAL IDAMAX, DASUM, DLAMCH, DNRM2
227 * .. External Subroutines ..
228 EXTERNAL DCOPY, DLAGTF, DLAGTS, DLARNV, DSCAL, XERBLA
230 * .. Intrinsic Functions ..
231 INTRINSIC ABS, DBLE, DCMPLX, MAX, SQRT
233 * .. Executable Statements ..
235 * Test the input parameters.
244 ELSE IF( M.LT.0 .OR. M.GT.N ) THEN
246 ELSE IF( LDZ.LT.MAX( 1, N ) ) THEN
250 IF( IBLOCK( J ).LT.IBLOCK( J-1 ) ) THEN
254 IF( IBLOCK( J ).EQ.IBLOCK( J-1 ) .AND. W( J ).LT.W( J-1 ) )
264 CALL XERBLA( 'ZSTEIN', -INFO )
268 * Quick return if possible
270 IF( N.EQ.0 .OR. M.EQ.0 ) THEN
272 ELSE IF( N.EQ.1 ) THEN
277 * Get machine constants.
279 EPS = DLAMCH( 'Precision' )
281 * Initialize seed for random number generator DLARNV.
287 * Initialize pointers.
295 * Compute eigenvectors of matrix blocks.
298 DO 180 NBLK = 1, IBLOCK( M )
300 * Find starting and ending indices of block nblk.
305 B1 = ISPLIT( NBLK-1 ) + 1
313 * Compute reorthogonalization criterion and stopping criterion.
315 ONENRM = ABS( D( B1 ) ) + ABS( E( B1 ) )
316 ONENRM = MAX( ONENRM, ABS( D( BN ) )+ABS( E( BN-1 ) ) )
317 DO 50 I = B1 + 1, BN - 1
318 ONENRM = MAX( ONENRM, ABS( D( I ) )+ABS( E( I-1 ) )+
323 DTPCRT = SQRT( ODM1 / BLKSIZ )
325 * Loop through eigenvalues of block nblk.
330 IF( IBLOCK( J ).NE.NBLK ) THEN
337 * Skip all the work if the block size is one.
339 IF( BLKSIZ.EQ.1 ) THEN
340 WORK( INDRV1+1 ) = ONE
344 * If eigenvalues j and j-1 are too close, add a relatively
345 * small perturbation.
358 * Get random starting vector.
360 CALL DLARNV( 2, ISEED, BLKSIZ, WORK( INDRV1+1 ) )
362 * Copy the matrix T so it won't be destroyed in factorization.
364 CALL DCOPY( BLKSIZ, D( B1 ), 1, WORK( INDRV4+1 ), 1 )
365 CALL DCOPY( BLKSIZ-1, E( B1 ), 1, WORK( INDRV2+2 ), 1 )
366 CALL DCOPY( BLKSIZ-1, E( B1 ), 1, WORK( INDRV3+1 ), 1 )
368 * Compute LU factors with partial pivoting ( PT = LU )
371 CALL DLAGTF( BLKSIZ, WORK( INDRV4+1 ), XJ, WORK( INDRV2+2 ),
372 $ WORK( INDRV3+1 ), TOL, WORK( INDRV5+1 ), IWORK,
375 * Update iteration count.
382 * Normalize and scale the righthand side vector Pb.
384 JMAX = IDAMAX( BLKSIZ, WORK( INDRV1+1 ), 1 )
385 SCL = BLKSIZ*ONENRM*MAX( EPS,
386 $ ABS( WORK( INDRV4+BLKSIZ ) ) ) /
387 $ ABS( WORK( INDRV1+JMAX ) )
388 CALL DSCAL( BLKSIZ, SCL, WORK( INDRV1+1 ), 1 )
390 * Solve the system LU = Pb.
392 CALL DLAGTS( -1, BLKSIZ, WORK( INDRV4+1 ), WORK( INDRV2+2 ),
393 $ WORK( INDRV3+1 ), WORK( INDRV5+1 ), IWORK,
394 $ WORK( INDRV1+1 ), TOL, IINFO )
396 * Reorthogonalize by modified Gram-Schmidt if eigenvalues are
401 IF( ABS( XJ-XJM ).GT.ORTOL )
403 IF( GPIND.NE.J ) THEN
404 DO 100 I = GPIND, J - 1
407 ZTR = ZTR + WORK( INDRV1+JR )*
408 $ DBLE( Z( B1-1+JR, I ) )
411 WORK( INDRV1+JR ) = WORK( INDRV1+JR ) -
412 $ ZTR*DBLE( Z( B1-1+JR, I ) )
417 * Check the infinity norm of the iterate.
420 JMAX = IDAMAX( BLKSIZ, WORK( INDRV1+1 ), 1 )
421 NRM = ABS( WORK( INDRV1+JMAX ) )
423 * Continue for additional iterations after norm reaches
424 * stopping criterion.
429 IF( NRMCHK.LT.EXTRA+1 )
434 * If stopping criterion was not satisfied, update info and
435 * store eigenvector number in array ifail.
441 * Accept iterate as jth eigenvector.
444 SCL = ONE / DNRM2( BLKSIZ, WORK( INDRV1+1 ), 1 )
445 JMAX = IDAMAX( BLKSIZ, WORK( INDRV1+1 ), 1 )
446 IF( WORK( INDRV1+JMAX ).LT.ZERO )
448 CALL DSCAL( BLKSIZ, SCL, WORK( INDRV1+1 ), 1 )
454 Z( B1+I-1, J ) = DCMPLX( WORK( INDRV1+I ), ZERO )
457 * Save the shift to check eigenvalue spacing at next