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.

ssvdct.f 5.3 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. *> \brief \b SSVDCT
  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 SSVDCT( N, S, E, SHIFT, NUM )
  12. *
  13. * .. Scalar Arguments ..
  14. * INTEGER N, NUM
  15. * REAL SHIFT
  16. * ..
  17. * .. Array Arguments ..
  18. * REAL E( * ), S( * )
  19. * ..
  20. *
  21. *
  22. *> \par Purpose:
  23. * =============
  24. *>
  25. *> \verbatim
  26. *>
  27. *> SSVDCT counts the number NUM of eigenvalues of a 2*N by 2*N
  28. *> tridiagonal matrix T which are less than or equal to SHIFT. T is
  29. *> formed by putting zeros on the diagonal and making the off-diagonals
  30. *> equal to S(1), E(1), S(2), E(2), ... , E(N-1), S(N). If SHIFT is
  31. *> positive, NUM is equal to N plus the number of singular values of a
  32. *> bidiagonal matrix B less than or equal to SHIFT. Here B has diagonal
  33. *> entries S(1), ..., S(N) and superdiagonal entries E(1), ... E(N-1).
  34. *> If SHIFT is negative, NUM is equal to the number of singular values
  35. *> of B greater than or equal to -SHIFT.
  36. *>
  37. *> See W. Kahan "Accurate Eigenvalues of a Symmetric Tridiagonal
  38. *> Matrix", Report CS41, Computer Science Dept., Stanford University,
  39. *> July 21, 1966
  40. *> \endverbatim
  41. *
  42. * Arguments:
  43. * ==========
  44. *
  45. *> \param[in] N
  46. *> \verbatim
  47. *> N is INTEGER
  48. *> The dimension of the bidiagonal matrix B.
  49. *> \endverbatim
  50. *>
  51. *> \param[in] S
  52. *> \verbatim
  53. *> S is REAL array, dimension (N)
  54. *> The diagonal entries of the bidiagonal matrix B.
  55. *> \endverbatim
  56. *>
  57. *> \param[in] E
  58. *> \verbatim
  59. *> E is REAL array of dimension (N-1)
  60. *> The superdiagonal entries of the bidiagonal matrix B.
  61. *> \endverbatim
  62. *>
  63. *> \param[in] SHIFT
  64. *> \verbatim
  65. *> SHIFT is REAL
  66. *> The shift, used as described under Purpose.
  67. *> \endverbatim
  68. *>
  69. *> \param[out] NUM
  70. *> \verbatim
  71. *> NUM is INTEGER
  72. *> The number of eigenvalues of T less than or equal to SHIFT.
  73. *> \endverbatim
  74. *
  75. * Authors:
  76. * ========
  77. *
  78. *> \author Univ. of Tennessee
  79. *> \author Univ. of California Berkeley
  80. *> \author Univ. of Colorado Denver
  81. *> \author NAG Ltd.
  82. *
  83. *> \ingroup single_eig
  84. *
  85. * =====================================================================
  86. SUBROUTINE SSVDCT( N, S, E, SHIFT, NUM )
  87. *
  88. * -- LAPACK test routine --
  89. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  90. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  91. *
  92. * .. Scalar Arguments ..
  93. INTEGER N, NUM
  94. REAL SHIFT
  95. * ..
  96. * .. Array Arguments ..
  97. REAL E( * ), S( * )
  98. * ..
  99. *
  100. * =====================================================================
  101. *
  102. * .. Parameters ..
  103. REAL ONE
  104. PARAMETER ( ONE = 1.0E0 )
  105. REAL ZERO
  106. PARAMETER ( ZERO = 0.0E0 )
  107. * ..
  108. * .. Local Scalars ..
  109. INTEGER I
  110. REAL M1, M2, MX, OVFL, SOV, SSHIFT, SSUN, SUN, TMP,
  111. $ TOM, U, UNFL
  112. * ..
  113. * .. External Functions ..
  114. REAL SLAMCH
  115. EXTERNAL SLAMCH
  116. * ..
  117. * .. Intrinsic Functions ..
  118. INTRINSIC ABS, MAX, SQRT
  119. * ..
  120. * .. Executable Statements ..
  121. *
  122. * Get machine constants
  123. *
  124. UNFL = 2*SLAMCH( 'Safe minimum' )
  125. OVFL = ONE / UNFL
  126. *
  127. * Find largest entry
  128. *
  129. MX = ABS( S( 1 ) )
  130. DO 10 I = 1, N - 1
  131. MX = MAX( MX, ABS( S( I+1 ) ), ABS( E( I ) ) )
  132. 10 CONTINUE
  133. *
  134. IF( MX.EQ.ZERO ) THEN
  135. IF( SHIFT.LT.ZERO ) THEN
  136. NUM = 0
  137. ELSE
  138. NUM = 2*N
  139. END IF
  140. RETURN
  141. END IF
  142. *
  143. * Compute scale factors as in Kahan's report
  144. *
  145. SUN = SQRT( UNFL )
  146. SSUN = SQRT( SUN )
  147. SOV = SQRT( OVFL )
  148. TOM = SSUN*SOV
  149. IF( MX.LE.ONE ) THEN
  150. M1 = ONE / MX
  151. M2 = TOM
  152. ELSE
  153. M1 = ONE
  154. M2 = TOM / MX
  155. END IF
  156. *
  157. * Begin counting
  158. *
  159. U = ONE
  160. NUM = 0
  161. SSHIFT = ( SHIFT*M1 )*M2
  162. U = -SSHIFT
  163. IF( U.LE.SUN ) THEN
  164. IF( U.LE.ZERO ) THEN
  165. NUM = NUM + 1
  166. IF( U.GT.-SUN )
  167. $ U = -SUN
  168. ELSE
  169. U = SUN
  170. END IF
  171. END IF
  172. TMP = ( S( 1 )*M1 )*M2
  173. U = -TMP*( TMP / U ) - SSHIFT
  174. IF( U.LE.SUN ) THEN
  175. IF( U.LE.ZERO ) THEN
  176. NUM = NUM + 1
  177. IF( U.GT.-SUN )
  178. $ U = -SUN
  179. ELSE
  180. U = SUN
  181. END IF
  182. END IF
  183. DO 20 I = 1, N - 1
  184. TMP = ( E( I )*M1 )*M2
  185. U = -TMP*( TMP / U ) - SSHIFT
  186. IF( U.LE.SUN ) THEN
  187. IF( U.LE.ZERO ) THEN
  188. NUM = NUM + 1
  189. IF( U.GT.-SUN )
  190. $ U = -SUN
  191. ELSE
  192. U = SUN
  193. END IF
  194. END IF
  195. TMP = ( S( I+1 )*M1 )*M2
  196. U = -TMP*( TMP / U ) - SSHIFT
  197. IF( U.LE.SUN ) THEN
  198. IF( U.LE.ZERO ) THEN
  199. NUM = NUM + 1
  200. IF( U.GT.-SUN )
  201. $ U = -SUN
  202. ELSE
  203. U = SUN
  204. END IF
  205. END IF
  206. 20 CONTINUE
  207. RETURN
  208. *
  209. * End of SSVDCT
  210. *
  211. END