LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
ssyevr_2stage.f
Go to the documentation of this file.
1*> \brief <b> SSYEVR_2STAGE computes the eigenvalues and, optionally, the left and/or right eigenvectors for SY matrices</b>
2*
3* @generated from dsyevr_2stage.f, fortran d -> s, Sat Nov 5 23:50:10 2016
4*
5* =========== DOCUMENTATION ===========
6*
7* Online html documentation available at
8* http://www.netlib.org/lapack/explore-html/
9*
10*> Download SSYEVR_2STAGE + dependencies
11*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/ssyevr_2stage.f">
12*> [TGZ]</a>
13*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/ssyevr_2stage.f">
14*> [ZIP]</a>
15*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/ssyevr_2stage.f">
16*> [TXT]</a>
17*
18* Definition:
19* ===========
20*
21* SUBROUTINE SSYEVR_2STAGE( JOBZ, RANGE, UPLO, N, A, LDA, VL, VU,
22* IL, IU, ABSTOL, M, W, Z, LDZ, ISUPPZ, WORK,
23* LWORK, IWORK, LIWORK, INFO )
24*
25* IMPLICIT NONE
26*
27* .. Scalar Arguments ..
28* CHARACTER JOBZ, RANGE, UPLO
29* INTEGER IL, INFO, IU, LDA, LDZ, LIWORK, LWORK, M, N
30* REAL ABSTOL, VL, VU
31* ..
32* .. Array Arguments ..
33* INTEGER ISUPPZ( * ), IWORK( * )
34* REAL A( LDA, * ), W( * ), WORK( * ), Z( LDZ, * )
35* ..
36*
37*
38*> \par Purpose:
39* =============
40*>
41*> \verbatim
42*>
43*> SSYEVR_2STAGE computes selected eigenvalues and, optionally, eigenvectors
44*> of a real symmetric matrix A using the 2stage technique for
45*> the reduction to tridiagonal. Eigenvalues and eigenvectors can be
46*> selected by specifying either a range of values or a range of
47*> indices for the desired eigenvalues.
48*>
49*> SSYEVR_2STAGE first reduces the matrix A to tridiagonal form T with a call
50*> to SSYTRD. Then, whenever possible, SSYEVR_2STAGE calls SSTEMR to compute
51*> the eigenspectrum using Relatively Robust Representations. SSTEMR
52*> computes eigenvalues by the dqds algorithm, while orthogonal
53*> eigenvectors are computed from various "good" L D L^T representations
54*> (also known as Relatively Robust Representations). Gram-Schmidt
55*> orthogonalization is avoided as far as possible. More specifically,
56*> the various steps of the algorithm are as follows.
57*>
58*> For each unreduced block (submatrix) of T,
59*> (a) Compute T - sigma I = L D L^T, so that L and D
60*> define all the wanted eigenvalues to high relative accuracy.
61*> This means that small relative changes in the entries of D and L
62*> cause only small relative changes in the eigenvalues and
63*> eigenvectors. The standard (unfactored) representation of the
64*> tridiagonal matrix T does not have this property in general.
65*> (b) Compute the eigenvalues to suitable accuracy.
66*> If the eigenvectors are desired, the algorithm attains full
67*> accuracy of the computed eigenvalues only right before
68*> the corresponding vectors have to be computed, see steps c) and d).
69*> (c) For each cluster of close eigenvalues, select a new
70*> shift close to the cluster, find a new factorization, and refine
71*> the shifted eigenvalues to suitable accuracy.
72*> (d) For each eigenvalue with a large enough relative separation compute
73*> the corresponding eigenvector by forming a rank revealing twisted
74*> factorization. Go back to (c) for any clusters that remain.
75*>
76*> The desired accuracy of the output can be specified by the input
77*> parameter ABSTOL.
78*>
79*> For more details, see SSTEMR's documentation and:
80*> - Inderjit S. Dhillon and Beresford N. Parlett: "Multiple representations
81*> to compute orthogonal eigenvectors of symmetric tridiagonal matrices,"
82*> Linear Algebra and its Applications, 387(1), pp. 1-28, August 2004.
83*> - Inderjit Dhillon and Beresford Parlett: "Orthogonal Eigenvectors and
84*> Relative Gaps," SIAM Journal on Matrix Analysis and Applications, Vol. 25,
85*> 2004. Also LAPACK Working Note 154.
86*> - Inderjit Dhillon: "A new O(n^2) algorithm for the symmetric
87*> tridiagonal eigenvalue/eigenvector problem",
88*> Computer Science Division Technical Report No. UCB/CSD-97-971,
89*> UC Berkeley, May 1997.
90*>
91*>
92*> Note 1 : SSYEVR_2STAGE calls SSTEMR when the full spectrum is requested
93*> on machines which conform to the ieee-754 floating point standard.
94*> SSYEVR_2STAGE calls SSTEBZ and SSTEIN on non-ieee machines and
95*> when partial spectrum requests are made.
96*>
97*> Normal execution of SSTEMR may create NaNs and infinities and
98*> hence may abort due to a floating point exception in environments
99*> which do not handle NaNs and infinities in the ieee standard default
100*> manner.
101*> \endverbatim
102*
103* Arguments:
104* ==========
105*
106*> \param[in] JOBZ
107*> \verbatim
108*> JOBZ is CHARACTER*1
109*> = 'N': Compute eigenvalues only;
110*> = 'V': Compute eigenvalues and eigenvectors.
111*> Not available in this release.
112*> \endverbatim
113*>
114*> \param[in] RANGE
115*> \verbatim
116*> RANGE is CHARACTER*1
117*> = 'A': all eigenvalues will be found.
118*> = 'V': all eigenvalues in the half-open interval (VL,VU]
119*> will be found.
120*> = 'I': the IL-th through IU-th eigenvalues will be found.
121*> For RANGE = 'V' or 'I' and IU - IL < N - 1, SSTEBZ and
122*> SSTEIN are called
123*> \endverbatim
124*>
125*> \param[in] UPLO
126*> \verbatim
127*> UPLO is CHARACTER*1
128*> = 'U': Upper triangle of A is stored;
129*> = 'L': Lower triangle of A is stored.
130*> \endverbatim
131*>
132*> \param[in] N
133*> \verbatim
134*> N is INTEGER
135*> The order of the matrix A. N >= 0.
136*> \endverbatim
137*>
138*> \param[in,out] A
139*> \verbatim
140*> A is REAL array, dimension (LDA, N)
141*> On entry, the symmetric matrix A. If UPLO = 'U', the
142*> leading N-by-N upper triangular part of A contains the
143*> upper triangular part of the matrix A. If UPLO = 'L',
144*> the leading N-by-N lower triangular part of A contains
145*> the lower triangular part of the matrix A.
146*> On exit, the lower triangle (if UPLO='L') or the upper
147*> triangle (if UPLO='U') of A, including the diagonal, is
148*> destroyed.
149*> \endverbatim
150*>
151*> \param[in] LDA
152*> \verbatim
153*> LDA is INTEGER
154*> The leading dimension of the array A. LDA >= max(1,N).
155*> \endverbatim
156*>
157*> \param[in] VL
158*> \verbatim
159*> VL is REAL
160*> If RANGE='V', the lower bound of the interval to
161*> be searched for eigenvalues. VL < VU.
162*> Not referenced if RANGE = 'A' or 'I'.
163*> \endverbatim
164*>
165*> \param[in] VU
166*> \verbatim
167*> VU is REAL
168*> If RANGE='V', the upper bound of the interval to
169*> be searched for eigenvalues. VL < VU.
170*> Not referenced if RANGE = 'A' or 'I'.
171*> \endverbatim
172*>
173*> \param[in] IL
174*> \verbatim
175*> IL is INTEGER
176*> If RANGE='I', the index of the
177*> smallest eigenvalue to be returned.
178*> 1 <= IL <= IU <= N, if N > 0; IL = 1 and IU = 0 if N = 0.
179*> Not referenced if RANGE = 'A' or 'V'.
180*> \endverbatim
181*>
182*> \param[in] IU
183*> \verbatim
184*> IU is INTEGER
185*> If RANGE='I', the index of the
186*> largest eigenvalue to be returned.
187*> 1 <= IL <= IU <= N, if N > 0; IL = 1 and IU = 0 if N = 0.
188*> Not referenced if RANGE = 'A' or 'V'.
189*> \endverbatim
190*>
191*> \param[in] ABSTOL
192*> \verbatim
193*> ABSTOL is REAL
194*> The absolute error tolerance for the eigenvalues.
195*> An approximate eigenvalue is accepted as converged
196*> when it is determined to lie in an interval [a,b]
197*> of width less than or equal to
198*>
199*> ABSTOL + EPS * max( |a|,|b| ) ,
200*>
201*> where EPS is the machine precision. If ABSTOL is less than
202*> or equal to zero, then EPS*|T| will be used in its place,
203*> where |T| is the 1-norm of the tridiagonal matrix obtained
204*> by reducing A to tridiagonal form.
205*>
206*> See "Computing Small Singular Values of Bidiagonal Matrices
207*> with Guaranteed High Relative Accuracy," by Demmel and
208*> Kahan, LAPACK Working Note #3.
209*>
210*> If high relative accuracy is important, set ABSTOL to
211*> SLAMCH( 'Safe minimum' ). Doing so will guarantee that
212*> eigenvalues are computed to high relative accuracy when
213*> possible in future releases. The current code does not
214*> make any guarantees about high relative accuracy, but
215*> future releases will. See J. Barlow and J. Demmel,
216*> "Computing Accurate Eigensystems of Scaled Diagonally
217*> Dominant Matrices", LAPACK Working Note #7, for a discussion
218*> of which matrices define their eigenvalues to high relative
219*> accuracy.
220*> \endverbatim
221*>
222*> \param[out] M
223*> \verbatim
224*> M is INTEGER
225*> The total number of eigenvalues found. 0 <= M <= N.
226*> If RANGE = 'A', M = N, and if RANGE = 'I', M = IU-IL+1.
227*> \endverbatim
228*>
229*> \param[out] W
230*> \verbatim
231*> W is REAL array, dimension (N)
232*> The first M elements contain the selected eigenvalues in
233*> ascending order.
234*> \endverbatim
235*>
236*> \param[out] Z
237*> \verbatim
238*> Z is REAL array, dimension (LDZ, max(1,M))
239*> If JOBZ = 'V', then if INFO = 0, the first M columns of Z
240*> contain the orthonormal eigenvectors of the matrix A
241*> corresponding to the selected eigenvalues, with the i-th
242*> column of Z holding the eigenvector associated with W(i).
243*> If JOBZ = 'N', then Z is not referenced.
244*> Note: the user must ensure that at least max(1,M) columns are
245*> supplied in the array Z; if RANGE = 'V', the exact value of M
246*> is not known in advance and an upper bound must be used.
247*> Supplying N columns is always safe.
248*> \endverbatim
249*>
250*> \param[in] LDZ
251*> \verbatim
252*> LDZ is INTEGER
253*> The leading dimension of the array Z. LDZ >= 1, and if
254*> JOBZ = 'V', LDZ >= max(1,N).
255*> \endverbatim
256*>
257*> \param[out] ISUPPZ
258*> \verbatim
259*> ISUPPZ is INTEGER array, dimension ( 2*max(1,M) )
260*> The support of the eigenvectors in Z, i.e., the indices
261*> indicating the nonzero elements in Z. The i-th eigenvector
262*> is nonzero only in elements ISUPPZ( 2*i-1 ) through
263*> ISUPPZ( 2*i ). This is an output of SSTEMR (tridiagonal
264*> matrix). The support of the eigenvectors of A is typically
265*> 1:N because of the orthogonal transformations applied by SORMTR.
266*> Implemented only for RANGE = 'A' or 'I' and IU - IL = N - 1
267*> \endverbatim
268*>
269*> \param[out] WORK
270*> \verbatim
271*> WORK is REAL array, dimension (MAX(1,LWORK))
272*> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
273*> \endverbatim
274*>
275*> \param[in] LWORK
276*> \verbatim
277*> LWORK is INTEGER
278*> The dimension of the array WORK.
279*> If N <= 1, LWORK must be at least 1.
280*> If JOBZ = 'N' and N > 1, LWORK must be queried.
281*> LWORK = MAX(1, 26*N, dimension) where
282*> dimension = max(stage1,stage2) + (KD+1)*N + 5*N
283*> = N*KD + N*max(KD+1,FACTOPTNB)
284*> + max(2*KD*KD, KD*NTHREADS)
285*> + (KD+1)*N + 5*N
286*> where KD is the blocking size of the reduction,
287*> FACTOPTNB is the blocking used by the QR or LQ
288*> algorithm, usually FACTOPTNB=128 is a good choice
289*> NTHREADS is the number of threads used when
290*> openMP compilation is enabled, otherwise =1.
291*> If JOBZ = 'V' and N > 1, LWORK must be queried. Not yet available
292*>
293*> If LWORK = -1, then a workspace query is assumed; the routine
294*> only calculates the optimal size of the WORK array, returns
295*> this value as the first entry of the WORK array, and no error
296*> message related to LWORK is issued by XERBLA.
297*> \endverbatim
298*>
299*> \param[out] IWORK
300*> \verbatim
301*> IWORK is INTEGER array, dimension (MAX(1,LIWORK))
302*> On exit, if INFO = 0, IWORK(1) returns the optimal LIWORK.
303*> \endverbatim
304*>
305*> \param[in] LIWORK
306*> \verbatim
307*> LIWORK is INTEGER
308*> The dimension of the array IWORK.
309*> If N <= 1, LIWORK >= 1, else LIWORK >= 10*N.
310*>
311*> If LIWORK = -1, then a workspace query is assumed; the
312*> routine only calculates the optimal size of the IWORK array,
313*> returns this value as the first entry of the IWORK array, and
314*> no error message related to LIWORK is issued by XERBLA.
315*> \endverbatim
316*>
317*> \param[out] INFO
318*> \verbatim
319*> INFO is INTEGER
320*> = 0: successful exit
321*> < 0: if INFO = -i, the i-th argument had an illegal value
322*> > 0: Internal error
323*> \endverbatim
324*
325* Authors:
326* ========
327*
328*> \author Univ. of Tennessee
329*> \author Univ. of California Berkeley
330*> \author Univ. of Colorado Denver
331*> \author NAG Ltd.
332*
333*> \ingroup heevr_2stage
334*
335*> \par Contributors:
336* ==================
337*>
338*> Inderjit Dhillon, IBM Almaden, USA \n
339*> Osni Marques, LBNL/NERSC, USA \n
340*> Ken Stanley, Computer Science Division, University of
341*> California at Berkeley, USA \n
342*> Jason Riedy, Computer Science Division, University of
343*> California at Berkeley, USA \n
344*>
345*> \par Further Details:
346* =====================
347*>
348*> \verbatim
349*>
350*> All details about the 2stage techniques are available in:
351*>
352*> Azzam Haidar, Hatem Ltaief, and Jack Dongarra.
353*> Parallel reduction to condensed forms for symmetric eigenvalue problems
354*> using aggregated fine-grained and memory-aware kernels. In Proceedings
355*> of 2011 International Conference for High Performance Computing,
356*> Networking, Storage and Analysis (SC '11), New York, NY, USA,
357*> Article 8 , 11 pages.
358*> http://doi.acm.org/10.1145/2063384.2063394
359*>
360*> A. Haidar, J. Kurzak, P. Luszczek, 2013.
361*> An improved parallel singular value algorithm and its implementation
362*> for multicore hardware, In Proceedings of 2013 International Conference
363*> for High Performance Computing, Networking, Storage and Analysis (SC '13).
364*> Denver, Colorado, USA, 2013.
365*> Article 90, 12 pages.
366*> http://doi.acm.org/10.1145/2503210.2503292
367*>
368*> A. Haidar, R. Solca, S. Tomov, T. Schulthess and J. Dongarra.
369*> A novel hybrid CPU-GPU generalized eigensolver for electronic structure
370*> calculations based on fine-grained memory aware tasks.
371*> International Journal of High Performance Computing Applications.
372*> Volume 28 Issue 2, Pages 196-209, May 2014.
373*> http://hpc.sagepub.com/content/28/2/196
374*>
375*> \endverbatim
376*
377* =====================================================================
378 SUBROUTINE ssyevr_2stage( JOBZ, RANGE, UPLO, N, A, LDA, VL, VU,
379 $ IL, IU, ABSTOL, M, W, Z, LDZ, ISUPPZ, WORK,
380 $ LWORK, IWORK, LIWORK, INFO )
381*
382 IMPLICIT NONE
383*
384* -- LAPACK driver routine --
385* -- LAPACK is a software package provided by Univ. of Tennessee, --
386* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
387*
388* .. Scalar Arguments ..
389 CHARACTER JOBZ, RANGE, UPLO
390 INTEGER IL, INFO, IU, LDA, LDZ, LIWORK, LWORK, M, N
391 REAL ABSTOL, VL, VU
392* ..
393* .. Array Arguments ..
394 INTEGER ISUPPZ( * ), IWORK( * )
395 REAL A( LDA, * ), W( * ), WORK( * ), Z( LDZ, * )
396* ..
397*
398* =====================================================================
399*
400* .. Parameters ..
401 REAL ZERO, ONE, TWO
402 PARAMETER ( ZERO = 0.0e+0, one = 1.0e+0, two = 2.0e+0 )
403* ..
404* .. Local Scalars ..
405 LOGICAL ALLEIG, INDEIG, LOWER, LQUERY, VALEIG, WANTZ,
406 $ TRYRAC, TEST
407 CHARACTER ORDER
408 INTEGER I, IEEEOK, IINFO, IMAX, INDD, INDDD, INDE,
409 $ indee, indibl, indifl, indisp, indiwo, indtau,
410 $ indwk, indwkn, iscale, j, jj, liwmin,
411 $ llwork, llwrkn, lwmin, nsplit,
412 $ lhtrd, lwtrd, kd, ib, indhous
413 REAL ABSTLL, ANRM, BIGNUM, EPS, RMAX, RMIN, SAFMIN,
414 $ SIGMA, SMLNUM, TMP1, VLL, VUU
415* ..
416* .. External Functions ..
417 LOGICAL LSAME
418 INTEGER ILAENV, ILAENV2STAGE
419 REAL SLAMCH, SLANSY, SROUNDUP_LWORK
420 EXTERNAL lsame, slamch, slansy,
421 $ sroundup_lwork, ilaenv,
422 $ ilaenv2stage
423* ..
424* .. External Subroutines ..
425 EXTERNAL scopy, sormtr, sscal, sstebz, sstemr,
426 $ sstein,
428* ..
429* .. Intrinsic Functions ..
430 INTRINSIC max, min, sqrt
431* ..
432* .. Executable Statements ..
433*
434* Test the input parameters.
435*
436 ieeeok = ilaenv( 10, 'SSYEVR', 'N', 1, 2, 3, 4 )
437*
438 lower = lsame( uplo, 'L' )
439 wantz = lsame( jobz, 'V' )
440 alleig = lsame( range, 'A' )
441 valeig = lsame( range, 'V' )
442 indeig = lsame( range, 'I' )
443*
444 lquery = ( ( lwork.EQ.-1 ) .OR. ( liwork.EQ.-1 ) )
445*
446 kd = ilaenv2stage( 1, 'SSYTRD_2STAGE', jobz, n, -1, -1,
447 $ -1 )
448 ib = ilaenv2stage( 2, 'SSYTRD_2STAGE', jobz, n, kd, -1,
449 $ -1 )
450 lhtrd = ilaenv2stage( 3, 'SSYTRD_2STAGE', jobz, n, kd, ib,
451 $ -1 )
452 lwtrd = ilaenv2stage( 4, 'SSYTRD_2STAGE', jobz, n, kd, ib,
453 $ -1 )
454*
455 IF( n.LE.1 ) THEN
456 lwmin = 1
457 liwmin = 1
458 ELSE
459 lwmin = max( 26*n, 5*n + lhtrd + lwtrd )
460 liwmin = 10*n
461 END IF
462*
463 info = 0
464 IF( .NOT.( lsame( jobz, 'N' ) ) ) THEN
465 info = -1
466 ELSE IF( .NOT.( alleig .OR. valeig .OR. indeig ) ) THEN
467 info = -2
468 ELSE IF( .NOT.( lower .OR. lsame( uplo, 'U' ) ) ) THEN
469 info = -3
470 ELSE IF( n.LT.0 ) THEN
471 info = -4
472 ELSE IF( lda.LT.max( 1, n ) ) THEN
473 info = -6
474 ELSE
475 IF( valeig ) THEN
476 IF( n.GT.0 .AND. vu.LE.vl )
477 $ info = -8
478 ELSE IF( indeig ) THEN
479 IF( il.LT.1 .OR. il.GT.max( 1, n ) ) THEN
480 info = -9
481 ELSE IF( iu.LT.min( n, il ) .OR. iu.GT.n ) THEN
482 info = -10
483 END IF
484 END IF
485 END IF
486 IF( info.EQ.0 ) THEN
487 IF( ldz.LT.1 .OR. ( wantz .AND. ldz.LT.n ) ) THEN
488 info = -15
489 ELSE IF( lwork.LT.lwmin .AND. .NOT.lquery ) THEN
490 info = -18
491 ELSE IF( liwork.LT.liwmin .AND. .NOT.lquery ) THEN
492 info = -20
493 END IF
494 END IF
495*
496 IF( info.EQ.0 ) THEN
497* NB = ILAENV( 1, 'SSYTRD', UPLO, N, -1, -1, -1 )
498* NB = MAX( NB, ILAENV( 1, 'SORMTR', UPLO, N, -1, -1, -1 ) )
499* LWKOPT = MAX( ( NB+1 )*N, LWMIN )
500 work( 1 ) = sroundup_lwork( lwmin )
501 iwork( 1 ) = liwmin
502 END IF
503*
504 IF( info.NE.0 ) THEN
505 CALL xerbla( 'SSYEVR_2STAGE', -info )
506 RETURN
507 ELSE IF( lquery ) THEN
508 RETURN
509 END IF
510*
511* Quick return if possible
512*
513 m = 0
514 IF( n.EQ.0 ) THEN
515 work( 1 ) = 1
516 RETURN
517 END IF
518*
519 IF( n.EQ.1 ) THEN
520 work( 1 ) = 1
521 IF( alleig .OR. indeig ) THEN
522 m = 1
523 w( 1 ) = a( 1, 1 )
524 ELSE
525 IF( vl.LT.a( 1, 1 ) .AND. vu.GE.a( 1, 1 ) ) THEN
526 m = 1
527 w( 1 ) = a( 1, 1 )
528 END IF
529 END IF
530 IF( wantz ) THEN
531 z( 1, 1 ) = one
532 isuppz( 1 ) = 1
533 isuppz( 2 ) = 1
534 END IF
535 RETURN
536 END IF
537*
538* Get machine constants.
539*
540 safmin = slamch( 'Safe minimum' )
541 eps = slamch( 'Precision' )
542 smlnum = safmin / eps
543 bignum = one / smlnum
544 rmin = sqrt( smlnum )
545 rmax = min( sqrt( bignum ), one / sqrt( sqrt( safmin ) ) )
546*
547* Scale matrix to allowable range, if necessary.
548*
549 iscale = 0
550 abstll = abstol
551 IF (valeig) THEN
552 vll = vl
553 vuu = vu
554 END IF
555 anrm = slansy( 'M', uplo, n, a, lda, work )
556 IF( anrm.GT.zero .AND. anrm.LT.rmin ) THEN
557 iscale = 1
558 sigma = rmin / anrm
559 ELSE IF( anrm.GT.rmax ) THEN
560 iscale = 1
561 sigma = rmax / anrm
562 END IF
563 IF( iscale.EQ.1 ) THEN
564 IF( lower ) THEN
565 DO 10 j = 1, n
566 CALL sscal( n-j+1, sigma, a( j, j ), 1 )
567 10 CONTINUE
568 ELSE
569 DO 20 j = 1, n
570 CALL sscal( j, sigma, a( 1, j ), 1 )
571 20 CONTINUE
572 END IF
573 IF( abstol.GT.0 )
574 $ abstll = abstol*sigma
575 IF( valeig ) THEN
576 vll = vl*sigma
577 vuu = vu*sigma
578 END IF
579 END IF
580
581* Initialize indices into workspaces. Note: The IWORK indices are
582* used only if SSTERF or SSTEMR fail.
583
584* WORK(INDTAU:INDTAU+N-1) stores the scalar factors of the
585* elementary reflectors used in SSYTRD.
586 indtau = 1
587* WORK(INDD:INDD+N-1) stores the tridiagonal's diagonal entries.
588 indd = indtau + n
589* WORK(INDE:INDE+N-1) stores the off-diagonal entries of the
590* tridiagonal matrix from SSYTRD.
591 inde = indd + n
592* WORK(INDDD:INDDD+N-1) is a copy of the diagonal entries over
593* -written by SSTEMR (the SSTERF path copies the diagonal to W).
594 inddd = inde + n
595* WORK(INDEE:INDEE+N-1) is a copy of the off-diagonal entries over
596* -written while computing the eigenvalues in SSTERF and SSTEMR.
597 indee = inddd + n
598* INDHOUS is the starting offset Householder storage of stage 2
599 indhous = indee + n
600* INDWK is the starting offset of the left-over workspace, and
601* LLWORK is the remaining workspace size.
602 indwk = indhous + lhtrd
603 llwork = lwork - indwk + 1
604
605
606* IWORK(INDIBL:INDIBL+M-1) corresponds to IBLOCK in SSTEBZ and
607* stores the block indices of each of the M<=N eigenvalues.
608 indibl = 1
609* IWORK(INDISP:INDISP+NSPLIT-1) corresponds to ISPLIT in SSTEBZ and
610* stores the starting and finishing indices of each block.
611 indisp = indibl + n
612* IWORK(INDIFL:INDIFL+N-1) stores the indices of eigenvectors
613* that corresponding to eigenvectors that fail to converge in
614* SSTEIN. This information is discarded; if any fail, the driver
615* returns INFO > 0.
616 indifl = indisp + n
617* INDIWO is the offset of the remaining integer workspace.
618 indiwo = indifl + n
619
620*
621* Call SSYTRD_2STAGE to reduce symmetric matrix to tridiagonal form.
622*
623*
624 CALL ssytrd_2stage( jobz, uplo, n, a, lda, work( indd ),
625 $ work( inde ), work( indtau ), work( indhous ),
626 $ lhtrd, work( indwk ), llwork, iinfo )
627*
628* If all eigenvalues are desired
629* then call SSTERF or SSTEMR and SORMTR.
630*
631 test = .false.
632 IF( indeig ) THEN
633 IF( il.EQ.1 .AND. iu.EQ.n ) THEN
634 test = .true.
635 END IF
636 END IF
637 IF( ( alleig.OR.test ) .AND. ( ieeeok.EQ.1 ) ) THEN
638 IF( .NOT.wantz ) THEN
639 CALL scopy( n, work( indd ), 1, w, 1 )
640 CALL scopy( n-1, work( inde ), 1, work( indee ), 1 )
641 CALL ssterf( n, w, work( indee ), info )
642 ELSE
643 CALL scopy( n-1, work( inde ), 1, work( indee ), 1 )
644 CALL scopy( n, work( indd ), 1, work( inddd ), 1 )
645*
646 IF (abstol .LE. two*real( n )*eps) THEN
647 tryrac = .true.
648 ELSE
649 tryrac = .false.
650 END IF
651 CALL sstemr( jobz, 'A', n, work( inddd ), work( indee ),
652 $ vl, vu, il, iu, m, w, z, ldz, n, isuppz,
653 $ tryrac, work( indwk ), lwork, iwork, liwork,
654 $ info )
655*
656*
657*
658* Apply orthogonal matrix used in reduction to tridiagonal
659* form to eigenvectors returned by SSTEMR.
660*
661 IF( wantz .AND. info.EQ.0 ) THEN
662 indwkn = inde
663 llwrkn = lwork - indwkn + 1
664 CALL sormtr( 'L', uplo, 'N', n, m, a, lda,
665 $ work( indtau ), z, ldz, work( indwkn ),
666 $ llwrkn, iinfo )
667 END IF
668 END IF
669*
670*
671 IF( info.EQ.0 ) THEN
672* Everything worked. Skip SSTEBZ/SSTEIN. IWORK(:) are
673* undefined.
674 m = n
675 GO TO 30
676 END IF
677 info = 0
678 END IF
679*
680* Otherwise, call SSTEBZ and, if eigenvectors are desired, SSTEIN.
681* Also call SSTEBZ and SSTEIN if SSTEMR fails.
682*
683 IF( wantz ) THEN
684 order = 'B'
685 ELSE
686 order = 'E'
687 END IF
688
689 CALL sstebz( range, order, n, vll, vuu, il, iu, abstll,
690 $ work( indd ), work( inde ), m, nsplit, w,
691 $ iwork( indibl ), iwork( indisp ), work( indwk ),
692 $ iwork( indiwo ), info )
693*
694 IF( wantz ) THEN
695 CALL sstein( n, work( indd ), work( inde ), m, w,
696 $ iwork( indibl ), iwork( indisp ), z, ldz,
697 $ work( indwk ), iwork( indiwo ), iwork( indifl ),
698 $ info )
699*
700* Apply orthogonal matrix used in reduction to tridiagonal
701* form to eigenvectors returned by SSTEIN.
702*
703 indwkn = inde
704 llwrkn = lwork - indwkn + 1
705 CALL sormtr( 'L', uplo, 'N', n, m, a, lda, work( indtau ),
706 $ z,
707 $ ldz, work( indwkn ), llwrkn, iinfo )
708 END IF
709*
710* If matrix was scaled, then rescale eigenvalues appropriately.
711*
712* Jump here if SSTEMR/SSTEIN succeeded.
713 30 CONTINUE
714 IF( iscale.EQ.1 ) THEN
715 IF( info.EQ.0 ) THEN
716 imax = m
717 ELSE
718 imax = info - 1
719 END IF
720 CALL sscal( imax, one / sigma, w, 1 )
721 END IF
722*
723* If eigenvalues are not in order, then sort them, along with
724* eigenvectors. Note: We do not sort the IFAIL portion of IWORK.
725* It may not be initialized (if SSTEMR/SSTEIN succeeded), and we do
726* not return this detailed information to the user.
727*
728 IF( wantz ) THEN
729 DO 50 j = 1, m - 1
730 i = 0
731 tmp1 = w( j )
732 DO 40 jj = j + 1, m
733 IF( w( jj ).LT.tmp1 ) THEN
734 i = jj
735 tmp1 = w( jj )
736 END IF
737 40 CONTINUE
738*
739 IF( i.NE.0 ) THEN
740 w( i ) = w( j )
741 w( j ) = tmp1
742 CALL sswap( n, z( 1, i ), 1, z( 1, j ), 1 )
743 END IF
744 50 CONTINUE
745 END IF
746*
747* Set WORK(1) to optimal workspace size.
748*
749 work( 1 ) = sroundup_lwork( lwmin )
750 iwork( 1 ) = liwmin
751*
752 RETURN
753*
754* End of SSYEVR_2STAGE
755*
756 END
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine scopy(n, sx, incx, sy, incy)
SCOPY
Definition scopy.f:82
subroutine ssyevr_2stage(jobz, range, uplo, n, a, lda, vl, vu, il, iu, abstol, m, w, z, ldz, isuppz, work, lwork, iwork, liwork, info)
SSYEVR_2STAGE computes the eigenvalues and, optionally, the left and/or right eigenvectors for SY mat...
subroutine ssytrd_2stage(vect, uplo, n, a, lda, d, e, tau, hous2, lhous2, work, lwork, info)
SSYTRD_2STAGE
subroutine sscal(n, sa, sx, incx)
SSCAL
Definition sscal.f:79
subroutine sstebz(range, order, n, vl, vu, il, iu, abstol, d, e, m, nsplit, w, iblock, isplit, work, iwork, info)
SSTEBZ
Definition sstebz.f:272
subroutine sstein(n, d, e, m, w, iblock, isplit, z, ldz, work, iwork, ifail, info)
SSTEIN
Definition sstein.f:172
subroutine sstemr(jobz, range, n, d, e, vl, vu, il, iu, m, w, z, ldz, nzc, isuppz, tryrac, work, lwork, iwork, liwork, info)
SSTEMR
Definition sstemr.f:320
subroutine ssterf(n, d, e, info)
SSTERF
Definition ssterf.f:84
subroutine sswap(n, sx, incx, sy, incy)
SSWAP
Definition sswap.f:82
subroutine sormtr(side, uplo, trans, m, n, a, lda, tau, c, ldc, work, lwork, info)
SORMTR
Definition sormtr.f:171