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.

cstt21.f 6.8 kB

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