You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

sstev.f 6.3 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. *> \brief <b> SSTEV computes the eigenvalues and, optionally, the left and/or right eigenvectors for OTHER matrices</b>
  2. *
  3. * =========== DOCUMENTATION ===========
  4. *
  5. * Online html documentation available at
  6. * http://www.netlib.org/lapack/explore-html/
  7. *
  8. *> \htmlonly
  9. *> Download SSTEV + dependencies
  10. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/sstev.f">
  11. *> [TGZ]</a>
  12. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/sstev.f">
  13. *> [ZIP]</a>
  14. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/sstev.f">
  15. *> [TXT]</a>
  16. *> \endhtmlonly
  17. *
  18. * Definition:
  19. * ===========
  20. *
  21. * SUBROUTINE SSTEV( JOBZ, N, D, E, Z, LDZ, WORK, INFO )
  22. *
  23. * .. Scalar Arguments ..
  24. * CHARACTER JOBZ
  25. * INTEGER INFO, LDZ, N
  26. * ..
  27. * .. Array Arguments ..
  28. * REAL D( * ), E( * ), WORK( * ), Z( LDZ, * )
  29. * ..
  30. *
  31. *
  32. *> \par Purpose:
  33. * =============
  34. *>
  35. *> \verbatim
  36. *>
  37. *> SSTEV computes all eigenvalues and, optionally, eigenvectors of a
  38. *> real symmetric tridiagonal matrix A.
  39. *> \endverbatim
  40. *
  41. * Arguments:
  42. * ==========
  43. *
  44. *> \param[in] JOBZ
  45. *> \verbatim
  46. *> JOBZ is CHARACTER*1
  47. *> = 'N': Compute eigenvalues only;
  48. *> = 'V': Compute eigenvalues and eigenvectors.
  49. *> \endverbatim
  50. *>
  51. *> \param[in] N
  52. *> \verbatim
  53. *> N is INTEGER
  54. *> The order of the matrix. N >= 0.
  55. *> \endverbatim
  56. *>
  57. *> \param[in,out] D
  58. *> \verbatim
  59. *> D is REAL array, dimension (N)
  60. *> On entry, the n diagonal elements of the tridiagonal matrix
  61. *> A.
  62. *> On exit, if INFO = 0, the eigenvalues in ascending order.
  63. *> \endverbatim
  64. *>
  65. *> \param[in,out] E
  66. *> \verbatim
  67. *> E is REAL array, dimension (N-1)
  68. *> On entry, the (n-1) subdiagonal elements of the tridiagonal
  69. *> matrix A, stored in elements 1 to N-1 of E.
  70. *> On exit, the contents of E are destroyed.
  71. *> \endverbatim
  72. *>
  73. *> \param[out] Z
  74. *> \verbatim
  75. *> Z is REAL array, dimension (LDZ, N)
  76. *> If JOBZ = 'V', then if INFO = 0, Z contains the orthonormal
  77. *> eigenvectors of the matrix A, with the i-th column of Z
  78. *> holding the eigenvector associated with D(i).
  79. *> If JOBZ = 'N', then Z is not referenced.
  80. *> \endverbatim
  81. *>
  82. *> \param[in] LDZ
  83. *> \verbatim
  84. *> LDZ is INTEGER
  85. *> The leading dimension of the array Z. LDZ >= 1, and if
  86. *> JOBZ = 'V', LDZ >= max(1,N).
  87. *> \endverbatim
  88. *>
  89. *> \param[out] WORK
  90. *> \verbatim
  91. *> WORK is REAL array, dimension (max(1,2*N-2))
  92. *> If JOBZ = 'N', WORK is not referenced.
  93. *> \endverbatim
  94. *>
  95. *> \param[out] INFO
  96. *> \verbatim
  97. *> INFO is INTEGER
  98. *> = 0: successful exit
  99. *> < 0: if INFO = -i, the i-th argument had an illegal value
  100. *> > 0: if INFO = i, the algorithm failed to converge; i
  101. *> off-diagonal elements of E did not converge to zero.
  102. *> \endverbatim
  103. *
  104. * Authors:
  105. * ========
  106. *
  107. *> \author Univ. of Tennessee
  108. *> \author Univ. of California Berkeley
  109. *> \author Univ. of Colorado Denver
  110. *> \author NAG Ltd.
  111. *
  112. *> \ingroup realOTHEReigen
  113. *
  114. * =====================================================================
  115. SUBROUTINE SSTEV( JOBZ, N, D, E, Z, LDZ, WORK, INFO )
  116. *
  117. * -- LAPACK driver routine --
  118. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  119. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  120. *
  121. * .. Scalar Arguments ..
  122. CHARACTER JOBZ
  123. INTEGER INFO, LDZ, N
  124. * ..
  125. * .. Array Arguments ..
  126. REAL D( * ), E( * ), WORK( * ), Z( LDZ, * )
  127. * ..
  128. *
  129. * =====================================================================
  130. *
  131. * .. Parameters ..
  132. REAL ZERO, ONE
  133. PARAMETER ( ZERO = 0.0E0, ONE = 1.0E0 )
  134. * ..
  135. * .. Local Scalars ..
  136. LOGICAL WANTZ
  137. INTEGER IMAX, ISCALE
  138. REAL BIGNUM, EPS, RMAX, RMIN, SAFMIN, SIGMA, SMLNUM,
  139. $ TNRM
  140. * ..
  141. * .. External Functions ..
  142. LOGICAL LSAME
  143. REAL SLAMCH, SLANST
  144. EXTERNAL LSAME, SLAMCH, SLANST
  145. * ..
  146. * .. External Subroutines ..
  147. EXTERNAL SSCAL, SSTEQR, SSTERF, XERBLA
  148. * ..
  149. * .. Intrinsic Functions ..
  150. INTRINSIC SQRT
  151. * ..
  152. * .. Executable Statements ..
  153. *
  154. * Test the input parameters.
  155. *
  156. WANTZ = LSAME( JOBZ, 'V' )
  157. *
  158. INFO = 0
  159. IF( .NOT.( WANTZ .OR. LSAME( JOBZ, 'N' ) ) ) THEN
  160. INFO = -1
  161. ELSE IF( N.LT.0 ) THEN
  162. INFO = -2
  163. ELSE IF( LDZ.LT.1 .OR. ( WANTZ .AND. LDZ.LT.N ) ) THEN
  164. INFO = -6
  165. END IF
  166. *
  167. IF( INFO.NE.0 ) THEN
  168. CALL XERBLA( 'SSTEV ', -INFO )
  169. RETURN
  170. END IF
  171. *
  172. * Quick return if possible
  173. *
  174. IF( N.EQ.0 )
  175. $ RETURN
  176. *
  177. IF( N.EQ.1 ) THEN
  178. IF( WANTZ )
  179. $ Z( 1, 1 ) = ONE
  180. RETURN
  181. END IF
  182. *
  183. * Get machine constants.
  184. *
  185. SAFMIN = SLAMCH( 'Safe minimum' )
  186. EPS = SLAMCH( 'Precision' )
  187. SMLNUM = SAFMIN / EPS
  188. BIGNUM = ONE / SMLNUM
  189. RMIN = SQRT( SMLNUM )
  190. RMAX = SQRT( BIGNUM )
  191. *
  192. * Scale matrix to allowable range, if necessary.
  193. *
  194. ISCALE = 0
  195. TNRM = SLANST( 'M', N, D, E )
  196. IF( TNRM.GT.ZERO .AND. TNRM.LT.RMIN ) THEN
  197. ISCALE = 1
  198. SIGMA = RMIN / TNRM
  199. ELSE IF( TNRM.GT.RMAX ) THEN
  200. ISCALE = 1
  201. SIGMA = RMAX / TNRM
  202. END IF
  203. IF( ISCALE.EQ.1 ) THEN
  204. CALL SSCAL( N, SIGMA, D, 1 )
  205. CALL SSCAL( N-1, SIGMA, E( 1 ), 1 )
  206. END IF
  207. *
  208. * For eigenvalues only, call SSTERF. For eigenvalues and
  209. * eigenvectors, call SSTEQR.
  210. *
  211. IF( .NOT.WANTZ ) THEN
  212. CALL SSTERF( N, D, E, INFO )
  213. ELSE
  214. CALL SSTEQR( 'I', N, D, E, Z, LDZ, WORK, INFO )
  215. END IF
  216. *
  217. * If matrix was scaled, then rescale eigenvalues appropriately.
  218. *
  219. IF( ISCALE.EQ.1 ) THEN
  220. IF( INFO.EQ.0 ) THEN
  221. IMAX = N
  222. ELSE
  223. IMAX = INFO - 1
  224. END IF
  225. CALL SSCAL( IMAX, ONE / SIGMA, D, 1 )
  226. END IF
  227. *
  228. RETURN
  229. *
  230. * End of SSTEV
  231. *
  232. END