LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches

◆ dsyev()

subroutine dsyev ( character jobz,
character uplo,
integer n,
double precision, dimension( lda, * ) a,
integer lda,
double precision, dimension( * ) w,
double precision, dimension( * ) work,
integer lwork,
integer info )

DSYEV computes the eigenvalues and, optionally, the left and/or right eigenvectors for SY matrices

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

Purpose:
!>
!> DSYEV computes all eigenvalues and, optionally, eigenvectors of a
!> real symmetric 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 DOUBLE PRECISION array, dimension (LDA, N)
!>          On entry, the symmetric 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 DOUBLE PRECISION array, dimension (N)
!>          If INFO = 0, the eigenvalues in ascending order.
!> 
[out]WORK
!>          WORK is DOUBLE PRECISION 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,3*N-1).
!>          For optimal efficiency, LWORK >= (NB+2)*N,
!>          where NB is the blocksize for DSYTRD 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]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 129 of file dsyev.f.

130*
131* -- LAPACK driver routine --
132* -- LAPACK is a software package provided by Univ. of Tennessee, --
133* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
134*
135* .. Scalar Arguments ..
136 CHARACTER JOBZ, UPLO
137 INTEGER INFO, LDA, LWORK, N
138* ..
139* .. Array Arguments ..
140 DOUBLE PRECISION A( LDA, * ), W( * ), WORK( * )
141* ..
142*
143* =====================================================================
144*
145* .. Parameters ..
146 DOUBLE PRECISION ZERO, ONE
147 parameter( zero = 0.0d0, one = 1.0d0 )
148* ..
149* .. Local Scalars ..
150 LOGICAL LOWER, LQUERY, WANTZ
151 INTEGER IINFO, IMAX, INDE, INDTAU, INDWRK, ISCALE,
152 $ LLWORK, LWKOPT, NB
153 DOUBLE PRECISION ANRM, BIGNUM, EPS, RMAX, RMIN, SAFMIN, SIGMA,
154 $ SMLNUM
155* ..
156* .. External Functions ..
157 LOGICAL LSAME
158 INTEGER ILAENV
159 DOUBLE PRECISION DLAMCH, DLANSY
160 EXTERNAL lsame, ilaenv, dlamch, dlansy
161* ..
162* .. External Subroutines ..
163 EXTERNAL dlascl, dorgtr, dscal, dsteqr, dsterf,
164 $ dsytrd,
165 $ xerbla
166* ..
167* .. Intrinsic Functions ..
168 INTRINSIC max, sqrt
169* ..
170* .. Executable Statements ..
171*
172* Test the input parameters.
173*
174 wantz = lsame( jobz, 'V' )
175 lower = lsame( uplo, 'L' )
176 lquery = ( lwork.EQ.-1 )
177*
178 info = 0
179 IF( .NOT.( wantz .OR. lsame( jobz, 'N' ) ) ) THEN
180 info = -1
181 ELSE IF( .NOT.( lower .OR. lsame( uplo, 'U' ) ) ) THEN
182 info = -2
183 ELSE IF( n.LT.0 ) THEN
184 info = -3
185 ELSE IF( lda.LT.max( 1, n ) ) THEN
186 info = -5
187 END IF
188*
189 IF( info.EQ.0 ) THEN
190 nb = ilaenv( 1, 'DSYTRD', uplo, n, -1, -1, -1 )
191 lwkopt = max( 1, ( nb+2 )*n )
192 work( 1 ) = lwkopt
193*
194 IF( lwork.LT.max( 1, 3*n-1 ) .AND. .NOT.lquery )
195 $ info = -8
196 END IF
197*
198 IF( info.NE.0 ) THEN
199 CALL xerbla( 'DSYEV ', -info )
200 RETURN
201 ELSE IF( lquery ) THEN
202 RETURN
203 END IF
204*
205* Quick return if possible
206*
207 IF( n.EQ.0 ) THEN
208 RETURN
209 END IF
210*
211 IF( n.EQ.1 ) THEN
212 w( 1 ) = a( 1, 1 )
213 work( 1 ) = 2
214 IF( wantz )
215 $ a( 1, 1 ) = one
216 RETURN
217 END IF
218*
219* Get machine constants.
220*
221 safmin = dlamch( 'Safe minimum' )
222 eps = dlamch( 'Precision' )
223 smlnum = safmin / eps
224 bignum = one / smlnum
225 rmin = sqrt( smlnum )
226 rmax = sqrt( bignum )
227*
228* Scale matrix to allowable range, if necessary.
229*
230 anrm = dlansy( 'M', uplo, n, a, lda, work )
231 iscale = 0
232 IF( anrm.GT.zero .AND. anrm.LT.rmin ) THEN
233 iscale = 1
234 sigma = rmin / anrm
235 ELSE IF( anrm.GT.rmax ) THEN
236 iscale = 1
237 sigma = rmax / anrm
238 END IF
239 IF( iscale.EQ.1 )
240 $ CALL dlascl( uplo, 0, 0, one, sigma, n, n, a, lda, info )
241*
242* Call DSYTRD to reduce symmetric matrix to tridiagonal form.
243*
244 inde = 1
245 indtau = inde + n
246 indwrk = indtau + n
247 llwork = lwork - indwrk + 1
248 CALL dsytrd( uplo, n, a, lda, w, work( inde ), work( indtau ),
249 $ work( indwrk ), llwork, iinfo )
250*
251* For eigenvalues only, call DSTERF. For eigenvectors, first call
252* DORGTR to generate the orthogonal matrix, then call DSTEQR.
253*
254 IF( .NOT.wantz ) THEN
255 CALL dsterf( n, w, work( inde ), info )
256 ELSE
257 CALL dorgtr( uplo, n, a, lda, work( indtau ),
258 $ work( indwrk ),
259 $ llwork, iinfo )
260 CALL dsteqr( jobz, n, w, work( inde ), a, lda,
261 $ work( indtau ),
262 $ info )
263 END IF
264*
265* If matrix was scaled, then rescale eigenvalues appropriately.
266*
267 IF( iscale.EQ.1 ) THEN
268 IF( info.EQ.0 ) THEN
269 imax = n
270 ELSE
271 imax = info - 1
272 END IF
273 CALL dscal( imax, one / sigma, w, 1 )
274 END IF
275*
276* Set WORK(1) to optimal workspace size.
277*
278 work( 1 ) = lwkopt
279*
280 RETURN
281*
282* End of DSYEV
283*
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine dsytrd(uplo, n, a, lda, d, e, tau, work, lwork, info)
DSYTRD
Definition dsytrd.f:191
integer function ilaenv(ispec, name, opts, n1, n2, n3, n4)
ILAENV
Definition ilaenv.f:160
double precision function dlamch(cmach)
DLAMCH
Definition dlamch.f:69
double precision function dlansy(norm, uplo, n, a, lda, work)
DLANSY returns the value of the 1-norm, or the Frobenius norm, or the infinity norm,...
Definition dlansy.f:120
subroutine dlascl(type, kl, ku, cfrom, cto, m, n, a, lda, info)
DLASCL multiplies a general rectangular matrix by a real scalar defined as cto/cfrom.
Definition dlascl.f:142
logical function lsame(ca, cb)
LSAME
Definition lsame.f:48
subroutine dscal(n, da, dx, incx)
DSCAL
Definition dscal.f:79
subroutine dsteqr(compz, n, d, e, z, ldz, work, info)
DSTEQR
Definition dsteqr.f:129
subroutine dsterf(n, d, e, info)
DSTERF
Definition dsterf.f:84
subroutine dorgtr(uplo, n, a, lda, tau, work, lwork, info)
DORGTR
Definition dorgtr.f:121
Here is the call graph for this function:
Here is the caller graph for this function: