LAPACK  3.10.0
LAPACK: Linear Algebra PACKage

◆ cheev()

subroutine cheev ( character  JOBZ,
character  UPLO,
integer  N,
complex, dimension( lda, * )  A,
integer  LDA,
real, dimension( * )  W,
complex, dimension( * )  WORK,
integer  LWORK,
real, dimension( * )  RWORK,
integer  INFO 
)

CHEEV computes the eigenvalues and, optionally, the left and/or right eigenvectors for HE matrices

Download CHEEV + dependencies [TGZ] [ZIP] [TXT]

Purpose:
 CHEEV computes all eigenvalues and, optionally, eigenvectors of a
 complex Hermitian matrix A.
Parameters
[in]JOBZ
          JOBZ is CHARACTER*1
          = 'N':  Compute eigenvalues only;
          = 'V':  Compute eigenvalues and eigenvectors.
[in]UPLO
          UPLO is CHARACTER*1
          = 'U':  Upper triangle of A is stored;
          = 'L':  Lower triangle of A is stored.
[in]N
          N is INTEGER
          The order of the matrix A.  N >= 0.
[in,out]A
          A is COMPLEX array, dimension (LDA, N)
          On entry, the Hermitian matrix A.  If UPLO = 'U', the
          leading N-by-N upper triangular part of A contains the
          upper triangular part of the matrix A.  If UPLO = 'L',
          the leading N-by-N lower triangular part of A contains
          the lower triangular part of the matrix A.
          On exit, if JOBZ = 'V', then if INFO = 0, A contains the
          orthonormal eigenvectors of the matrix A.
          If JOBZ = 'N', then on exit the lower triangle (if UPLO='L')
          or the upper triangle (if UPLO='U') of A, including the
          diagonal, is destroyed.
[in]LDA
          LDA is INTEGER
          The leading dimension of the array A.  LDA >= max(1,N).
[out]W
          W is REAL array, dimension (N)
          If INFO = 0, the eigenvalues in ascending order.
[out]WORK
          WORK is COMPLEX array, dimension (MAX(1,LWORK))
          On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
[in]LWORK
          LWORK is INTEGER
          The length of the array WORK.  LWORK >= max(1,2*N-1).
          For optimal efficiency, LWORK >= (NB+1)*N,
          where NB is the blocksize for CHETRD returned by ILAENV.

          If LWORK = -1, then a workspace query is assumed; the routine
          only calculates the optimal size of the WORK array, returns
          this value as the first entry of the WORK array, and no error
          message related to LWORK is issued by XERBLA.
[out]RWORK
          RWORK is REAL array, dimension (max(1, 3*N-2))
[out]INFO
          INFO is INTEGER
          = 0:  successful exit
          < 0:  if INFO = -i, the i-th argument had an illegal value
          > 0:  if INFO = i, the algorithm failed to converge; i
                off-diagonal elements of an intermediate tridiagonal
                form did not converge to zero.
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.

Definition at line 138 of file cheev.f.

140 *
141 * -- LAPACK driver routine --
142 * -- LAPACK is a software package provided by Univ. of Tennessee, --
143 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
144 *
145 * .. Scalar Arguments ..
146  CHARACTER JOBZ, UPLO
147  INTEGER INFO, LDA, LWORK, N
148 * ..
149 * .. Array Arguments ..
150  REAL RWORK( * ), W( * )
151  COMPLEX A( LDA, * ), WORK( * )
152 * ..
153 *
154 * =====================================================================
155 *
156 * .. Parameters ..
157  REAL ZERO, ONE
158  parameter( zero = 0.0e0, one = 1.0e0 )
159  COMPLEX CONE
160  parameter( cone = ( 1.0e0, 0.0e0 ) )
161 * ..
162 * .. Local Scalars ..
163  LOGICAL LOWER, LQUERY, WANTZ
164  INTEGER IINFO, IMAX, INDE, INDTAU, INDWRK, ISCALE,
165  $ LLWORK, LWKOPT, NB
166  REAL ANRM, BIGNUM, EPS, RMAX, RMIN, SAFMIN, SIGMA,
167  $ SMLNUM
168 * ..
169 * .. External Functions ..
170  LOGICAL LSAME
171  INTEGER ILAENV
172  REAL CLANHE, SLAMCH
173  EXTERNAL ilaenv, lsame, clanhe, slamch
174 * ..
175 * .. External Subroutines ..
176  EXTERNAL chetrd, clascl, csteqr, cungtr, sscal, ssterf,
177  $ xerbla
178 * ..
179 * .. Intrinsic Functions ..
180  INTRINSIC max, sqrt
181 * ..
182 * .. Executable Statements ..
183 *
184 * Test the input parameters.
185 *
186  wantz = lsame( jobz, 'V' )
187  lower = lsame( uplo, 'L' )
188  lquery = ( lwork.EQ.-1 )
189 *
190  info = 0
191  IF( .NOT.( wantz .OR. lsame( jobz, 'N' ) ) ) THEN
192  info = -1
193  ELSE IF( .NOT.( lower .OR. lsame( uplo, 'U' ) ) ) THEN
194  info = -2
195  ELSE IF( n.LT.0 ) THEN
196  info = -3
197  ELSE IF( lda.LT.max( 1, n ) ) THEN
198  info = -5
199  END IF
200 *
201  IF( info.EQ.0 ) THEN
202  nb = ilaenv( 1, 'CHETRD', uplo, n, -1, -1, -1 )
203  lwkopt = max( 1, ( nb+1 )*n )
204  work( 1 ) = lwkopt
205 *
206  IF( lwork.LT.max( 1, 2*n-1 ) .AND. .NOT.lquery )
207  $ info = -8
208  END IF
209 *
210  IF( info.NE.0 ) THEN
211  CALL xerbla( 'CHEEV ', -info )
212  RETURN
213  ELSE IF( lquery ) THEN
214  RETURN
215  END IF
216 *
217 * Quick return if possible
218 *
219  IF( n.EQ.0 ) THEN
220  RETURN
221  END IF
222 *
223  IF( n.EQ.1 ) THEN
224  w( 1 ) = real( a( 1, 1 ) )
225  work( 1 ) = 1
226  IF( wantz )
227  $ a( 1, 1 ) = cone
228  RETURN
229  END IF
230 *
231 * Get machine constants.
232 *
233  safmin = slamch( 'Safe minimum' )
234  eps = slamch( 'Precision' )
235  smlnum = safmin / eps
236  bignum = one / smlnum
237  rmin = sqrt( smlnum )
238  rmax = sqrt( bignum )
239 *
240 * Scale matrix to allowable range, if necessary.
241 *
242  anrm = clanhe( 'M', uplo, n, a, lda, rwork )
243  iscale = 0
244  IF( anrm.GT.zero .AND. anrm.LT.rmin ) THEN
245  iscale = 1
246  sigma = rmin / anrm
247  ELSE IF( anrm.GT.rmax ) THEN
248  iscale = 1
249  sigma = rmax / anrm
250  END IF
251  IF( iscale.EQ.1 )
252  $ CALL clascl( uplo, 0, 0, one, sigma, n, n, a, lda, info )
253 *
254 * Call CHETRD to reduce Hermitian matrix to tridiagonal form.
255 *
256  inde = 1
257  indtau = 1
258  indwrk = indtau + n
259  llwork = lwork - indwrk + 1
260  CALL chetrd( uplo, n, a, lda, w, rwork( inde ), work( indtau ),
261  $ work( indwrk ), llwork, iinfo )
262 *
263 * For eigenvalues only, call SSTERF. For eigenvectors, first call
264 * CUNGTR to generate the unitary matrix, then call CSTEQR.
265 *
266  IF( .NOT.wantz ) THEN
267  CALL ssterf( n, w, rwork( inde ), info )
268  ELSE
269  CALL cungtr( uplo, n, a, lda, work( indtau ), work( indwrk ),
270  $ llwork, iinfo )
271  indwrk = inde + n
272  CALL csteqr( jobz, n, w, rwork( inde ), a, lda,
273  $ rwork( indwrk ), info )
274  END IF
275 *
276 * If matrix was scaled, then rescale eigenvalues appropriately.
277 *
278  IF( iscale.EQ.1 ) THEN
279  IF( info.EQ.0 ) THEN
280  imax = n
281  ELSE
282  imax = info - 1
283  END IF
284  CALL sscal( imax, one / sigma, w, 1 )
285  END IF
286 *
287 * Set WORK(1) to optimal complex workspace size.
288 *
289  work( 1 ) = lwkopt
290 *
291  RETURN
292 *
293 * End of CHEEV
294 *
integer function ilaenv(ISPEC, NAME, OPTS, N1, N2, N3, N4)
ILAENV
Definition: ilaenv.f:162
subroutine xerbla(SRNAME, INFO)
XERBLA
Definition: xerbla.f:60
logical function lsame(CA, CB)
LSAME
Definition: lsame.f:53
subroutine ssterf(N, D, E, INFO)
SSTERF
Definition: ssterf.f:86
real function clanhe(NORM, UPLO, N, A, LDA, WORK)
CLANHE returns the value of the 1-norm, or the Frobenius norm, or the infinity norm,...
Definition: clanhe.f:124
subroutine chetrd(UPLO, N, A, LDA, D, E, TAU, WORK, LWORK, INFO)
CHETRD
Definition: chetrd.f:192
subroutine clascl(TYPE, KL, KU, CFROM, CTO, M, N, A, LDA, INFO)
CLASCL multiplies a general rectangular matrix by a real scalar defined as cto/cfrom.
Definition: clascl.f:143
subroutine csteqr(COMPZ, N, D, E, Z, LDZ, WORK, INFO)
CSTEQR
Definition: csteqr.f:132
subroutine cungtr(UPLO, N, A, LDA, TAU, WORK, LWORK, INFO)
CUNGTR
Definition: cungtr.f:123
subroutine sscal(N, SA, SX, INCX)
SSCAL
Definition: sscal.f:79
real function slamch(CMACH)
SLAMCH
Definition: slamch.f:68
Here is the call graph for this function:
Here is the caller graph for this function: