LAPACK  3.4.2
LAPACK: Linear Algebra PACKage
 All Files Functions Groups
dstein.f
Go to the documentation of this file.
1 *> \brief \b DSTEIN
2 *
3 * =========== DOCUMENTATION ===========
4 *
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
7 *
8 *> \htmlonly
9 *> Download DSTEIN + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dstein.f">
11 *> [TGZ]</a>
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dstein.f">
13 *> [ZIP]</a>
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dstein.f">
15 *> [TXT]</a>
16 *> \endhtmlonly
17 *
18 * Definition:
19 * ===========
20 *
21 * SUBROUTINE DSTEIN( N, D, E, M, W, IBLOCK, ISPLIT, Z, LDZ, WORK,
22 * IWORK, IFAIL, INFO )
23 *
24 * .. Scalar Arguments ..
25 * INTEGER INFO, LDZ, M, N
26 * ..
27 * .. Array Arguments ..
28 * INTEGER IBLOCK( * ), IFAIL( * ), ISPLIT( * ),
29 * $ IWORK( * )
30 * DOUBLE PRECISION D( * ), E( * ), W( * ), WORK( * ), Z( LDZ, * )
31 * ..
32 *
33 *
34 *> \par Purpose:
35 * =============
36 *>
37 *> \verbatim
38 *>
39 *> DSTEIN computes the eigenvectors of a real symmetric tridiagonal
40 *> matrix T corresponding to specified eigenvalues, using inverse
41 *> iteration.
42 *>
43 *> The maximum number of iterations allowed for each eigenvector is
44 *> specified by an internal parameter MAXITS (currently set to 5).
45 *> \endverbatim
46 *
47 * Arguments:
48 * ==========
49 *
50 *> \param[in] N
51 *> \verbatim
52 *> N is INTEGER
53 *> The order of the matrix. N >= 0.
54 *> \endverbatim
55 *>
56 *> \param[in] D
57 *> \verbatim
58 *> D is DOUBLE PRECISION array, dimension (N)
59 *> The n diagonal elements of the tridiagonal matrix T.
60 *> \endverbatim
61 *>
62 *> \param[in] E
63 *> \verbatim
64 *> E is DOUBLE PRECISION array, dimension (N-1)
65 *> The (n-1) subdiagonal elements of the tridiagonal matrix
66 *> T, in elements 1 to N-1.
67 *> \endverbatim
68 *>
69 *> \param[in] M
70 *> \verbatim
71 *> M is INTEGER
72 *> The number of eigenvectors to be found. 0 <= M <= N.
73 *> \endverbatim
74 *>
75 *> \param[in] W
76 *> \verbatim
77 *> W is DOUBLE PRECISION 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 DSTEBZ with ORDER = 'B' is expected here. )
83 *> \endverbatim
84 *>
85 *> \param[in] IBLOCK
86 *> \verbatim
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 DSTEBZ is expected here. )
93 *> \endverbatim
94 *>
95 *> \param[in] ISPLIT
96 *> \verbatim
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 DSTEBZ is expected here. )
103 *> \endverbatim
104 *>
105 *> \param[out] Z
106 *> \verbatim
107 *> Z is DOUBLE PRECISION 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.
112 *> \endverbatim
113 *>
114 *> \param[in] LDZ
115 *> \verbatim
116 *> LDZ is INTEGER
117 *> The leading dimension of the array Z. LDZ >= max(1,N).
118 *> \endverbatim
119 *>
120 *> \param[out] WORK
121 *> \verbatim
122 *> WORK is DOUBLE PRECISION array, dimension (5*N)
123 *> \endverbatim
124 *>
125 *> \param[out] IWORK
126 *> \verbatim
127 *> IWORK is INTEGER array, dimension (N)
128 *> \endverbatim
129 *>
130 *> \param[out] IFAIL
131 *> \verbatim
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
136 *> array IFAIL.
137 *> \endverbatim
138 *>
139 *> \param[out] INFO
140 *> \verbatim
141 *> INFO is INTEGER
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
146 *> array IFAIL.
147 *> \endverbatim
148 *
149 *> \par Internal Parameters:
150 * =========================
151 *>
152 *> \verbatim
153 *> MAXITS INTEGER, default = 5
154 *> The maximum number of iterations performed.
155 *>
156 *> EXTRA INTEGER, default = 2
157 *> The number of iterations performed after norm growth
158 *> criterion is satisfied, should be at least 1.
159 *> \endverbatim
160 *
161 * Authors:
162 * ========
163 *
164 *> \author Univ. of Tennessee
165 *> \author Univ. of California Berkeley
166 *> \author Univ. of Colorado Denver
167 *> \author NAG Ltd.
168 *
169 *> \date November 2011
170 *
171 *> \ingroup doubleOTHERcomputational
172 *
173 * =====================================================================
174  SUBROUTINE dstein( N, D, E, M, W, IBLOCK, ISPLIT, Z, LDZ, WORK,
175  $ iwork, ifail, info )
176 *
177 * -- LAPACK computational routine (version 3.4.0) --
178 * -- LAPACK is a software package provided by Univ. of Tennessee, --
179 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
180 * November 2011
181 *
182 * .. Scalar Arguments ..
183  INTEGER info, ldz, m, n
184 * ..
185 * .. Array Arguments ..
186  INTEGER iblock( * ), ifail( * ), isplit( * ),
187  $ iwork( * )
188  DOUBLE PRECISION d( * ), e( * ), w( * ), work( * ), z( ldz, * )
189 * ..
190 *
191 * =====================================================================
192 *
193 * .. Parameters ..
194  DOUBLE PRECISION zero, one, ten, odm3, odm1
195  parameter( zero = 0.0d+0, one = 1.0d+0, ten = 1.0d+1,
196  $ odm3 = 1.0d-3, odm1 = 1.0d-1 )
197  INTEGER maxits, extra
198  parameter( maxits = 5, extra = 2 )
199 * ..
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  DOUBLE PRECISION dtpcrt, eps, eps1, nrm, onenrm, ortol, pertol,
205  $ scl, sep, tol, xj, xjm, ztr
206 * ..
207 * .. Local Arrays ..
208  INTEGER iseed( 4 )
209 * ..
210 * .. External Functions ..
211  INTEGER idamax
212  DOUBLE PRECISION dasum, ddot, dlamch, dnrm2
213  EXTERNAL idamax, dasum, ddot, dlamch, dnrm2
214 * ..
215 * .. External Subroutines ..
216  EXTERNAL daxpy, dcopy, dlagtf, dlagts, dlarnv, dscal,
217  $ xerbla
218 * ..
219 * .. Intrinsic Functions ..
220  INTRINSIC abs, max, sqrt
221 * ..
222 * .. Executable Statements ..
223 *
224 * Test the input parameters.
225 *
226  info = 0
227  DO 10 i = 1, m
228  ifail( i ) = 0
229  10 continue
230 *
231  IF( n.LT.0 ) THEN
232  info = -1
233  ELSE IF( m.LT.0 .OR. m.GT.n ) THEN
234  info = -4
235  ELSE IF( ldz.LT.max( 1, n ) ) THEN
236  info = -9
237  ELSE
238  DO 20 j = 2, m
239  IF( iblock( j ).LT.iblock( j-1 ) ) THEN
240  info = -6
241  go to 30
242  END IF
243  IF( iblock( j ).EQ.iblock( j-1 ) .AND. w( j ).LT.w( j-1 ) )
244  $ THEN
245  info = -5
246  go to 30
247  END IF
248  20 continue
249  30 continue
250  END IF
251 *
252  IF( info.NE.0 ) THEN
253  CALL xerbla( 'DSTEIN', -info )
254  return
255  END IF
256 *
257 * Quick return if possible
258 *
259  IF( n.EQ.0 .OR. m.EQ.0 ) THEN
260  return
261  ELSE IF( n.EQ.1 ) THEN
262  z( 1, 1 ) = one
263  return
264  END IF
265 *
266 * Get machine constants.
267 *
268  eps = dlamch( 'Precision' )
269 *
270 * Initialize seed for random number generator DLARNV.
271 *
272  DO 40 i = 1, 4
273  iseed( i ) = 1
274  40 continue
275 *
276 * Initialize pointers.
277 *
278  indrv1 = 0
279  indrv2 = indrv1 + n
280  indrv3 = indrv2 + n
281  indrv4 = indrv3 + n
282  indrv5 = indrv4 + n
283 *
284 * Compute eigenvectors of matrix blocks.
285 *
286  j1 = 1
287  DO 160 nblk = 1, iblock( m )
288 *
289 * Find starting and ending indices of block nblk.
290 *
291  IF( nblk.EQ.1 ) THEN
292  b1 = 1
293  ELSE
294  b1 = isplit( nblk-1 ) + 1
295  END IF
296  bn = isplit( nblk )
297  blksiz = bn - b1 + 1
298  IF( blksiz.EQ.1 )
299  $ go to 60
300  gpind = b1
301 *
302 * Compute reorthogonalization criterion and stopping criterion.
303 *
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 ) )+
308  $ abs( e( i ) ) )
309  50 continue
310  ortol = odm3*onenrm
311 *
312  dtpcrt = sqrt( odm1 / blksiz )
313 *
314 * Loop through eigenvalues of block nblk.
315 *
316  60 continue
317  jblk = 0
318  DO 150 j = j1, m
319  IF( iblock( j ).NE.nblk ) THEN
320  j1 = j
321  go to 160
322  END IF
323  jblk = jblk + 1
324  xj = w( j )
325 *
326 * Skip all the work if the block size is one.
327 *
328  IF( blksiz.EQ.1 ) THEN
329  work( indrv1+1 ) = one
330  go to 120
331  END IF
332 *
333 * If eigenvalues j and j-1 are too close, add a relatively
334 * small perturbation.
335 *
336  IF( jblk.GT.1 ) THEN
337  eps1 = abs( eps*xj )
338  pertol = ten*eps1
339  sep = xj - xjm
340  IF( sep.LT.pertol )
341  $ xj = xjm + pertol
342  END IF
343 *
344  its = 0
345  nrmchk = 0
346 *
347 * Get random starting vector.
348 *
349  CALL dlarnv( 2, iseed, blksiz, work( indrv1+1 ) )
350 *
351 * Copy the matrix T so it won't be destroyed in factorization.
352 *
353  CALL dcopy( blksiz, d( b1 ), 1, work( indrv4+1 ), 1 )
354  CALL dcopy( blksiz-1, e( b1 ), 1, work( indrv2+2 ), 1 )
355  CALL dcopy( blksiz-1, e( b1 ), 1, work( indrv3+1 ), 1 )
356 *
357 * Compute LU factors with partial pivoting ( PT = LU )
358 *
359  tol = zero
360  CALL dlagtf( blksiz, work( indrv4+1 ), xj, work( indrv2+2 ),
361  $ work( indrv3+1 ), tol, work( indrv5+1 ), iwork,
362  $ iinfo )
363 *
364 * Update iteration count.
365 *
366  70 continue
367  its = its + 1
368  IF( its.GT.maxits )
369  $ go to 100
370 *
371 * Normalize and scale the righthand side vector Pb.
372 *
373  scl = blksiz*onenrm*max( eps,
374  $ abs( work( indrv4+blksiz ) ) ) /
375  $ dasum( blksiz, work( indrv1+1 ), 1 )
376  CALL dscal( blksiz, scl, work( indrv1+1 ), 1 )
377 *
378 * Solve the system LU = Pb.
379 *
380  CALL dlagts( -1, blksiz, work( indrv4+1 ), work( indrv2+2 ),
381  $ work( indrv3+1 ), work( indrv5+1 ), iwork,
382  $ work( indrv1+1 ), tol, iinfo )
383 *
384 * Reorthogonalize by modified Gram-Schmidt if eigenvalues are
385 * close enough.
386 *
387  IF( jblk.EQ.1 )
388  $ go to 90
389  IF( abs( xj-xjm ).GT.ortol )
390  $ gpind = j
391  IF( gpind.NE.j ) THEN
392  DO 80 i = gpind, j - 1
393  ztr = -ddot( blksiz, work( indrv1+1 ), 1, z( b1, i ),
394  $ 1 )
395  CALL daxpy( blksiz, ztr, z( b1, i ), 1,
396  $ work( indrv1+1 ), 1 )
397  80 continue
398  END IF
399 *
400 * Check the infinity norm of the iterate.
401 *
402  90 continue
403  jmax = idamax( blksiz, work( indrv1+1 ), 1 )
404  nrm = abs( work( indrv1+jmax ) )
405 *
406 * Continue for additional iterations after norm reaches
407 * stopping criterion.
408 *
409  IF( nrm.LT.dtpcrt )
410  $ go to 70
411  nrmchk = nrmchk + 1
412  IF( nrmchk.LT.extra+1 )
413  $ go to 70
414 *
415  go to 110
416 *
417 * If stopping criterion was not satisfied, update info and
418 * store eigenvector number in array ifail.
419 *
420  100 continue
421  info = info + 1
422  ifail( info ) = j
423 *
424 * Accept iterate as jth eigenvector.
425 *
426  110 continue
427  scl = one / dnrm2( blksiz, work( indrv1+1 ), 1 )
428  jmax = idamax( blksiz, work( indrv1+1 ), 1 )
429  IF( work( indrv1+jmax ).LT.zero )
430  $ scl = -scl
431  CALL dscal( blksiz, scl, work( indrv1+1 ), 1 )
432  120 continue
433  DO 130 i = 1, n
434  z( i, j ) = zero
435  130 continue
436  DO 140 i = 1, blksiz
437  z( b1+i-1, j ) = work( indrv1+i )
438  140 continue
439 *
440 * Save the shift to check eigenvalue spacing at next
441 * iteration.
442 *
443  xjm = xj
444 *
445  150 continue
446  160 continue
447 *
448  return
449 *
450 * End of DSTEIN
451 *
452  END