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.

dstech.f 6.0 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. *> \brief \b DSTECH
  2. *
  3. * =========== DOCUMENTATION ===========
  4. *
  5. * Online html documentation available at
  6. * http://www.netlib.org/lapack/explore-html/
  7. *
  8. * Definition:
  9. * ===========
  10. *
  11. * SUBROUTINE DSTECH( N, A, B, EIG, TOL, WORK, INFO )
  12. *
  13. * .. Scalar Arguments ..
  14. * INTEGER INFO, N
  15. * DOUBLE PRECISION TOL
  16. * ..
  17. * .. Array Arguments ..
  18. * DOUBLE PRECISION A( * ), B( * ), EIG( * ), WORK( * )
  19. * ..
  20. *
  21. *
  22. *> \par Purpose:
  23. * =============
  24. *>
  25. *> \verbatim
  26. *>
  27. *> Let T be the tridiagonal matrix with diagonal entries A(1) ,...,
  28. *> A(N) and offdiagonal entries B(1) ,..., B(N-1)). DSTECH checks to
  29. *> see if EIG(1) ,..., EIG(N) are indeed accurate eigenvalues of T.
  30. *> It does this by expanding each EIG(I) into an interval
  31. *> [SVD(I) - EPS, SVD(I) + EPS], merging overlapping intervals if
  32. *> any, and using Sturm sequences to count and verify whether each
  33. *> resulting interval has the correct number of eigenvalues (using
  34. *> DSTECT). Here EPS = TOL*MAZHEPS*MAXEIG, where MACHEPS is the
  35. *> machine precision and MAXEIG is the absolute value of the largest
  36. *> eigenvalue. If each interval contains the correct number of
  37. *> eigenvalues, INFO = 0 is returned, otherwise INFO is the index of
  38. *> the first eigenvalue in the first bad interval.
  39. *> \endverbatim
  40. *
  41. * Arguments:
  42. * ==========
  43. *
  44. *> \param[in] N
  45. *> \verbatim
  46. *> N is INTEGER
  47. *> The dimension of the tridiagonal matrix T.
  48. *> \endverbatim
  49. *>
  50. *> \param[in] A
  51. *> \verbatim
  52. *> A is DOUBLE PRECISION array, dimension (N)
  53. *> The diagonal entries of the tridiagonal matrix T.
  54. *> \endverbatim
  55. *>
  56. *> \param[in] B
  57. *> \verbatim
  58. *> B is DOUBLE PRECISION array, dimension (N-1)
  59. *> The offdiagonal entries of the tridiagonal matrix T.
  60. *> \endverbatim
  61. *>
  62. *> \param[in] EIG
  63. *> \verbatim
  64. *> EIG is DOUBLE PRECISION array, dimension (N)
  65. *> The purported eigenvalues to be checked.
  66. *> \endverbatim
  67. *>
  68. *> \param[in] TOL
  69. *> \verbatim
  70. *> TOL is DOUBLE PRECISION
  71. *> Error tolerance for checking, a multiple of the
  72. *> machine precision.
  73. *> \endverbatim
  74. *>
  75. *> \param[out] WORK
  76. *> \verbatim
  77. *> WORK is DOUBLE PRECISION array, dimension (N)
  78. *> \endverbatim
  79. *>
  80. *> \param[out] INFO
  81. *> \verbatim
  82. *> INFO is INTEGER
  83. *> 0 if the eigenvalues are all correct (to within
  84. *> 1 +- TOL*MAZHEPS*MAXEIG)
  85. *> >0 if the interval containing the INFO-th eigenvalue
  86. *> contains the incorrect number of eigenvalues.
  87. *> \endverbatim
  88. *
  89. * Authors:
  90. * ========
  91. *
  92. *> \author Univ. of Tennessee
  93. *> \author Univ. of California Berkeley
  94. *> \author Univ. of Colorado Denver
  95. *> \author NAG Ltd.
  96. *
  97. *> \ingroup double_eig
  98. *
  99. * =====================================================================
  100. SUBROUTINE DSTECH( N, A, B, EIG, TOL, WORK, INFO )
  101. *
  102. * -- LAPACK test routine --
  103. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  104. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  105. *
  106. * .. Scalar Arguments ..
  107. INTEGER INFO, N
  108. DOUBLE PRECISION TOL
  109. * ..
  110. * .. Array Arguments ..
  111. DOUBLE PRECISION A( * ), B( * ), EIG( * ), WORK( * )
  112. * ..
  113. *
  114. * =====================================================================
  115. *
  116. * .. Parameters ..
  117. DOUBLE PRECISION ZERO
  118. PARAMETER ( ZERO = 0.0D0 )
  119. * ..
  120. * .. Local Scalars ..
  121. INTEGER BPNT, COUNT, I, ISUB, J, NUML, NUMU, TPNT
  122. DOUBLE PRECISION EMIN, EPS, LOWER, MX, TUPPR, UNFLEP, UPPER
  123. * ..
  124. * .. External Functions ..
  125. DOUBLE PRECISION DLAMCH
  126. EXTERNAL DLAMCH
  127. * ..
  128. * .. External Subroutines ..
  129. EXTERNAL DSTECT
  130. * ..
  131. * .. Intrinsic Functions ..
  132. INTRINSIC ABS, MAX
  133. * ..
  134. * .. Executable Statements ..
  135. *
  136. * Check input parameters
  137. *
  138. INFO = 0
  139. IF( N.EQ.0 )
  140. $ RETURN
  141. IF( N.LT.0 ) THEN
  142. INFO = -1
  143. RETURN
  144. END IF
  145. IF( TOL.LT.ZERO ) THEN
  146. INFO = -5
  147. RETURN
  148. END IF
  149. *
  150. * Get machine constants
  151. *
  152. EPS = DLAMCH( 'Epsilon' )*DLAMCH( 'Base' )
  153. UNFLEP = DLAMCH( 'Safe minimum' ) / EPS
  154. EPS = TOL*EPS
  155. *
  156. * Compute maximum absolute eigenvalue, error tolerance
  157. *
  158. MX = ABS( EIG( 1 ) )
  159. DO 10 I = 2, N
  160. MX = MAX( MX, ABS( EIG( I ) ) )
  161. 10 CONTINUE
  162. EPS = MAX( EPS*MX, UNFLEP )
  163. *
  164. * Sort eigenvalues from EIG into WORK
  165. *
  166. DO 20 I = 1, N
  167. WORK( I ) = EIG( I )
  168. 20 CONTINUE
  169. DO 40 I = 1, N - 1
  170. ISUB = 1
  171. EMIN = WORK( 1 )
  172. DO 30 J = 2, N + 1 - I
  173. IF( WORK( J ).LT.EMIN ) THEN
  174. ISUB = J
  175. EMIN = WORK( J )
  176. END IF
  177. 30 CONTINUE
  178. IF( ISUB.NE.N+1-I ) THEN
  179. WORK( ISUB ) = WORK( N+1-I )
  180. WORK( N+1-I ) = EMIN
  181. END IF
  182. 40 CONTINUE
  183. *
  184. * TPNT points to singular value at right endpoint of interval
  185. * BPNT points to singular value at left endpoint of interval
  186. *
  187. TPNT = 1
  188. BPNT = 1
  189. *
  190. * Begin loop over all intervals
  191. *
  192. 50 CONTINUE
  193. UPPER = WORK( TPNT ) + EPS
  194. LOWER = WORK( BPNT ) - EPS
  195. *
  196. * Begin loop merging overlapping intervals
  197. *
  198. 60 CONTINUE
  199. IF( BPNT.EQ.N )
  200. $ GO TO 70
  201. TUPPR = WORK( BPNT+1 ) + EPS
  202. IF( TUPPR.LT.LOWER )
  203. $ GO TO 70
  204. *
  205. * Merge
  206. *
  207. BPNT = BPNT + 1
  208. LOWER = WORK( BPNT ) - EPS
  209. GO TO 60
  210. 70 CONTINUE
  211. *
  212. * Count singular values in interval [ LOWER, UPPER ]
  213. *
  214. CALL DSTECT( N, A, B, LOWER, NUML )
  215. CALL DSTECT( N, A, B, UPPER, NUMU )
  216. COUNT = NUMU - NUML
  217. IF( COUNT.NE.BPNT-TPNT+1 ) THEN
  218. *
  219. * Wrong number of singular values in interval
  220. *
  221. INFO = TPNT
  222. GO TO 80
  223. END IF
  224. TPNT = BPNT + 1
  225. BPNT = TPNT
  226. IF( TPNT.LE.N )
  227. $ GO TO 50
  228. 80 CONTINUE
  229. RETURN
  230. *
  231. * End of DSTECH
  232. *
  233. END