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

◆ ssyev()

subroutine ssyev ( character jobz,
character uplo,
integer n,
real, dimension( lda, * ) a,
integer lda,
real, dimension( * ) w,
real, dimension( * ) work,
integer lwork,
integer info )

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

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

Purpose:
!>
!> SSYEV 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 REAL 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 REAL array, dimension (N)
!>          If INFO = 0, the eigenvalues in ascending order.
!> 
[out]WORK
!>          WORK is REAL 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 SSYTRD 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 ssyev.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 REAL A( LDA, * ), W( * ), WORK( * )
141* ..
142*
143* =====================================================================
144*
145* .. Parameters ..
146 REAL ZERO, ONE
147 parameter( zero = 0.0e0, one = 1.0e0 )
148* ..
149* .. Local Scalars ..
150 LOGICAL LOWER, LQUERY, WANTZ
151 INTEGER IINFO, IMAX, INDE, INDTAU, INDWRK, ISCALE,
152 $ LLWORK, LWKOPT, NB
153 REAL ANRM, BIGNUM, EPS, RMAX, RMIN, SAFMIN, SIGMA,
154 $ SMLNUM
155* ..
156* .. External Functions ..
157 LOGICAL LSAME
158 INTEGER ILAENV
159 REAL SLAMCH, SLANSY, SROUNDUP_LWORK
160 EXTERNAL ilaenv, lsame, slamch, slansy,
162* ..
163* .. External Subroutines ..
164 EXTERNAL slascl, sorgtr, sscal, ssteqr, ssterf,
165 $ ssytrd,
166 $ xerbla
167* ..
168* .. Intrinsic Functions ..
169 INTRINSIC max, sqrt
170* ..
171* .. Executable Statements ..
172*
173* Test the input parameters.
174*
175 wantz = lsame( jobz, 'V' )
176 lower = lsame( uplo, 'L' )
177 lquery = ( lwork.EQ.-1 )
178*
179 info = 0
180 IF( .NOT.( wantz .OR. lsame( jobz, 'N' ) ) ) THEN
181 info = -1
182 ELSE IF( .NOT.( lower .OR. lsame( uplo, 'U' ) ) ) THEN
183 info = -2
184 ELSE IF( n.LT.0 ) THEN
185 info = -3
186 ELSE IF( lda.LT.max( 1, n ) ) THEN
187 info = -5
188 END IF
189*
190 IF( info.EQ.0 ) THEN
191 nb = ilaenv( 1, 'SSYTRD', uplo, n, -1, -1, -1 )
192 lwkopt = max( 1, ( nb+2 )*n )
193 work( 1 ) = sroundup_lwork(lwkopt)
194*
195 IF( lwork.LT.max( 1, 3*n-1 ) .AND. .NOT.lquery )
196 $ info = -8
197 END IF
198*
199 IF( info.NE.0 ) THEN
200 CALL xerbla( 'SSYEV ', -info )
201 RETURN
202 ELSE IF( lquery ) THEN
203 RETURN
204 END IF
205*
206* Quick return if possible
207*
208 IF( n.EQ.0 ) THEN
209 RETURN
210 END IF
211*
212 IF( n.EQ.1 ) THEN
213 w( 1 ) = a( 1, 1 )
214 work( 1 ) = 2
215 IF( wantz )
216 $ a( 1, 1 ) = one
217 RETURN
218 END IF
219*
220* Get machine constants.
221*
222 safmin = slamch( 'Safe minimum' )
223 eps = slamch( 'Precision' )
224 smlnum = safmin / eps
225 bignum = one / smlnum
226 rmin = sqrt( smlnum )
227 rmax = sqrt( bignum )
228*
229* Scale matrix to allowable range, if necessary.
230*
231 anrm = slansy( 'M', uplo, n, a, lda, work )
232 iscale = 0
233 IF( anrm.GT.zero .AND. anrm.LT.rmin ) THEN
234 iscale = 1
235 sigma = rmin / anrm
236 ELSE IF( anrm.GT.rmax ) THEN
237 iscale = 1
238 sigma = rmax / anrm
239 END IF
240 IF( iscale.EQ.1 )
241 $ CALL slascl( uplo, 0, 0, one, sigma, n, n, a, lda, info )
242*
243* Call SSYTRD to reduce symmetric matrix to tridiagonal form.
244*
245 inde = 1
246 indtau = inde + n
247 indwrk = indtau + n
248 llwork = lwork - indwrk + 1
249 CALL ssytrd( uplo, n, a, lda, w, work( inde ), work( indtau ),
250 $ work( indwrk ), llwork, iinfo )
251*
252* For eigenvalues only, call SSTERF. For eigenvectors, first call
253* SORGTR to generate the orthogonal matrix, then call SSTEQR.
254*
255 IF( .NOT.wantz ) THEN
256 CALL ssterf( n, w, work( inde ), info )
257 ELSE
258 CALL sorgtr( uplo, n, a, lda, work( indtau ),
259 $ work( indwrk ),
260 $ llwork, iinfo )
261 CALL ssteqr( jobz, n, w, work( inde ), a, lda,
262 $ work( indtau ),
263 $ info )
264 END IF
265*
266* If matrix was scaled, then rescale eigenvalues appropriately.
267*
268 IF( iscale.EQ.1 ) THEN
269 IF( info.EQ.0 ) THEN
270 imax = n
271 ELSE
272 imax = info - 1
273 END IF
274 CALL sscal( imax, one / sigma, w, 1 )
275 END IF
276*
277* Set WORK(1) to optimal workspace size.
278*
279 work( 1 ) = sroundup_lwork(lwkopt)
280*
281 RETURN
282*
283* End of SSYEV
284*
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine ssytrd(uplo, n, a, lda, d, e, tau, work, lwork, info)
SSYTRD
Definition ssytrd.f:191
integer function ilaenv(ispec, name, opts, n1, n2, n3, n4)
ILAENV
Definition ilaenv.f:160
real function slamch(cmach)
SLAMCH
Definition slamch.f:68
real function slansy(norm, uplo, n, a, lda, work)
SLANSY returns the value of the 1-norm, or the Frobenius norm, or the infinity norm,...
Definition slansy.f:120
subroutine slascl(type, kl, ku, cfrom, cto, m, n, a, lda, info)
SLASCL multiplies a general rectangular matrix by a real scalar defined as cto/cfrom.
Definition slascl.f:142
logical function lsame(ca, cb)
LSAME
Definition lsame.f:48
real function sroundup_lwork(lwork)
SROUNDUP_LWORK
subroutine sscal(n, sa, sx, incx)
SSCAL
Definition sscal.f:79
subroutine ssteqr(compz, n, d, e, z, ldz, work, info)
SSTEQR
Definition ssteqr.f:129
subroutine ssterf(n, d, e, info)
SSTERF
Definition ssterf.f:84
subroutine sorgtr(uplo, n, a, lda, tau, work, lwork, info)
SORGTR
Definition sorgtr.f:121
Here is the call graph for this function:
Here is the caller graph for this function: