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.

sstt22.f 7.0 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. *> \brief \b SSTT22
  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 SSTT22( N, M, KBAND, AD, AE, SD, SE, U, LDU, WORK,
  12. * LDWORK, RESULT )
  13. *
  14. * .. Scalar Arguments ..
  15. * INTEGER KBAND, LDU, LDWORK, M, N
  16. * ..
  17. * .. Array Arguments ..
  18. * REAL AD( * ), AE( * ), RESULT( 2 ), SD( * ),
  19. * $ SE( * ), U( LDU, * ), WORK( LDWORK, * )
  20. * ..
  21. *
  22. *
  23. *> \par Purpose:
  24. * =============
  25. *>
  26. *> \verbatim
  27. *>
  28. *> SSTT22 checks a set of M eigenvalues and eigenvectors,
  29. *>
  30. *> A U = U S
  31. *>
  32. *> where A is symmetric tridiagonal, the columns of U are orthogonal,
  33. *> and S is diagonal (if KBAND=0) or symmetric tridiagonal (if KBAND=1).
  34. *> Two tests are performed:
  35. *>
  36. *> RESULT(1) = | U' A U - S | / ( |A| m ulp )
  37. *>
  38. *> RESULT(2) = | I - U'U | / ( m ulp )
  39. *> \endverbatim
  40. *
  41. * Arguments:
  42. * ==========
  43. *
  44. *> \param[in] N
  45. *> \verbatim
  46. *> N is INTEGER
  47. *> The size of the matrix. If it is zero, SSTT22 does nothing.
  48. *> It must be at least zero.
  49. *> \endverbatim
  50. *>
  51. *> \param[in] M
  52. *> \verbatim
  53. *> M is INTEGER
  54. *> The number of eigenpairs to check. If it is zero, SSTT22
  55. *> does nothing. It must be at least zero.
  56. *> \endverbatim
  57. *>
  58. *> \param[in] KBAND
  59. *> \verbatim
  60. *> KBAND is INTEGER
  61. *> The bandwidth of the matrix S. It may only be zero or one.
  62. *> If zero, then S is diagonal, and SE is not referenced. If
  63. *> one, then S is symmetric tri-diagonal.
  64. *> \endverbatim
  65. *>
  66. *> \param[in] AD
  67. *> \verbatim
  68. *> AD is REAL array, dimension (N)
  69. *> The diagonal of the original (unfactored) matrix A. A is
  70. *> assumed to be symmetric tridiagonal.
  71. *> \endverbatim
  72. *>
  73. *> \param[in] AE
  74. *> \verbatim
  75. *> AE is REAL array, dimension (N)
  76. *> The off-diagonal of the original (unfactored) matrix A. A
  77. *> is assumed to be symmetric tridiagonal. AE(1) is ignored,
  78. *> AE(2) is the (1,2) and (2,1) element, etc.
  79. *> \endverbatim
  80. *>
  81. *> \param[in] SD
  82. *> \verbatim
  83. *> SD is REAL array, dimension (N)
  84. *> The diagonal of the (symmetric tri-) diagonal matrix S.
  85. *> \endverbatim
  86. *>
  87. *> \param[in] SE
  88. *> \verbatim
  89. *> SE is REAL array, dimension (N)
  90. *> The off-diagonal of the (symmetric tri-) diagonal matrix S.
  91. *> Not referenced if KBSND=0. If KBAND=1, then AE(1) is
  92. *> ignored, SE(2) is the (1,2) and (2,1) element, etc.
  93. *> \endverbatim
  94. *>
  95. *> \param[in] U
  96. *> \verbatim
  97. *> U is REAL array, dimension (LDU, N)
  98. *> The orthogonal matrix in the decomposition.
  99. *> \endverbatim
  100. *>
  101. *> \param[in] LDU
  102. *> \verbatim
  103. *> LDU is INTEGER
  104. *> The leading dimension of U. LDU must be at least N.
  105. *> \endverbatim
  106. *>
  107. *> \param[out] WORK
  108. *> \verbatim
  109. *> WORK is REAL array, dimension (LDWORK, M+1)
  110. *> \endverbatim
  111. *>
  112. *> \param[in] LDWORK
  113. *> \verbatim
  114. *> LDWORK is INTEGER
  115. *> The leading dimension of WORK. LDWORK must be at least
  116. *> max(1,M).
  117. *> \endverbatim
  118. *>
  119. *> \param[out] RESULT
  120. *> \verbatim
  121. *> RESULT is REAL array, dimension (2)
  122. *> The values computed by the two tests described above. The
  123. *> values are currently limited to 1/ulp, to avoid overflow.
  124. *> \endverbatim
  125. *
  126. * Authors:
  127. * ========
  128. *
  129. *> \author Univ. of Tennessee
  130. *> \author Univ. of California Berkeley
  131. *> \author Univ. of Colorado Denver
  132. *> \author NAG Ltd.
  133. *
  134. *> \ingroup single_eig
  135. *
  136. * =====================================================================
  137. SUBROUTINE SSTT22( N, M, KBAND, AD, AE, SD, SE, U, LDU, WORK,
  138. $ LDWORK, RESULT )
  139. *
  140. * -- LAPACK test routine --
  141. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  142. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  143. *
  144. * .. Scalar Arguments ..
  145. INTEGER KBAND, LDU, LDWORK, M, N
  146. * ..
  147. * .. Array Arguments ..
  148. REAL AD( * ), AE( * ), RESULT( 2 ), SD( * ),
  149. $ SE( * ), U( LDU, * ), WORK( LDWORK, * )
  150. * ..
  151. *
  152. * =====================================================================
  153. *
  154. * .. Parameters ..
  155. REAL ZERO, ONE
  156. PARAMETER ( ZERO = 0.0E0, ONE = 1.0E0 )
  157. * ..
  158. * .. Local Scalars ..
  159. INTEGER I, J, K
  160. REAL ANORM, AUKJ, ULP, UNFL, WNORM
  161. * ..
  162. * .. External Functions ..
  163. REAL SLAMCH, SLANGE, SLANSY
  164. EXTERNAL SLAMCH, SLANGE, SLANSY
  165. * ..
  166. * .. External Subroutines ..
  167. EXTERNAL SGEMM
  168. * ..
  169. * .. Intrinsic Functions ..
  170. INTRINSIC ABS, MAX, MIN, REAL
  171. * ..
  172. * .. Executable Statements ..
  173. *
  174. RESULT( 1 ) = ZERO
  175. RESULT( 2 ) = ZERO
  176. IF( N.LE.0 .OR. M.LE.0 )
  177. $ RETURN
  178. *
  179. UNFL = SLAMCH( 'Safe minimum' )
  180. ULP = SLAMCH( 'Epsilon' )
  181. *
  182. * Do Test 1
  183. *
  184. * Compute the 1-norm of A.
  185. *
  186. IF( N.GT.1 ) THEN
  187. ANORM = ABS( AD( 1 ) ) + ABS( AE( 1 ) )
  188. DO 10 J = 2, N - 1
  189. ANORM = MAX( ANORM, ABS( AD( J ) )+ABS( AE( J ) )+
  190. $ ABS( AE( J-1 ) ) )
  191. 10 CONTINUE
  192. ANORM = MAX( ANORM, ABS( AD( N ) )+ABS( AE( N-1 ) ) )
  193. ELSE
  194. ANORM = ABS( AD( 1 ) )
  195. END IF
  196. ANORM = MAX( ANORM, UNFL )
  197. *
  198. * Norm of U'AU - S
  199. *
  200. DO 40 I = 1, M
  201. DO 30 J = 1, M
  202. WORK( I, J ) = ZERO
  203. DO 20 K = 1, N
  204. AUKJ = AD( K )*U( K, J )
  205. IF( K.NE.N )
  206. $ AUKJ = AUKJ + AE( K )*U( K+1, J )
  207. IF( K.NE.1 )
  208. $ AUKJ = AUKJ + AE( K-1 )*U( K-1, J )
  209. WORK( I, J ) = WORK( I, J ) + U( K, I )*AUKJ
  210. 20 CONTINUE
  211. 30 CONTINUE
  212. WORK( I, I ) = WORK( I, I ) - SD( I )
  213. IF( KBAND.EQ.1 ) THEN
  214. IF( I.NE.1 )
  215. $ WORK( I, I-1 ) = WORK( I, I-1 ) - SE( I-1 )
  216. IF( I.NE.N )
  217. $ WORK( I, I+1 ) = WORK( I, I+1 ) - SE( I )
  218. END IF
  219. 40 CONTINUE
  220. *
  221. WNORM = SLANSY( '1', 'L', M, WORK, M, WORK( 1, M+1 ) )
  222. *
  223. IF( ANORM.GT.WNORM ) THEN
  224. RESULT( 1 ) = ( WNORM / ANORM ) / ( M*ULP )
  225. ELSE
  226. IF( ANORM.LT.ONE ) THEN
  227. RESULT( 1 ) = ( MIN( WNORM, M*ANORM ) / ANORM ) / ( M*ULP )
  228. ELSE
  229. RESULT( 1 ) = MIN( WNORM / ANORM, REAL( M ) ) / ( M*ULP )
  230. END IF
  231. END IF
  232. *
  233. * Do Test 2
  234. *
  235. * Compute U'U - I
  236. *
  237. CALL SGEMM( 'T', 'N', M, M, N, ONE, U, LDU, U, LDU, ZERO, WORK,
  238. $ M )
  239. *
  240. DO 50 J = 1, M
  241. WORK( J, J ) = WORK( J, J ) - ONE
  242. 50 CONTINUE
  243. *
  244. RESULT( 2 ) = MIN( REAL( M ), SLANGE( '1', M, M, WORK, M, WORK( 1,
  245. $ M+1 ) ) ) / ( M*ULP )
  246. *
  247. RETURN
  248. *
  249. * End of SSTT22
  250. *
  251. END