Télécharger dsyev.eso

Retour à la liste

Numérotation des lignes :

dsyev
  1. C DSYEV SOURCE BP208322 22/09/16 21:15:06 11454
  2. *> \brief <b> DSYEV computes the eigenvalues and, optionally, the left and/or right eigenvectors for SY matrices</b>
  3. *
  4. * =========== DOCUMENTATION ===========
  5. *
  6. * Online html documentation available at
  7. * http://www.netlib.org/lapack/explore-html/
  8. *
  9. *> \htmlonly
  10. *> Download DSYEV + dependencies
  11. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dsyev.f">
  12. *> [TGZ]</a>
  13. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dsyev.f">
  14. *> [ZIP]</a>
  15. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dsyev.f">
  16. *> [TXT]</a>
  17. *> \endhtmlonly
  18. *
  19. * Definition:
  20. * ===========
  21. *
  22. * SUBROUTINE DSYEV( JOBZ, UPLO, N, A, LDA, W, WORK, LWORK, INFO )
  23. *
  24. * .. Scalar Arguments ..
  25. * CHARACTER JOBZ, UPLO
  26. * INTEGER INFO, LDA, LWORK, N
  27. * ..
  28. * .. Array Arguments ..
  29. * REAL*8 A( LDA, * ), W( * ), WORK( * )
  30. * ..
  31. *
  32. *
  33. *> \par Purpose:
  34. * =============
  35. *>
  36. *> \verbatim
  37. *>
  38. *> DSYEV computes all eigenvalues and, optionally, eigenvectors of a
  39. *> real symmetric matrix A.
  40. *> \endverbatim
  41. *
  42. * Arguments:
  43. * ==========
  44. *
  45. *> \param[in] JOBZ
  46. *> \verbatim
  47. *> JOBZ is CHARACTER*1
  48. *> = 'N': Compute eigenvalues only;
  49. *> = 'V': Compute eigenvalues and eigenvectors.
  50. *> \endverbatim
  51. *>
  52. *> \param[in] UPLO
  53. *> \verbatim
  54. *> UPLO is CHARACTER*1
  55. *> = 'U': Upper triangle of A is stored;
  56. *> = 'L': Lower triangle of A is stored.
  57. *> \endverbatim
  58. *>
  59. *> \param[in] N
  60. *> \verbatim
  61. *> N is INTEGER
  62. *> The order of the matrix A. N >= 0.
  63. *> \endverbatim
  64. *>
  65. *> \param[in,out] A
  66. *> \verbatim
  67. *> A is REAL*8 array, dimension (LDA, N)
  68. *> On entry, the symmetric matrix A. If UPLO = 'U', the
  69. *> leading N-by-N upper triangular part of A contains the
  70. *> upper triangular part of the matrix A. If UPLO = 'L',
  71. *> the leading N-by-N lower triangular part of A contains
  72. *> the lower triangular part of the matrix A.
  73. *> On exit, if JOBZ = 'V', then if INFO = 0, A contains the
  74. *> orthonormal eigenvectors of the matrix A.
  75. *> If JOBZ = 'N', then on exit the lower triangle (if UPLO='L')
  76. *> or the upper triangle (if UPLO='U') of A, including the
  77. *> diagonal, is destroyed.
  78. *> \endverbatim
  79. *>
  80. *> \param[in] LDA
  81. *> \verbatim
  82. *> LDA is INTEGER
  83. *> The leading dimension of the array A. LDA >= max(1,N).
  84. *> \endverbatim
  85. *>
  86. *> \param[out] W
  87. *> \verbatim
  88. *> W is REAL*8 array, dimension (N)
  89. *> If INFO = 0, the eigenvalues in ascending order.
  90. *> \endverbatim
  91. *>
  92. *> \param[out] WORK
  93. *> \verbatim
  94. *> WORK is REAL*8 array, dimension (MAX(1,LWORK))
  95. *> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  96. *> \endverbatim
  97. *>
  98. *> \param[in] LWORK
  99. *> \verbatim
  100. *> LWORK is INTEGER
  101. *> The length of the array WORK. LWORK >= max(1,3*N-1).
  102. *> For optimal efficiency, LWORK >= (NB+2)*N,
  103. *> where NB is the blocksize for DSYTRD returned by ILAENV.
  104. *>
  105. *> If LWORK = -1, then a workspace query is assumed; the routine
  106. *> only calculates the optimal size of the WORK array, returns
  107. *> this value as the first entry of the WORK array, and no error
  108. *> message related to LWORK is issued by XERBLA.
  109. *> \endverbatim
  110. *>
  111. *> \param[out] INFO
  112. *> \verbatim
  113. *> INFO is INTEGER
  114. *> = 0: successful exit
  115. *> < 0: if INFO = -i, the i-th argument had an illegal value
  116. *> > 0: if INFO = i, the algorithm failed to converge; i
  117. *> off-diagonal elements of an intermediate tridiagonal
  118. *> form did not converge to zero.
  119. *> \endverbatim
  120. *
  121. * Authors:
  122. * ========
  123. *
  124. *> \author Univ. of Tennessee
  125. *> \author Univ. of California Berkeley
  126. *> \author Univ. of Colorado Denver
  127. *> \author NAG Ltd.
  128. *
  129. *> \ingroup doubleSYeigen
  130. *
  131. * =====================================================================
  132. SUBROUTINE DSYEV( JOBZ, UPLO, N, A, LDA, W, WORK, LWORK, INFO )
  133. *
  134. * -- LAPACK driver routine --
  135. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  136. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  137. *
  138. * .. Scalar Arguments ..
  139. CHARACTER JOBZ, UPLO
  140. INTEGER INFO, LDA, LWORK, N
  141. * ..
  142. * .. Array Arguments ..
  143. REAL*8 A( LDA, * ), W( * ), WORK( * )
  144. * ..
  145. *
  146. * =====================================================================
  147. *
  148. * .. Parameters ..
  149. REAL*8 ZERO, ONE
  150. PARAMETER ( ZERO = 0.0D0, ONE = 1.0D0 )
  151. * ..
  152. * .. Local Scalars ..
  153. LOGICAL LOWER, LQUERY, WANTZ
  154. INTEGER IINFO, IMAX, INDE, INDTAU, INDWRK, ISCALE,
  155. $ LLWORK, LWKOPT, NB
  156. REAL*8 ANRM, BIGNUM, EPS, RMAX, RMIN, SAFMIN, SIGMA,
  157. $ SMLNUM
  158. * ..
  159. * .. External Functions ..
  160. LOGICAL LSAME
  161. INTEGER ILAENV
  162. REAL*8 DLAMCH, DLANSY
  163. EXTERNAL LSAME, ILAENV, DLAMCH, DLANSY
  164. * ..
  165. * .. External Subroutines ..
  166. EXTERNAL DLASCL, DORGTR, DSCAL, DSTEQR, DSTERF, DSYTRD,
  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, 'DSYTRD', UPLO, N, -1, -1, -1 )
  192. LWKOPT = MAX( 1, ( NB+2 )*N )
  193. WORK( 1 ) = 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( 'DSYEV ', -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 = DLAMCH( 'Safe minimum' )
  223. EPS = DLAMCH( '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 = DLANSY( '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 DLASCL( UPLO, 0, 0, ONE, SIGMA, N, N, A, LDA, INFO )
  242. *
  243. * Call DSYTRD 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 DSYTRD( UPLO, N, A, LDA, W, WORK( INDE ), WORK( INDTAU ),
  250. $ WORK( INDWRK ), LLWORK, IINFO )
  251. *
  252. * For eigenvalues only, call DSTERF. For eigenvectors, first call
  253. * DORGTR to generate the orthogonal matrix, then call DSTEQR.
  254. *
  255. IF( .NOT.WANTZ ) THEN
  256. CALL DSTERF( N, W, WORK( INDE ), INFO )
  257. ELSE
  258. CALL DORGTR( UPLO, N, A, LDA, WORK( INDTAU ), WORK( INDWRK ),
  259. $ LLWORK, IINFO )
  260. CALL DSTEQR( JOBZ, N, W, WORK( INDE ), A, LDA, WORK( INDTAU ),
  261. $ INFO )
  262. END IF
  263. *
  264. * If matrix was scaled, then rescale eigenvalues appropriately.
  265. *
  266. IF( ISCALE.EQ.1 ) THEN
  267. IF( INFO.EQ.0 ) THEN
  268. IMAX = N
  269. ELSE
  270. IMAX = INFO - 1
  271. END IF
  272. CALL DSCAL( IMAX, ONE / SIGMA, W, 1 )
  273. END IF
  274. *
  275. * Set WORK(1) to optimal workspace size.
  276. *
  277. WORK( 1 ) = LWKOPT
  278. *
  279. RETURN
  280. *
  281. * End of DSYEV
  282. *
  283. END
  284.  
  285.  

© Cast3M 2003 - Tous droits réservés.
Mentions légales