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.

cstt22.f 7.4 kB

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