3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
9 *> Download SSTEIN + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/sstein.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/sstein.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/sstein.f">
21 * SUBROUTINE SSTEIN( 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 * REAL D( * ), E( * ), W( * ), WORK( * ), Z( LDZ, * )
39 *> SSTEIN computes the eigenvectors of a real symmetric tridiagonal
40 *> matrix T corresponding to specified eigenvalues, using inverse
43 *> The maximum number of iterations allowed for each eigenvector is
44 *> specified by an internal parameter MAXITS (currently set to 5).
53 *> The order of the matrix. N >= 0.
58 *> D is REAL array, dimension (N)
59 *> The n diagonal elements of the tridiagonal matrix T.
64 *> E is REAL array, dimension (N-1)
65 *> The (n-1) subdiagonal elements of the tridiagonal matrix
66 *> T, in elements 1 to N-1.
72 *> The number of eigenvectors to be found. 0 <= M <= N.
77 *> W is REAL array, dimension (N)
78 *> The first M elements of W contain the eigenvalues for
79 *> which eigenvectors are to be computed. The eigenvalues
80 *> should be grouped by split-off block and ordered from
81 *> smallest to largest within the block. ( The output array
82 *> W from SSTEBZ with ORDER = 'B' is expected here. )
87 *> IBLOCK is INTEGER array, dimension (N)
88 *> The submatrix indices associated with the corresponding
89 *> eigenvalues in W; IBLOCK(i)=1 if eigenvalue W(i) belongs to
90 *> the first submatrix from the top, =2 if W(i) belongs to
91 *> the second submatrix, etc. ( The output array IBLOCK
92 *> from SSTEBZ is expected here. )
97 *> ISPLIT is INTEGER array, dimension (N)
98 *> The splitting points, at which T breaks up into submatrices.
99 *> The first submatrix consists of rows/columns 1 to
100 *> ISPLIT( 1 ), the second of rows/columns ISPLIT( 1 )+1
101 *> through ISPLIT( 2 ), etc.
102 *> ( The output array ISPLIT from SSTEBZ is expected here. )
107 *> Z is REAL array, dimension (LDZ, M)
108 *> The computed eigenvectors. The eigenvector associated
109 *> with the eigenvalue W(i) is stored in the i-th column of
110 *> Z. Any vector which fails to converge is set to its current
111 *> iterate after MAXITS iterations.
117 *> The leading dimension of the array Z. LDZ >= max(1,N).
122 *> WORK is REAL array, dimension (5*N)
127 *> IWORK is INTEGER array, dimension (N)
132 *> IFAIL is INTEGER array, dimension (M)
133 *> On normal exit, all elements of IFAIL are zero.
134 *> If one or more eigenvectors fail to converge after
135 *> MAXITS iterations, then their indices are stored in
142 *> = 0: successful exit.
143 *> < 0: if INFO = -i, the i-th argument had an illegal value
144 *> > 0: if INFO = i, then i eigenvectors failed to converge
145 *> in MAXITS iterations. Their indices are stored in
149 *> \par Internal Parameters:
150 * =========================
153 *> MAXITS INTEGER, default = 5
154 *> The maximum number of iterations performed.
156 *> EXTRA INTEGER, default = 2
157 *> The number of iterations performed after norm growth
158 *> criterion is satisfied, should be at least 1.
164 *> \author Univ. of Tennessee
165 *> \author Univ. of California Berkeley
166 *> \author Univ. of Colorado Denver
169 *> \date November 2015
171 *> \ingroup realOTHERcomputational
173 * =====================================================================
174 SUBROUTINE SSTEIN( N, D, E, M, W, IBLOCK, ISPLIT, Z, LDZ, WORK,
175 $ IWORK, IFAIL, INFO )
177 * -- LAPACK computational routine (version 3.6.0) --
178 * -- LAPACK is a software package provided by Univ. of Tennessee, --
179 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
182 * .. Scalar Arguments ..
183 INTEGER INFO, LDZ, M, N
185 * .. Array Arguments ..
186 INTEGER IBLOCK( * ), IFAIL( * ), ISPLIT( * ),
188 REAL D( * ), E( * ), W( * ), WORK( * ), Z( LDZ, * )
191 * =====================================================================
194 REAL ZERO, ONE, TEN, ODM3, ODM1
195 PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0, TEN = 1.0E+1,
196 $ ODM3 = 1.0E-3, ODM1 = 1.0E-1 )
197 INTEGER MAXITS, EXTRA
198 PARAMETER ( MAXITS = 5, EXTRA = 2 )
200 * .. Local Scalars ..
201 INTEGER B1, BLKSIZ, BN, GPIND, I, IINFO, INDRV1,
202 $ INDRV2, INDRV3, INDRV4, INDRV5, ITS, J, J1,
203 $ JBLK, JMAX, NBLK, NRMCHK
204 REAL CTR, EPS, EPS1, NRM, ONENRM, ORTOL, PERTOL,
205 $ SCL, SEP, STPCRT, TOL, XJ, XJM
210 * .. External Functions ..
212 REAL SDOT, SLAMCH, SNRM2
213 EXTERNAL ISAMAX, SDOT, SLAMCH, SNRM2
215 * .. External Subroutines ..
216 EXTERNAL SAXPY, SCOPY, SLAGTF, SLAGTS, SLARNV, SSCAL,
219 * .. Intrinsic Functions ..
220 INTRINSIC ABS, MAX, SQRT
222 * .. Executable Statements ..
224 * Test the input parameters.
233 ELSE IF( M.LT.0 .OR. M.GT.N ) THEN
235 ELSE IF( LDZ.LT.MAX( 1, N ) ) THEN
239 IF( IBLOCK( J ).LT.IBLOCK( J-1 ) ) THEN
243 IF( IBLOCK( J ).EQ.IBLOCK( J-1 ) .AND. W( J ).LT.W( J-1 ) )
253 CALL XERBLA( 'SSTEIN', -INFO )
257 * Quick return if possible
259 IF( N.EQ.0 .OR. M.EQ.0 ) THEN
261 ELSE IF( N.EQ.1 ) THEN
266 * Get machine constants.
268 EPS = SLAMCH( 'Precision' )
270 * Initialize seed for random number generator SLARNV.
276 * Initialize pointers.
284 * Compute eigenvectors of matrix blocks.
287 DO 160 NBLK = 1, IBLOCK( M )
289 * Find starting and ending indices of block nblk.
294 B1 = ISPLIT( NBLK-1 ) + 1
302 * Compute reorthogonalization criterion and stopping criterion.
304 ONENRM = ABS( D( B1 ) ) + ABS( E( B1 ) )
305 ONENRM = MAX( ONENRM, ABS( D( BN ) )+ABS( E( BN-1 ) ) )
306 DO 50 I = B1 + 1, BN - 1
307 ONENRM = MAX( ONENRM, ABS( D( I ) )+ABS( E( I-1 ) )+
312 STPCRT = SQRT( ODM1 / BLKSIZ )
314 * Loop through eigenvalues of block nblk.
319 IF( IBLOCK( J ).NE.NBLK ) THEN
326 * Skip all the work if the block size is one.
328 IF( BLKSIZ.EQ.1 ) THEN
329 WORK( INDRV1+1 ) = ONE
333 * If eigenvalues j and j-1 are too close, add a relatively
334 * small perturbation.
347 * Get random starting vector.
349 CALL SLARNV( 2, ISEED, BLKSIZ, WORK( INDRV1+1 ) )
351 * Copy the matrix T so it won't be destroyed in factorization.
353 CALL SCOPY( BLKSIZ, D( B1 ), 1, WORK( INDRV4+1 ), 1 )
354 CALL SCOPY( BLKSIZ-1, E( B1 ), 1, WORK( INDRV2+2 ), 1 )
355 CALL SCOPY( BLKSIZ-1, E( B1 ), 1, WORK( INDRV3+1 ), 1 )
357 * Compute LU factors with partial pivoting ( PT = LU )
360 CALL SLAGTF( BLKSIZ, WORK( INDRV4+1 ), XJ, WORK( INDRV2+2 ),
361 $ WORK( INDRV3+1 ), TOL, WORK( INDRV5+1 ), IWORK,
364 * Update iteration count.
371 * Normalize and scale the righthand side vector Pb.
373 JMAX = ISAMAX( BLKSIZ, WORK( INDRV1+1 ), 1 )
374 SCL = BLKSIZ*ONENRM*MAX( EPS,
375 $ ABS( WORK( INDRV4+BLKSIZ ) ) ) /
376 $ ABS( WORK( INDRV1+JMAX ) )
377 CALL SSCAL( BLKSIZ, SCL, WORK( INDRV1+1 ), 1 )
379 * Solve the system LU = Pb.
381 CALL SLAGTS( -1, BLKSIZ, WORK( INDRV4+1 ), WORK( INDRV2+2 ),
382 $ WORK( INDRV3+1 ), WORK( INDRV5+1 ), IWORK,
383 $ WORK( INDRV1+1 ), TOL, IINFO )
385 * Reorthogonalize by modified Gram-Schmidt if eigenvalues are
390 IF( ABS( XJ-XJM ).GT.ORTOL )
392 IF( GPIND.NE.J ) THEN
393 DO 80 I = GPIND, J - 1
394 CTR = -SDOT( BLKSIZ, WORK( INDRV1+1 ), 1, Z( B1, I ),
396 CALL SAXPY( BLKSIZ, CTR, Z( B1, I ), 1,
397 $ WORK( INDRV1+1 ), 1 )
401 * Check the infinity norm of the iterate.
404 JMAX = ISAMAX( BLKSIZ, WORK( INDRV1+1 ), 1 )
405 NRM = ABS( WORK( INDRV1+JMAX ) )
407 * Continue for additional iterations after norm reaches
408 * stopping criterion.
413 IF( NRMCHK.LT.EXTRA+1 )
418 * If stopping criterion was not satisfied, update info and
419 * store eigenvector number in array ifail.
425 * Accept iterate as jth eigenvector.
428 SCL = ONE / SNRM2( BLKSIZ, WORK( INDRV1+1 ), 1 )
429 JMAX = ISAMAX( BLKSIZ, WORK( INDRV1+1 ), 1 )
430 IF( WORK( INDRV1+JMAX ).LT.ZERO )
432 CALL SSCAL( BLKSIZ, SCL, WORK( INDRV1+1 ), 1 )
438 Z( B1+I-1, J ) = WORK( INDRV1+I )
441 * Save the shift to check eigenvalue spacing at next