1 *> \brief <b> DSYEV computes the eigenvalues and, optionally, the left and/or right eigenvectors for SY matrices</b>
3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
9 *> Download DSYEV + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dsyev.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dsyev.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dsyev.f">
21 * SUBROUTINE DSYEV( JOBZ, UPLO, N, A, LDA, W, WORK, LWORK, INFO )
23 * .. Scalar Arguments ..
24 * CHARACTER JOBZ, UPLO
25 * INTEGER INFO, LDA, LWORK, N
27 * .. Array Arguments ..
28 * DOUBLE PRECISION A( LDA, * ), W( * ), WORK( * )
37 *> DSYEV computes all eigenvalues and, optionally, eigenvectors of a
38 *> real symmetric matrix A.
46 *> JOBZ is CHARACTER*1
47 *> = 'N': Compute eigenvalues only;
48 *> = 'V': Compute eigenvalues and eigenvectors.
53 *> UPLO is CHARACTER*1
54 *> = 'U': Upper triangle of A is stored;
55 *> = 'L': Lower triangle of A is stored.
61 *> The order of the matrix A. N >= 0.
66 *> A is DOUBLE PRECISION array, dimension (LDA, N)
67 *> On entry, the symmetric matrix A. If UPLO = 'U', the
68 *> leading N-by-N upper triangular part of A contains the
69 *> upper triangular part of the matrix A. If UPLO = 'L',
70 *> the leading N-by-N lower triangular part of A contains
71 *> the lower triangular part of the matrix A.
72 *> On exit, if JOBZ = 'V', then if INFO = 0, A contains the
73 *> orthonormal eigenvectors of the matrix A.
74 *> If JOBZ = 'N', then on exit the lower triangle (if UPLO='L')
75 *> or the upper triangle (if UPLO='U') of A, including the
76 *> diagonal, is destroyed.
82 *> The leading dimension of the array A. LDA >= max(1,N).
87 *> W is DOUBLE PRECISION array, dimension (N)
88 *> If INFO = 0, the eigenvalues in ascending order.
93 *> WORK is DOUBLE PRECISION array, dimension (MAX(1,LWORK))
94 *> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
100 *> The length of the array WORK. LWORK >= max(1,3*N-1).
101 *> For optimal efficiency, LWORK >= (NB+2)*N,
102 *> where NB is the blocksize for DSYTRD returned by ILAENV.
104 *> If LWORK = -1, then a workspace query is assumed; the routine
105 *> only calculates the optimal size of the WORK array, returns
106 *> this value as the first entry of the WORK array, and no error
107 *> message related to LWORK is issued by XERBLA.
113 *> = 0: successful exit
114 *> < 0: if INFO = -i, the i-th argument had an illegal value
115 *> > 0: if INFO = i, the algorithm failed to converge; i
116 *> off-diagonal elements of an intermediate tridiagonal
117 *> form did not converge to zero.
123 *> \author Univ. of Tennessee
124 *> \author Univ. of California Berkeley
125 *> \author Univ. of Colorado Denver
128 *> \date November 2011
130 *> \ingroup doubleSYeigen
132 * =====================================================================
133 SUBROUTINE DSYEV( JOBZ, UPLO, N, A, LDA, W, WORK, LWORK, INFO )
135 * -- LAPACK driver routine (version 3.4.0) --
136 * -- LAPACK is a software package provided by Univ. of Tennessee, --
137 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
140 * .. Scalar Arguments ..
142 INTEGER INFO, LDA, LWORK, N
144 * .. Array Arguments ..
145 DOUBLE PRECISION A( LDA, * ), W( * ), WORK( * )
148 * =====================================================================
151 DOUBLE PRECISION ZERO, ONE
152 PARAMETER ( ZERO = 0.0D0, ONE = 1.0D0 )
154 * .. Local Scalars ..
155 LOGICAL LOWER, LQUERY, WANTZ
156 INTEGER IINFO, IMAX, INDE, INDTAU, INDWRK, ISCALE,
158 DOUBLE PRECISION ANRM, BIGNUM, EPS, RMAX, RMIN, SAFMIN, SIGMA,
161 * .. External Functions ..
164 DOUBLE PRECISION DLAMCH, DLANSY
165 EXTERNAL LSAME, ILAENV, DLAMCH, DLANSY
167 * .. External Subroutines ..
168 EXTERNAL DLASCL, DORGTR, DSCAL, DSTEQR, DSTERF, DSYTRD,
171 * .. Intrinsic Functions ..
174 * .. Executable Statements ..
176 * Test the input parameters.
178 WANTZ = LSAME( JOBZ, 'V' )
179 LOWER = LSAME( UPLO, 'L' )
180 LQUERY = ( LWORK.EQ.-1 )
183 IF( .NOT.( WANTZ .OR. LSAME( JOBZ, 'N' ) ) ) THEN
185 ELSE IF( .NOT.( LOWER .OR. LSAME( UPLO, 'U' ) ) ) THEN
187 ELSE IF( N.LT.0 ) THEN
189 ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
194 NB = ILAENV( 1, 'DSYTRD', UPLO, N, -1, -1, -1 )
195 LWKOPT = MAX( 1, ( NB+2 )*N )
198 IF( LWORK.LT.MAX( 1, 3*N-1 ) .AND. .NOT.LQUERY )
203 CALL XERBLA( 'DSYEV ', -INFO )
205 ELSE IF( LQUERY ) THEN
209 * Quick return if possible
223 * Get machine constants.
225 SAFMIN = DLAMCH( 'Safe minimum' )
226 EPS = DLAMCH( 'Precision' )
227 SMLNUM = SAFMIN / EPS
228 BIGNUM = ONE / SMLNUM
229 RMIN = SQRT( SMLNUM )
230 RMAX = SQRT( BIGNUM )
232 * Scale matrix to allowable range, if necessary.
234 ANRM = DLANSY( 'M', UPLO, N, A, LDA, WORK )
236 IF( ANRM.GT.ZERO .AND. ANRM.LT.RMIN ) THEN
239 ELSE IF( ANRM.GT.RMAX ) THEN
244 $ CALL DLASCL( UPLO, 0, 0, ONE, SIGMA, N, N, A, LDA, INFO )
246 * Call DSYTRD to reduce symmetric matrix to tridiagonal form.
251 LLWORK = LWORK - INDWRK + 1
252 CALL DSYTRD( UPLO, N, A, LDA, W, WORK( INDE ), WORK( INDTAU ),
253 $ WORK( INDWRK ), LLWORK, IINFO )
255 * For eigenvalues only, call DSTERF. For eigenvectors, first call
256 * DORGTR to generate the orthogonal matrix, then call DSTEQR.
258 IF( .NOT.WANTZ ) THEN
259 CALL DSTERF( N, W, WORK( INDE ), INFO )
261 CALL DORGTR( UPLO, N, A, LDA, WORK( INDTAU ), WORK( INDWRK ),
263 CALL DSTEQR( JOBZ, N, W, WORK( INDE ), A, LDA, WORK( INDTAU ),
267 * If matrix was scaled, then rescale eigenvalues appropriately.
269 IF( ISCALE.EQ.1 ) THEN
275 CALL DSCAL( IMAX, ONE / SIGMA, W, 1 )
278 * Set WORK(1) to optimal workspace size.