LAPACK  3.7.0
LAPACK: Linear Algebra PACKage
zhbevx_2stage.f
Go to the documentation of this file.
1 *> \brief <b> ZHBEVX_2STAGE computes the eigenvalues and, optionally, the left and/or right eigenvectors for OTHER matrices</b>
2 *
3 * @precisions fortran z -> s d c
4 *
5 * =========== DOCUMENTATION ===========
6 *
7 * Online html documentation available at
8 * http://www.netlib.org/lapack/explore-html/
9 *
10 *> \htmlonly
11 *> Download ZHBEVX_2STAGE + dependencies
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zhbevx_2stage.f">
13 *> [TGZ]</a>
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zhbevx_2stage.f">
15 *> [ZIP]</a>
16 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zhbevx_2stage.f">
17 *> [TXT]</a>
18 *> \endhtmlonly
19 *
20 * Definition:
21 * ===========
22 *
23 * SUBROUTINE ZHBEVX_2STAGE( JOBZ, RANGE, UPLO, N, KD, AB, LDAB,
24 * Q, LDQ, VL, VU, IL, IU, ABSTOL, M, W,
25 * Z, LDZ, WORK, LWORK, RWORK, IWORK,
26 * IFAIL, INFO )
27 *
28 * IMPLICIT NONE
29 *
30 * .. Scalar Arguments ..
31 * CHARACTER JOBZ, RANGE, UPLO
32 * INTEGER IL, INFO, IU, KD, LDAB, LDQ, LDZ, M, N, LWORK
33 * DOUBLE PRECISION ABSTOL, VL, VU
34 * ..
35 * .. Array Arguments ..
36 * INTEGER IFAIL( * ), IWORK( * )
37 * DOUBLE PRECISION RWORK( * ), W( * )
38 * COMPLEX*16 AB( LDAB, * ), Q( LDQ, * ), WORK( * ),
39 * $ Z( LDZ, * )
40 * ..
41 *
42 *
43 *> \par Purpose:
44 * =============
45 *>
46 *> \verbatim
47 *>
48 *> ZHBEVX_2STAGE computes selected eigenvalues and, optionally, eigenvectors
49 *> of a complex Hermitian band matrix A using the 2stage technique for
50 *> the reduction to tridiagonal. Eigenvalues and eigenvectors
51 *> can be selected by specifying either a range of values or a range of
52 *> indices for the desired eigenvalues.
53 *> \endverbatim
54 *
55 * Arguments:
56 * ==========
57 *
58 *> \param[in] JOBZ
59 *> \verbatim
60 *> JOBZ is CHARACTER*1
61 *> = 'N': Compute eigenvalues only;
62 *> = 'V': Compute eigenvalues and eigenvectors.
63 *> Not available in this release.
64 *> \endverbatim
65 *>
66 *> \param[in] RANGE
67 *> \verbatim
68 *> RANGE is CHARACTER*1
69 *> = 'A': all eigenvalues will be found;
70 *> = 'V': all eigenvalues in the half-open interval (VL,VU]
71 *> will be found;
72 *> = 'I': the IL-th through IU-th eigenvalues will be found.
73 *> \endverbatim
74 *>
75 *> \param[in] UPLO
76 *> \verbatim
77 *> UPLO is CHARACTER*1
78 *> = 'U': Upper triangle of A is stored;
79 *> = 'L': Lower triangle of A is stored.
80 *> \endverbatim
81 *>
82 *> \param[in] N
83 *> \verbatim
84 *> N is INTEGER
85 *> The order of the matrix A. N >= 0.
86 *> \endverbatim
87 *>
88 *> \param[in] KD
89 *> \verbatim
90 *> KD is INTEGER
91 *> The number of superdiagonals of the matrix A if UPLO = 'U',
92 *> or the number of subdiagonals if UPLO = 'L'. KD >= 0.
93 *> \endverbatim
94 *>
95 *> \param[in,out] AB
96 *> \verbatim
97 *> AB is COMPLEX*16 array, dimension (LDAB, N)
98 *> On entry, the upper or lower triangle of the Hermitian band
99 *> matrix A, stored in the first KD+1 rows of the array. The
100 *> j-th column of A is stored in the j-th column of the array AB
101 *> as follows:
102 *> if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for max(1,j-kd)<=i<=j;
103 *> if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=min(n,j+kd).
104 *>
105 *> On exit, AB is overwritten by values generated during the
106 *> reduction to tridiagonal form.
107 *> \endverbatim
108 *>
109 *> \param[in] LDAB
110 *> \verbatim
111 *> LDAB is INTEGER
112 *> The leading dimension of the array AB. LDAB >= KD + 1.
113 *> \endverbatim
114 *>
115 *> \param[out] Q
116 *> \verbatim
117 *> Q is COMPLEX*16 array, dimension (LDQ, N)
118 *> If JOBZ = 'V', the N-by-N unitary matrix used in the
119 *> reduction to tridiagonal form.
120 *> If JOBZ = 'N', the array Q is not referenced.
121 *> \endverbatim
122 *>
123 *> \param[in] LDQ
124 *> \verbatim
125 *> LDQ is INTEGER
126 *> The leading dimension of the array Q. If JOBZ = 'V', then
127 *> LDQ >= max(1,N).
128 *> \endverbatim
129 *>
130 *> \param[in] VL
131 *> \verbatim
132 *> VL is DOUBLE PRECISION
133 *> If RANGE='V', the lower bound of the interval to
134 *> be searched for eigenvalues. VL < VU.
135 *> Not referenced if RANGE = 'A' or 'I'.
136 *> \endverbatim
137 *>
138 *> \param[in] VU
139 *> \verbatim
140 *> VU is DOUBLE PRECISION
141 *> If RANGE='V', the upper bound of the interval to
142 *> be searched for eigenvalues. VL < VU.
143 *> Not referenced if RANGE = 'A' or 'I'.
144 *> \endverbatim
145 *>
146 *> \param[in] IL
147 *> \verbatim
148 *> IL is INTEGER
149 *> If RANGE='I', the index of the
150 *> smallest eigenvalue to be returned.
151 *> 1 <= IL <= IU <= N, if N > 0; IL = 1 and IU = 0 if N = 0.
152 *> Not referenced if RANGE = 'A' or 'V'.
153 *> \endverbatim
154 *>
155 *> \param[in] IU
156 *> \verbatim
157 *> IU is INTEGER
158 *> If RANGE='I', the index of the
159 *> largest eigenvalue to be returned.
160 *> 1 <= IL <= IU <= N, if N > 0; IL = 1 and IU = 0 if N = 0.
161 *> Not referenced if RANGE = 'A' or 'V'.
162 *> \endverbatim
163 *>
164 *> \param[in] ABSTOL
165 *> \verbatim
166 *> ABSTOL is DOUBLE PRECISION
167 *> The absolute error tolerance for the eigenvalues.
168 *> An approximate eigenvalue is accepted as converged
169 *> when it is determined to lie in an interval [a,b]
170 *> of width less than or equal to
171 *>
172 *> ABSTOL + EPS * max( |a|,|b| ) ,
173 *>
174 *> where EPS is the machine precision. If ABSTOL is less than
175 *> or equal to zero, then EPS*|T| will be used in its place,
176 *> where |T| is the 1-norm of the tridiagonal matrix obtained
177 *> by reducing AB to tridiagonal form.
178 *>
179 *> Eigenvalues will be computed most accurately when ABSTOL is
180 *> set to twice the underflow threshold 2*DLAMCH('S'), not zero.
181 *> If this routine returns with INFO>0, indicating that some
182 *> eigenvectors did not converge, try setting ABSTOL to
183 *> 2*DLAMCH('S').
184 *>
185 *> See "Computing Small Singular Values of Bidiagonal Matrices
186 *> with Guaranteed High Relative Accuracy," by Demmel and
187 *> Kahan, LAPACK Working Note #3.
188 *> \endverbatim
189 *>
190 *> \param[out] M
191 *> \verbatim
192 *> M is INTEGER
193 *> The total number of eigenvalues found. 0 <= M <= N.
194 *> If RANGE = 'A', M = N, and if RANGE = 'I', M = IU-IL+1.
195 *> \endverbatim
196 *>
197 *> \param[out] W
198 *> \verbatim
199 *> W is DOUBLE PRECISION array, dimension (N)
200 *> The first M elements contain the selected eigenvalues in
201 *> ascending order.
202 *> \endverbatim
203 *>
204 *> \param[out] Z
205 *> \verbatim
206 *> Z is COMPLEX*16 array, dimension (LDZ, max(1,M))
207 *> If JOBZ = 'V', then if INFO = 0, the first M columns of Z
208 *> contain the orthonormal eigenvectors of the matrix A
209 *> corresponding to the selected eigenvalues, with the i-th
210 *> column of Z holding the eigenvector associated with W(i).
211 *> If an eigenvector fails to converge, then that column of Z
212 *> contains the latest approximation to the eigenvector, and the
213 *> index of the eigenvector is returned in IFAIL.
214 *> If JOBZ = 'N', then Z is not referenced.
215 *> Note: the user must ensure that at least max(1,M) columns are
216 *> supplied in the array Z; if RANGE = 'V', the exact value of M
217 *> is not known in advance and an upper bound must be used.
218 *> \endverbatim
219 *>
220 *> \param[in] LDZ
221 *> \verbatim
222 *> LDZ is INTEGER
223 *> The leading dimension of the array Z. LDZ >= 1, and if
224 *> JOBZ = 'V', LDZ >= max(1,N).
225 *> \endverbatim
226 *>
227 *> \param[out] WORK
228 *> \verbatim
229 *> WORK is COMPLEX*16 array, dimension (LWORK)
230 *> \endverbatim
231 *>
232 *> \param[in] LWORK
233 *> \verbatim
234 *> LWORK is INTEGER
235 *> The length of the array WORK. LWORK >= 1, when N <= 1;
236 *> otherwise
237 *> If JOBZ = 'N' and N > 1, LWORK must be queried.
238 *> LWORK = MAX(1, dimension) where
239 *> dimension = (2KD+1)*N + KD*NTHREADS
240 *> where KD is the size of the band.
241 *> NTHREADS is the number of threads used when
242 *> openMP compilation is enabled, otherwise =1.
243 *> If JOBZ = 'V' and N > 1, LWORK must be queried. Not yet available.
244 *>
245 *> If LWORK = -1, then a workspace query is assumed; the routine
246 *> only calculates the optimal sizes of the WORK, RWORK and
247 *> IWORK arrays, returns these values as the first entries of
248 *> the WORK, RWORK and IWORK arrays, and no error message
249 *> related to LWORK or LRWORK or LIWORK is issued by XERBLA.
250 *> \endverbatim
251 *>
252 *> \param[out] RWORK
253 *> \verbatim
254 *> RWORK is DOUBLE PRECISION array, dimension (7*N)
255 *> \endverbatim
256 *>
257 *> \param[out] IWORK
258 *> \verbatim
259 *> IWORK is INTEGER array, dimension (5*N)
260 *> \endverbatim
261 *>
262 *> \param[out] IFAIL
263 *> \verbatim
264 *> IFAIL is INTEGER array, dimension (N)
265 *> If JOBZ = 'V', then if INFO = 0, the first M elements of
266 *> IFAIL are zero. If INFO > 0, then IFAIL contains the
267 *> indices of the eigenvectors that failed to converge.
268 *> If JOBZ = 'N', then IFAIL is not referenced.
269 *> \endverbatim
270 *>
271 *> \param[out] INFO
272 *> \verbatim
273 *> INFO is INTEGER
274 *> = 0: successful exit
275 *> < 0: if INFO = -i, the i-th argument had an illegal value
276 *> > 0: if INFO = i, then i eigenvectors failed to converge.
277 *> Their indices are stored in array IFAIL.
278 *> \endverbatim
279 *
280 * Authors:
281 * ========
282 *
283 *> \author Univ. of Tennessee
284 *> \author Univ. of California Berkeley
285 *> \author Univ. of Colorado Denver
286 *> \author NAG Ltd.
287 *
288 *> \date June 2016
289 *
290 *> \ingroup complex16OTHEReigen
291 *
292 *> \par Further Details:
293 * =====================
294 *>
295 *> \verbatim
296 *>
297 *> All details about the 2stage techniques are available in:
298 *>
299 *> Azzam Haidar, Hatem Ltaief, and Jack Dongarra.
300 *> Parallel reduction to condensed forms for symmetric eigenvalue problems
301 *> using aggregated fine-grained and memory-aware kernels. In Proceedings
302 *> of 2011 International Conference for High Performance Computing,
303 *> Networking, Storage and Analysis (SC '11), New York, NY, USA,
304 *> Article 8 , 11 pages.
305 *> http://doi.acm.org/10.1145/2063384.2063394
306 *>
307 *> A. Haidar, J. Kurzak, P. Luszczek, 2013.
308 *> An improved parallel singular value algorithm and its implementation
309 *> for multicore hardware, In Proceedings of 2013 International Conference
310 *> for High Performance Computing, Networking, Storage and Analysis (SC '13).
311 *> Denver, Colorado, USA, 2013.
312 *> Article 90, 12 pages.
313 *> http://doi.acm.org/10.1145/2503210.2503292
314 *>
315 *> A. Haidar, R. Solca, S. Tomov, T. Schulthess and J. Dongarra.
316 *> A novel hybrid CPU-GPU generalized eigensolver for electronic structure
317 *> calculations based on fine-grained memory aware tasks.
318 *> International Journal of High Performance Computing Applications.
319 *> Volume 28 Issue 2, Pages 196-209, May 2014.
320 *> http://hpc.sagepub.com/content/28/2/196
321 *>
322 *> \endverbatim
323 *
324 * =====================================================================
325  SUBROUTINE zhbevx_2stage( JOBZ, RANGE, UPLO, N, KD, AB, LDAB,
326  $ q, ldq, vl, vu, il, iu, abstol, m, w,
327  $ z, ldz, work, lwork, rwork, iwork,
328  $ ifail, info )
329 *
330  IMPLICIT NONE
331 *
332 * -- LAPACK driver routine (version 3.7.0) --
333 * -- LAPACK is a software package provided by Univ. of Tennessee, --
334 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
335 * June 2016
336 *
337 * .. Scalar Arguments ..
338  CHARACTER JOBZ, RANGE, UPLO
339  INTEGER IL, INFO, IU, KD, LDAB, LDQ, LDZ, M, N, LWORK
340  DOUBLE PRECISION ABSTOL, VL, VU
341 * ..
342 * .. Array Arguments ..
343  INTEGER IFAIL( * ), IWORK( * )
344  DOUBLE PRECISION RWORK( * ), W( * )
345  COMPLEX*16 AB( ldab, * ), Q( ldq, * ), WORK( * ),
346  $ z( ldz, * )
347 * ..
348 *
349 * =====================================================================
350 *
351 * .. Parameters ..
352  DOUBLE PRECISION ZERO, ONE
353  parameter ( zero = 0.0d0, one = 1.0d0 )
354  COMPLEX*16 CZERO, CONE
355  parameter ( czero = ( 0.0d0, 0.0d0 ),
356  $ cone = ( 1.0d0, 0.0d0 ) )
357 * ..
358 * .. Local Scalars ..
359  LOGICAL ALLEIG, INDEIG, LOWER, TEST, VALEIG, WANTZ,
360  $ lquery
361  CHARACTER ORDER
362  INTEGER I, IINFO, IMAX, INDD, INDE, INDEE, INDIBL,
363  $ indisp, indiwk, indrwk, indwrk, iscale, itmp1,
364  $ llwork, lwmin, lhtrd, lwtrd, ib, indhous,
365  $ j, jj, nsplit
366  DOUBLE PRECISION ABSTLL, ANRM, BIGNUM, EPS, RMAX, RMIN, SAFMIN,
367  $ sigma, smlnum, tmp1, vll, vuu
368  COMPLEX*16 CTMP1
369 * ..
370 * .. External Functions ..
371  LOGICAL LSAME
372  INTEGER ILAENV
373  DOUBLE PRECISION DLAMCH, ZLANHB
374  EXTERNAL lsame, dlamch, zlanhb, ilaenv
375 * ..
376 * .. External Subroutines ..
377  EXTERNAL dcopy, dscal, dstebz, dsterf, xerbla, zcopy,
379  $ zswap, zhetrd_hb2st
380 * ..
381 * .. Intrinsic Functions ..
382  INTRINSIC dble, max, min, sqrt
383 * ..
384 * .. Executable Statements ..
385 *
386 * Test the input parameters.
387 *
388  wantz = lsame( jobz, 'V' )
389  alleig = lsame( range, 'A' )
390  valeig = lsame( range, 'V' )
391  indeig = lsame( range, 'I' )
392  lower = lsame( uplo, 'L' )
393  lquery = ( lwork.EQ.-1 )
394 *
395  info = 0
396  IF( .NOT.( lsame( jobz, 'N' ) ) ) THEN
397  info = -1
398  ELSE IF( .NOT.( alleig .OR. valeig .OR. indeig ) ) THEN
399  info = -2
400  ELSE IF( .NOT.( lower .OR. lsame( uplo, 'U' ) ) ) THEN
401  info = -3
402  ELSE IF( n.LT.0 ) THEN
403  info = -4
404  ELSE IF( kd.LT.0 ) THEN
405  info = -5
406  ELSE IF( ldab.LT.kd+1 ) THEN
407  info = -7
408  ELSE IF( wantz .AND. ldq.LT.max( 1, n ) ) THEN
409  info = -9
410  ELSE
411  IF( valeig ) THEN
412  IF( n.GT.0 .AND. vu.LE.vl )
413  $ info = -11
414  ELSE IF( indeig ) THEN
415  IF( il.LT.1 .OR. il.GT.max( 1, n ) ) THEN
416  info = -12
417  ELSE IF( iu.LT.min( n, il ) .OR. iu.GT.n ) THEN
418  info = -13
419  END IF
420  END IF
421  END IF
422  IF( info.EQ.0 ) THEN
423  IF( ldz.LT.1 .OR. ( wantz .AND. ldz.LT.n ) )
424  $ info = -18
425  END IF
426 *
427  IF( info.EQ.0 ) THEN
428  IF( n.LE.1 ) THEN
429  lwmin = 1
430  work( 1 ) = lwmin
431  ELSE
432  ib = ilaenv( 18, 'ZHETRD_HB2ST', jobz, n, kd, -1, -1 )
433  lhtrd = ilaenv( 19, 'ZHETRD_HB2ST', jobz, n, kd, ib, -1 )
434  lwtrd = ilaenv( 20, 'ZHETRD_HB2ST', jobz, n, kd, ib, -1 )
435  lwmin = lhtrd + lwtrd
436  work( 1 ) = lwmin
437  ENDIF
438 *
439  IF( lwork.LT.lwmin .AND. .NOT.lquery )
440  $ info = -20
441  END IF
442 *
443  IF( info.NE.0 ) THEN
444  CALL xerbla( 'ZHBEVX_2STAGE', -info )
445  RETURN
446  ELSE IF( lquery ) THEN
447  RETURN
448  END IF
449 *
450 * Quick return if possible
451 *
452  m = 0
453  IF( n.EQ.0 )
454  $ RETURN
455 *
456  IF( n.EQ.1 ) THEN
457  m = 1
458  IF( lower ) THEN
459  ctmp1 = ab( 1, 1 )
460  ELSE
461  ctmp1 = ab( kd+1, 1 )
462  END IF
463  tmp1 = dble( ctmp1 )
464  IF( valeig ) THEN
465  IF( .NOT.( vl.LT.tmp1 .AND. vu.GE.tmp1 ) )
466  $ m = 0
467  END IF
468  IF( m.EQ.1 ) THEN
469  w( 1 ) = dble( ctmp1 )
470  IF( wantz )
471  $ z( 1, 1 ) = cone
472  END IF
473  RETURN
474  END IF
475 *
476 * Get machine constants.
477 *
478  safmin = dlamch( 'Safe minimum' )
479  eps = dlamch( 'Precision' )
480  smlnum = safmin / eps
481  bignum = one / smlnum
482  rmin = sqrt( smlnum )
483  rmax = min( sqrt( bignum ), one / sqrt( sqrt( safmin ) ) )
484 *
485 * Scale matrix to allowable range, if necessary.
486 *
487  iscale = 0
488  abstll = abstol
489  IF( valeig ) THEN
490  vll = vl
491  vuu = vu
492  ELSE
493  vll = zero
494  vuu = zero
495  END IF
496  anrm = zlanhb( 'M', uplo, n, kd, ab, ldab, rwork )
497  IF( anrm.GT.zero .AND. anrm.LT.rmin ) THEN
498  iscale = 1
499  sigma = rmin / anrm
500  ELSE IF( anrm.GT.rmax ) THEN
501  iscale = 1
502  sigma = rmax / anrm
503  END IF
504  IF( iscale.EQ.1 ) THEN
505  IF( lower ) THEN
506  CALL zlascl( 'B', kd, kd, one, sigma, n, n, ab, ldab, info )
507  ELSE
508  CALL zlascl( 'Q', kd, kd, one, sigma, n, n, ab, ldab, info )
509  END IF
510  IF( abstol.GT.0 )
511  $ abstll = abstol*sigma
512  IF( valeig ) THEN
513  vll = vl*sigma
514  vuu = vu*sigma
515  END IF
516  END IF
517 *
518 * Call ZHBTRD_HB2ST to reduce Hermitian band matrix to tridiagonal form.
519 *
520  indd = 1
521  inde = indd + n
522  indrwk = inde + n
523 *
524  indhous = 1
525  indwrk = indhous + lhtrd
526  llwork = lwork - indwrk + 1
527 *
528  CALL zhetrd_hb2st( 'N', jobz, uplo, n, kd, ab, ldab,
529  $ rwork( indd ), rwork( inde ), work( indhous ),
530  $ lhtrd, work( indwrk ), llwork, iinfo )
531 *
532 * If all eigenvalues are desired and ABSTOL is less than or equal
533 * to zero, then call DSTERF or ZSTEQR. If this fails for some
534 * eigenvalue, then try DSTEBZ.
535 *
536  test = .false.
537  IF (indeig) THEN
538  IF (il.EQ.1 .AND. iu.EQ.n) THEN
539  test = .true.
540  END IF
541  END IF
542  IF ((alleig .OR. test) .AND. (abstol.LE.zero)) THEN
543  CALL dcopy( n, rwork( indd ), 1, w, 1 )
544  indee = indrwk + 2*n
545  IF( .NOT.wantz ) THEN
546  CALL dcopy( n-1, rwork( inde ), 1, rwork( indee ), 1 )
547  CALL dsterf( n, w, rwork( indee ), info )
548  ELSE
549  CALL zlacpy( 'A', n, n, q, ldq, z, ldz )
550  CALL dcopy( n-1, rwork( inde ), 1, rwork( indee ), 1 )
551  CALL zsteqr( jobz, n, w, rwork( indee ), z, ldz,
552  $ rwork( indrwk ), info )
553  IF( info.EQ.0 ) THEN
554  DO 10 i = 1, n
555  ifail( i ) = 0
556  10 CONTINUE
557  END IF
558  END IF
559  IF( info.EQ.0 ) THEN
560  m = n
561  GO TO 30
562  END IF
563  info = 0
564  END IF
565 *
566 * Otherwise, call DSTEBZ and, if eigenvectors are desired, ZSTEIN.
567 *
568  IF( wantz ) THEN
569  order = 'B'
570  ELSE
571  order = 'E'
572  END IF
573  indibl = 1
574  indisp = indibl + n
575  indiwk = indisp + n
576  CALL dstebz( range, order, n, vll, vuu, il, iu, abstll,
577  $ rwork( indd ), rwork( inde ), m, nsplit, w,
578  $ iwork( indibl ), iwork( indisp ), rwork( indrwk ),
579  $ iwork( indiwk ), info )
580 *
581  IF( wantz ) THEN
582  CALL zstein( n, rwork( indd ), rwork( inde ), m, w,
583  $ iwork( indibl ), iwork( indisp ), z, ldz,
584  $ rwork( indrwk ), iwork( indiwk ), ifail, info )
585 *
586 * Apply unitary matrix used in reduction to tridiagonal
587 * form to eigenvectors returned by ZSTEIN.
588 *
589  DO 20 j = 1, m
590  CALL zcopy( n, z( 1, j ), 1, work( 1 ), 1 )
591  CALL zgemv( 'N', n, n, cone, q, ldq, work, 1, czero,
592  $ z( 1, j ), 1 )
593  20 CONTINUE
594  END IF
595 *
596 * If matrix was scaled, then rescale eigenvalues appropriately.
597 *
598  30 CONTINUE
599  IF( iscale.EQ.1 ) THEN
600  IF( info.EQ.0 ) THEN
601  imax = m
602  ELSE
603  imax = info - 1
604  END IF
605  CALL dscal( imax, one / sigma, w, 1 )
606  END IF
607 *
608 * If eigenvalues are not in order, then sort them, along with
609 * eigenvectors.
610 *
611  IF( wantz ) THEN
612  DO 50 j = 1, m - 1
613  i = 0
614  tmp1 = w( j )
615  DO 40 jj = j + 1, m
616  IF( w( jj ).LT.tmp1 ) THEN
617  i = jj
618  tmp1 = w( jj )
619  END IF
620  40 CONTINUE
621 *
622  IF( i.NE.0 ) THEN
623  itmp1 = iwork( indibl+i-1 )
624  w( i ) = w( j )
625  iwork( indibl+i-1 ) = iwork( indibl+j-1 )
626  w( j ) = tmp1
627  iwork( indibl+j-1 ) = itmp1
628  CALL zswap( n, z( 1, i ), 1, z( 1, j ), 1 )
629  IF( info.NE.0 ) THEN
630  itmp1 = ifail( i )
631  ifail( i ) = ifail( j )
632  ifail( j ) = itmp1
633  END IF
634  END IF
635  50 CONTINUE
636  END IF
637 *
638 * Set WORK(1) to optimal workspace size.
639 *
640  work( 1 ) = lwmin
641 *
642  RETURN
643 *
644 * End of ZHBEVX_2STAGE
645 *
646  END
subroutine dcopy(N, DX, INCX, DY, INCY)
DCOPY
Definition: dcopy.f:53
subroutine zcopy(N, ZX, INCX, ZY, INCY)
ZCOPY
Definition: zcopy.f:52
subroutine zgemv(TRANS, M, N, ALPHA, A, LDA, X, INCX, BETA, Y, INCY)
ZGEMV
Definition: zgemv.f:160
subroutine zswap(N, ZX, INCX, ZY, INCY)
ZSWAP
Definition: zswap.f:52
subroutine zlascl(TYPE, KL, KU, CFROM, CTO, M, N, A, LDA, INFO)
ZLASCL multiplies a general rectangular matrix by a real scalar defined as cto/cfrom.
Definition: zlascl.f:145
subroutine zlacpy(UPLO, M, N, A, LDA, B, LDB)
ZLACPY copies all or part of one two-dimensional array to another.
Definition: zlacpy.f:105
subroutine dsterf(N, D, E, INFO)
DSTERF
Definition: dsterf.f:88
subroutine zsteqr(COMPZ, N, D, E, Z, LDZ, WORK, INFO)
ZSTEQR
Definition: zsteqr.f:134
subroutine zstein(N, D, E, M, W, IBLOCK, ISPLIT, Z, LDZ, WORK, IWORK, IFAIL, INFO)
ZSTEIN
Definition: zstein.f:184
subroutine dstebz(RANGE, ORDER, N, VL, VU, IL, IU, ABSTOL, D, E, M, NSPLIT, W, IBLOCK, ISPLIT, WORK, IWORK, INFO)
DSTEBZ
Definition: dstebz.f:275
subroutine xerbla(SRNAME, INFO)
XERBLA
Definition: xerbla.f:62
subroutine zhbevx_2stage(JOBZ, RANGE, UPLO, N, KD, AB, LDAB, Q, LDQ, VL, VU, IL, IU, ABSTOL, M, W, Z, LDZ, WORK, LWORK, RWORK, IWORK, IFAIL, INFO)
ZHBEVX_2STAGE computes the eigenvalues and, optionally, the left and/or right eigenvectors for OTHER...
subroutine dscal(N, DA, DX, INCX)
DSCAL
Definition: dscal.f:55