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.

shst01.f 5.8 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. *> \brief \b SHST01
  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 SHST01( N, ILO, IHI, A, LDA, H, LDH, Q, LDQ, WORK,
  12. * LWORK, RESULT )
  13. *
  14. * .. Scalar Arguments ..
  15. * INTEGER IHI, ILO, LDA, LDH, LDQ, LWORK, N
  16. * ..
  17. * .. Array Arguments ..
  18. * REAL A( LDA, * ), H( LDH, * ), Q( LDQ, * ),
  19. * $ RESULT( 2 ), WORK( LWORK )
  20. * ..
  21. *
  22. *
  23. *> \par Purpose:
  24. * =============
  25. *>
  26. *> \verbatim
  27. *>
  28. *> SHST01 tests the reduction of a general matrix A to upper Hessenberg
  29. *> form: A = Q*H*Q'. Two test ratios are computed;
  30. *>
  31. *> RESULT(1) = norm( A - Q*H*Q' ) / ( norm(A) * N * EPS )
  32. *> RESULT(2) = norm( I - Q'*Q ) / ( N * EPS )
  33. *>
  34. *> The matrix Q is assumed to be given explicitly as it would be
  35. *> following SGEHRD + SORGHR.
  36. *>
  37. *> In this version, ILO and IHI are not used and are assumed to be 1 and
  38. *> N, respectively.
  39. *> \endverbatim
  40. *
  41. * Arguments:
  42. * ==========
  43. *
  44. *> \param[in] N
  45. *> \verbatim
  46. *> N is INTEGER
  47. *> The order of the matrix A. N >= 0.
  48. *> \endverbatim
  49. *>
  50. *> \param[in] ILO
  51. *> \verbatim
  52. *> ILO is INTEGER
  53. *> \endverbatim
  54. *>
  55. *> \param[in] IHI
  56. *> \verbatim
  57. *> IHI is INTEGER
  58. *>
  59. *> A is assumed to be upper triangular in rows and columns
  60. *> 1:ILO-1 and IHI+1:N, so Q differs from the identity only in
  61. *> rows and columns ILO+1:IHI.
  62. *> \endverbatim
  63. *>
  64. *> \param[in] A
  65. *> \verbatim
  66. *> A is REAL array, dimension (LDA,N)
  67. *> The original n by n matrix A.
  68. *> \endverbatim
  69. *>
  70. *> \param[in] LDA
  71. *> \verbatim
  72. *> LDA is INTEGER
  73. *> The leading dimension of the array A. LDA >= max(1,N).
  74. *> \endverbatim
  75. *>
  76. *> \param[in] H
  77. *> \verbatim
  78. *> H is REAL array, dimension (LDH,N)
  79. *> The upper Hessenberg matrix H from the reduction A = Q*H*Q'
  80. *> as computed by SGEHRD. H is assumed to be zero below the
  81. *> first subdiagonal.
  82. *> \endverbatim
  83. *>
  84. *> \param[in] LDH
  85. *> \verbatim
  86. *> LDH is INTEGER
  87. *> The leading dimension of the array H. LDH >= max(1,N).
  88. *> \endverbatim
  89. *>
  90. *> \param[in] Q
  91. *> \verbatim
  92. *> Q is REAL array, dimension (LDQ,N)
  93. *> The orthogonal matrix Q from the reduction A = Q*H*Q' as
  94. *> computed by SGEHRD + SORGHR.
  95. *> \endverbatim
  96. *>
  97. *> \param[in] LDQ
  98. *> \verbatim
  99. *> LDQ is INTEGER
  100. *> The leading dimension of the array Q. LDQ >= max(1,N).
  101. *> \endverbatim
  102. *>
  103. *> \param[out] WORK
  104. *> \verbatim
  105. *> WORK is REAL array, dimension (LWORK)
  106. *> \endverbatim
  107. *>
  108. *> \param[in] LWORK
  109. *> \verbatim
  110. *> LWORK is INTEGER
  111. *> The length of the array WORK. LWORK >= 2*N*N.
  112. *> \endverbatim
  113. *>
  114. *> \param[out] RESULT
  115. *> \verbatim
  116. *> RESULT is REAL array, dimension (2)
  117. *> RESULT(1) = norm( A - Q*H*Q' ) / ( norm(A) * N * EPS )
  118. *> RESULT(2) = norm( I - Q'*Q ) / ( N * EPS )
  119. *> \endverbatim
  120. *
  121. * Authors:
  122. * ========
  123. *
  124. *> \author Univ. of Tennessee
  125. *> \author Univ. of California Berkeley
  126. *> \author Univ. of Colorado Denver
  127. *> \author NAG Ltd.
  128. *
  129. *> \ingroup single_eig
  130. *
  131. * =====================================================================
  132. SUBROUTINE SHST01( N, ILO, IHI, A, LDA, H, LDH, Q, LDQ, WORK,
  133. $ LWORK, RESULT )
  134. *
  135. * -- LAPACK test routine --
  136. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  137. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  138. *
  139. * .. Scalar Arguments ..
  140. INTEGER IHI, ILO, LDA, LDH, LDQ, LWORK, N
  141. * ..
  142. * .. Array Arguments ..
  143. REAL A( LDA, * ), H( LDH, * ), Q( LDQ, * ),
  144. $ RESULT( 2 ), WORK( LWORK )
  145. * ..
  146. *
  147. * =====================================================================
  148. *
  149. * .. Parameters ..
  150. REAL ONE, ZERO
  151. PARAMETER ( ONE = 1.0E+0, ZERO = 0.0E+0 )
  152. * ..
  153. * .. Local Scalars ..
  154. INTEGER LDWORK
  155. REAL ANORM, EPS, OVFL, SMLNUM, UNFL, WNORM
  156. * ..
  157. * .. External Functions ..
  158. REAL SLAMCH, SLANGE
  159. EXTERNAL SLAMCH, SLANGE
  160. * ..
  161. * .. External Subroutines ..
  162. EXTERNAL SGEMM, SLABAD, SLACPY, SORT01
  163. * ..
  164. * .. Intrinsic Functions ..
  165. INTRINSIC MAX, MIN
  166. * ..
  167. * .. Executable Statements ..
  168. *
  169. * Quick return if possible
  170. *
  171. IF( N.LE.0 ) THEN
  172. RESULT( 1 ) = ZERO
  173. RESULT( 2 ) = ZERO
  174. RETURN
  175. END IF
  176. *
  177. UNFL = SLAMCH( 'Safe minimum' )
  178. EPS = SLAMCH( 'Precision' )
  179. OVFL = ONE / UNFL
  180. CALL SLABAD( UNFL, OVFL )
  181. SMLNUM = UNFL*N / EPS
  182. *
  183. * Test 1: Compute norm( A - Q*H*Q' ) / ( norm(A) * N * EPS )
  184. *
  185. * Copy A to WORK
  186. *
  187. LDWORK = MAX( 1, N )
  188. CALL SLACPY( ' ', N, N, A, LDA, WORK, LDWORK )
  189. *
  190. * Compute Q*H
  191. *
  192. CALL SGEMM( 'No transpose', 'No transpose', N, N, N, ONE, Q, LDQ,
  193. $ H, LDH, ZERO, WORK( LDWORK*N+1 ), LDWORK )
  194. *
  195. * Compute A - Q*H*Q'
  196. *
  197. CALL SGEMM( 'No transpose', 'Transpose', N, N, N, -ONE,
  198. $ WORK( LDWORK*N+1 ), LDWORK, Q, LDQ, ONE, WORK,
  199. $ LDWORK )
  200. *
  201. ANORM = MAX( SLANGE( '1', N, N, A, LDA, WORK( LDWORK*N+1 ) ),
  202. $ UNFL )
  203. WNORM = SLANGE( '1', N, N, WORK, LDWORK, WORK( LDWORK*N+1 ) )
  204. *
  205. * Note that RESULT(1) cannot overflow and is bounded by 1/(N*EPS)
  206. *
  207. RESULT( 1 ) = MIN( WNORM, ANORM ) / MAX( SMLNUM, ANORM*EPS ) / N
  208. *
  209. * Test 2: Compute norm( I - Q'*Q ) / ( N * EPS )
  210. *
  211. CALL SORT01( 'Columns', N, N, Q, LDQ, WORK, LWORK, RESULT( 2 ) )
  212. *
  213. RETURN
  214. *
  215. * End of SHST01
  216. *
  217. END