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.

ssbt21.f 7.7 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. *> \brief \b SSBT21
  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 SSBT21( UPLO, N, KA, KS, A, LDA, D, E, U, LDU, WORK,
  12. * RESULT )
  13. *
  14. * .. Scalar Arguments ..
  15. * CHARACTER UPLO
  16. * INTEGER KA, KS, LDA, LDU, N
  17. * ..
  18. * .. Array Arguments ..
  19. * REAL A( LDA, * ), D( * ), E( * ), RESULT( 2 ),
  20. * $ U( LDU, * ), WORK( * )
  21. * ..
  22. *
  23. *
  24. *> \par Purpose:
  25. * =============
  26. *>
  27. *> \verbatim
  28. *>
  29. *> SSBT21 generally checks a decomposition of the form
  30. *>
  31. *> A = U S U**T
  32. *>
  33. *> where **T means transpose, A is symmetric banded, U is
  34. *> orthogonal, and S is diagonal (if KS=0) or symmetric
  35. *> tridiagonal (if KS=1).
  36. *>
  37. *> Specifically:
  38. *>
  39. *> RESULT(1) = | A - U S U**T | / ( |A| n ulp ) and
  40. *> RESULT(2) = | I - U U**T | / ( n ulp )
  41. *> \endverbatim
  42. *
  43. * Arguments:
  44. * ==========
  45. *
  46. *> \param[in] UPLO
  47. *> \verbatim
  48. *> UPLO is CHARACTER
  49. *> If UPLO='U', the upper triangle of A and V will be used and
  50. *> the (strictly) lower triangle will not be referenced.
  51. *> If UPLO='L', the lower triangle of A and V will be used and
  52. *> the (strictly) upper triangle will not be referenced.
  53. *> \endverbatim
  54. *>
  55. *> \param[in] N
  56. *> \verbatim
  57. *> N is INTEGER
  58. *> The size of the matrix. If it is zero, SSBT21 does nothing.
  59. *> It must be at least zero.
  60. *> \endverbatim
  61. *>
  62. *> \param[in] KA
  63. *> \verbatim
  64. *> KA is INTEGER
  65. *> The bandwidth of the matrix A. It must be at least zero. If
  66. *> it is larger than N-1, then max( 0, N-1 ) will be used.
  67. *> \endverbatim
  68. *>
  69. *> \param[in] KS
  70. *> \verbatim
  71. *> KS is INTEGER
  72. *> The bandwidth of the matrix S. It may only be zero or one.
  73. *> If zero, then S is diagonal, and E is not referenced. If
  74. *> one, then S is symmetric tri-diagonal.
  75. *> \endverbatim
  76. *>
  77. *> \param[in] A
  78. *> \verbatim
  79. *> A is REAL array, dimension (LDA, N)
  80. *> The original (unfactored) matrix. It is assumed to be
  81. *> symmetric, and only the upper (UPLO='U') or only the lower
  82. *> (UPLO='L') will be referenced.
  83. *> \endverbatim
  84. *>
  85. *> \param[in] LDA
  86. *> \verbatim
  87. *> LDA is INTEGER
  88. *> The leading dimension of A. It must be at least 1
  89. *> and at least min( KA, N-1 ).
  90. *> \endverbatim
  91. *>
  92. *> \param[in] D
  93. *> \verbatim
  94. *> D is REAL array, dimension (N)
  95. *> The diagonal of the (symmetric tri-) diagonal matrix S.
  96. *> \endverbatim
  97. *>
  98. *> \param[in] E
  99. *> \verbatim
  100. *> E is REAL array, dimension (N-1)
  101. *> The off-diagonal of the (symmetric tri-) diagonal matrix S.
  102. *> E(1) is the (1,2) and (2,1) element, E(2) is the (2,3) and
  103. *> (3,2) element, etc.
  104. *> Not referenced if KS=0.
  105. *> \endverbatim
  106. *>
  107. *> \param[in] U
  108. *> \verbatim
  109. *> U is REAL array, dimension (LDU, N)
  110. *> The orthogonal matrix in the decomposition, expressed as a
  111. *> dense matrix (i.e., not as a product of Householder
  112. *> transformations, Givens transformations, etc.)
  113. *> \endverbatim
  114. *>
  115. *> \param[in] LDU
  116. *> \verbatim
  117. *> LDU is INTEGER
  118. *> The leading dimension of U. LDU must be at least N and
  119. *> at least 1.
  120. *> \endverbatim
  121. *>
  122. *> \param[out] WORK
  123. *> \verbatim
  124. *> WORK is REAL array, dimension (N**2+N)
  125. *> \endverbatim
  126. *>
  127. *> \param[out] RESULT
  128. *> \verbatim
  129. *> RESULT is REAL array, dimension (2)
  130. *> The values computed by the two tests described above. The
  131. *> values are currently limited to 1/ulp, to avoid overflow.
  132. *> \endverbatim
  133. *
  134. * Authors:
  135. * ========
  136. *
  137. *> \author Univ. of Tennessee
  138. *> \author Univ. of California Berkeley
  139. *> \author Univ. of Colorado Denver
  140. *> \author NAG Ltd.
  141. *
  142. *> \ingroup single_eig
  143. *
  144. * =====================================================================
  145. SUBROUTINE SSBT21( UPLO, N, KA, KS, A, LDA, D, E, U, LDU, WORK,
  146. $ RESULT )
  147. *
  148. * -- LAPACK test routine --
  149. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  150. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  151. *
  152. * .. Scalar Arguments ..
  153. CHARACTER UPLO
  154. INTEGER KA, KS, LDA, LDU, N
  155. * ..
  156. * .. Array Arguments ..
  157. REAL A( LDA, * ), D( * ), E( * ), RESULT( 2 ),
  158. $ U( LDU, * ), WORK( * )
  159. * ..
  160. *
  161. * =====================================================================
  162. *
  163. * .. Parameters ..
  164. REAL ZERO, ONE
  165. PARAMETER ( ZERO = 0.0E0, ONE = 1.0E0 )
  166. * ..
  167. * .. Local Scalars ..
  168. LOGICAL LOWER
  169. CHARACTER CUPLO
  170. INTEGER IKA, J, JC, JR, LW
  171. REAL ANORM, ULP, UNFL, WNORM
  172. * ..
  173. * .. External Functions ..
  174. LOGICAL LSAME
  175. REAL SLAMCH, SLANGE, SLANSB, SLANSP
  176. EXTERNAL LSAME, SLAMCH, SLANGE, SLANSB, SLANSP
  177. * ..
  178. * .. External Subroutines ..
  179. EXTERNAL SGEMM, SSPR, SSPR2
  180. * ..
  181. * .. Intrinsic Functions ..
  182. INTRINSIC MAX, MIN, REAL
  183. * ..
  184. * .. Executable Statements ..
  185. *
  186. * Constants
  187. *
  188. RESULT( 1 ) = ZERO
  189. RESULT( 2 ) = ZERO
  190. IF( N.LE.0 )
  191. $ RETURN
  192. *
  193. IKA = MAX( 0, MIN( N-1, KA ) )
  194. LW = ( N*( N+1 ) ) / 2
  195. *
  196. IF( LSAME( UPLO, 'U' ) ) THEN
  197. LOWER = .FALSE.
  198. CUPLO = 'U'
  199. ELSE
  200. LOWER = .TRUE.
  201. CUPLO = 'L'
  202. END IF
  203. *
  204. UNFL = SLAMCH( 'Safe minimum' )
  205. ULP = SLAMCH( 'Epsilon' )*SLAMCH( 'Base' )
  206. *
  207. * Some Error Checks
  208. *
  209. * Do Test 1
  210. *
  211. * Norm of A:
  212. *
  213. ANORM = MAX( SLANSB( '1', CUPLO, N, IKA, A, LDA, WORK ), UNFL )
  214. *
  215. * Compute error matrix: Error = A - U S U**T
  216. *
  217. * Copy A from SB to SP storage format.
  218. *
  219. J = 0
  220. DO 50 JC = 1, N
  221. IF( LOWER ) THEN
  222. DO 10 JR = 1, MIN( IKA+1, N+1-JC )
  223. J = J + 1
  224. WORK( J ) = A( JR, JC )
  225. 10 CONTINUE
  226. DO 20 JR = IKA + 2, N + 1 - JC
  227. J = J + 1
  228. WORK( J ) = ZERO
  229. 20 CONTINUE
  230. ELSE
  231. DO 30 JR = IKA + 2, JC
  232. J = J + 1
  233. WORK( J ) = ZERO
  234. 30 CONTINUE
  235. DO 40 JR = MIN( IKA, JC-1 ), 0, -1
  236. J = J + 1
  237. WORK( J ) = A( IKA+1-JR, JC )
  238. 40 CONTINUE
  239. END IF
  240. 50 CONTINUE
  241. *
  242. DO 60 J = 1, N
  243. CALL SSPR( CUPLO, N, -D( J ), U( 1, J ), 1, WORK )
  244. 60 CONTINUE
  245. *
  246. IF( N.GT.1 .AND. KS.EQ.1 ) THEN
  247. DO 70 J = 1, N - 1
  248. CALL SSPR2( CUPLO, N, -E( J ), U( 1, J ), 1, U( 1, J+1 ), 1,
  249. $ WORK )
  250. 70 CONTINUE
  251. END IF
  252. WNORM = SLANSP( '1', CUPLO, N, WORK, WORK( LW+1 ) )
  253. *
  254. IF( ANORM.GT.WNORM ) THEN
  255. RESULT( 1 ) = ( WNORM / ANORM ) / ( N*ULP )
  256. ELSE
  257. IF( ANORM.LT.ONE ) THEN
  258. RESULT( 1 ) = ( MIN( WNORM, N*ANORM ) / ANORM ) / ( N*ULP )
  259. ELSE
  260. RESULT( 1 ) = MIN( WNORM / ANORM, REAL( N ) ) / ( N*ULP )
  261. END IF
  262. END IF
  263. *
  264. * Do Test 2
  265. *
  266. * Compute U U**T - I
  267. *
  268. CALL SGEMM( 'N', 'C', N, N, N, ONE, U, LDU, U, LDU, ZERO, WORK,
  269. $ N )
  270. *
  271. DO 80 J = 1, N
  272. WORK( ( N+1 )*( J-1 )+1 ) = WORK( ( N+1 )*( J-1 )+1 ) - ONE
  273. 80 CONTINUE
  274. *
  275. RESULT( 2 ) = MIN( SLANGE( '1', N, N, WORK, N, WORK( N**2+1 ) ),
  276. $ REAL( N ) ) / ( N*ULP )
  277. *
  278. RETURN
  279. *
  280. * End of SSBT21
  281. *
  282. END