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.

chet22.f 8.4 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. *> \brief \b CHET22
  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 CHET22( ITYPE, UPLO, N, M, KBAND, A, LDA, D, E, U, LDU,
  12. * V, LDV, TAU, WORK, RWORK, RESULT )
  13. *
  14. * .. Scalar Arguments ..
  15. * CHARACTER UPLO
  16. * INTEGER ITYPE, KBAND, LDA, LDU, LDV, M, N
  17. * ..
  18. * .. Array Arguments ..
  19. * REAL D( * ), E( * ), RESULT( 2 ), RWORK( * )
  20. * COMPLEX A( LDA, * ), TAU( * ), U( LDU, * ),
  21. * $ V( LDV, * ), WORK( * )
  22. * ..
  23. *
  24. *
  25. *> \par Purpose:
  26. * =============
  27. *>
  28. *> \verbatim
  29. *>
  30. *> CHET22 generally checks a decomposition of the form
  31. *>
  32. *> A U = U S
  33. *>
  34. *> where A is complex Hermitian, the columns of U are orthonormal,
  35. *> and S is diagonal (if KBAND=0) or symmetric tridiagonal (if
  36. *> KBAND=1). If ITYPE=1, then U is represented as a dense matrix,
  37. *> otherwise the U is expressed as a product of Householder
  38. *> transformations, whose vectors are stored in the array "V" and
  39. *> whose scaling constants are in "TAU"; we shall use the letter
  40. *> "V" to refer to the product of Householder transformations
  41. *> (which should be equal to U).
  42. *>
  43. *> Specifically, if ITYPE=1, then:
  44. *>
  45. *> RESULT(1) = | U' A U - S | / ( |A| m ulp ) *andC> RESULT(2) = | I - U'U | / ( m ulp )
  46. *> \endverbatim
  47. *
  48. * Arguments:
  49. * ==========
  50. *
  51. *> \verbatim
  52. *> ITYPE INTEGER
  53. *> Specifies the type of tests to be performed.
  54. *> 1: U expressed as a dense orthogonal matrix:
  55. *> RESULT(1) = | A - U S U' | / ( |A| n ulp ) *andC> RESULT(2) = | I - UU' | / ( n ulp )
  56. *>
  57. *> UPLO CHARACTER
  58. *> If UPLO='U', the upper triangle of A will be used and the
  59. *> (strictly) lower triangle will not be referenced. If
  60. *> UPLO='L', the lower triangle of A will be used and the
  61. *> (strictly) upper triangle will not be referenced.
  62. *> Not modified.
  63. *>
  64. *> N INTEGER
  65. *> The size of the matrix. If it is zero, CHET22 does nothing.
  66. *> It must be at least zero.
  67. *> Not modified.
  68. *>
  69. *> M INTEGER
  70. *> The number of columns of U. If it is zero, CHET22 does
  71. *> nothing. It must be at least zero.
  72. *> Not modified.
  73. *>
  74. *> KBAND INTEGER
  75. *> The bandwidth of the matrix. It may only be zero or one.
  76. *> If zero, then S is diagonal, and E is not referenced. If
  77. *> one, then S is symmetric tri-diagonal.
  78. *> Not modified.
  79. *>
  80. *> A COMPLEX array, dimension (LDA , N)
  81. *> The original (unfactored) matrix. It is assumed to be
  82. *> symmetric, and only the upper (UPLO='U') or only the lower
  83. *> (UPLO='L') will be referenced.
  84. *> Not modified.
  85. *>
  86. *> LDA INTEGER
  87. *> The leading dimension of A. It must be at least 1
  88. *> and at least N.
  89. *> Not modified.
  90. *>
  91. *> D REAL array, dimension (N)
  92. *> The diagonal of the (symmetric tri-) diagonal matrix.
  93. *> Not modified.
  94. *>
  95. *> E REAL array, dimension (N)
  96. *> The off-diagonal of the (symmetric tri-) diagonal matrix.
  97. *> E(1) is ignored, E(2) is the (1,2) and (2,1) element, etc.
  98. *> Not referenced if KBAND=0.
  99. *> Not modified.
  100. *>
  101. *> U COMPLEX array, dimension (LDU, N)
  102. *> If ITYPE=1, this contains the orthogonal matrix in
  103. *> the decomposition, expressed as a dense matrix.
  104. *> Not modified.
  105. *>
  106. *> LDU INTEGER
  107. *> The leading dimension of U. LDU must be at least N and
  108. *> at least 1.
  109. *> Not modified.
  110. *>
  111. *> V COMPLEX array, dimension (LDV, N)
  112. *> If ITYPE=2 or 3, the lower triangle of this array contains
  113. *> the Householder vectors used to describe the orthogonal
  114. *> matrix in the decomposition. If ITYPE=1, then it is not
  115. *> referenced.
  116. *> Not modified.
  117. *>
  118. *> LDV INTEGER
  119. *> The leading dimension of V. LDV must be at least N and
  120. *> at least 1.
  121. *> Not modified.
  122. *>
  123. *> TAU COMPLEX array, dimension (N)
  124. *> If ITYPE >= 2, then TAU(j) is the scalar factor of
  125. *> v(j) v(j)' in the Householder transformation H(j) of
  126. *> the product U = H(1)...H(n-2)
  127. *> If ITYPE < 2, then TAU is not referenced.
  128. *> Not modified.
  129. *>
  130. *> WORK COMPLEX array, dimension (2*N**2)
  131. *> Workspace.
  132. *> Modified.
  133. *>
  134. *> RWORK REAL array, dimension (N)
  135. *> Workspace.
  136. *> Modified.
  137. *>
  138. *> RESULT REAL array, dimension (2)
  139. *> The values computed by the two tests described above. The
  140. *> values are currently limited to 1/ulp, to avoid overflow.
  141. *> RESULT(1) is always modified. RESULT(2) is modified only
  142. *> if LDU is at least N.
  143. *> Modified.
  144. *> \endverbatim
  145. *
  146. * Authors:
  147. * ========
  148. *
  149. *> \author Univ. of Tennessee
  150. *> \author Univ. of California Berkeley
  151. *> \author Univ. of Colorado Denver
  152. *> \author NAG Ltd.
  153. *
  154. *> \date November 2011
  155. *
  156. *> \ingroup complex_eig
  157. *
  158. * =====================================================================
  159. SUBROUTINE CHET22( ITYPE, UPLO, N, M, KBAND, A, LDA, D, E, U, LDU,
  160. $ V, LDV, TAU, WORK, RWORK, RESULT )
  161. *
  162. * -- LAPACK test routine (version 3.4.0) --
  163. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  164. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  165. * November 2011
  166. *
  167. * .. Scalar Arguments ..
  168. CHARACTER UPLO
  169. INTEGER ITYPE, KBAND, LDA, LDU, LDV, M, N
  170. * ..
  171. * .. Array Arguments ..
  172. REAL D( * ), E( * ), RESULT( 2 ), RWORK( * )
  173. COMPLEX A( LDA, * ), TAU( * ), U( LDU, * ),
  174. $ V( LDV, * ), WORK( * )
  175. * ..
  176. *
  177. * =====================================================================
  178. *
  179. * .. Parameters ..
  180. REAL ZERO, ONE
  181. PARAMETER ( ZERO = 0.0E0, ONE = 1.0E0 )
  182. COMPLEX CZERO, CONE
  183. PARAMETER ( CZERO = ( 0.0E0, 0.0E0 ),
  184. $ CONE = ( 1.0E0, 0.0E0 ) )
  185. * ..
  186. * .. Local Scalars ..
  187. INTEGER J, JJ, JJ1, JJ2, NN, NNP1
  188. REAL ANORM, ULP, UNFL, WNORM
  189. * ..
  190. * .. External Functions ..
  191. REAL CLANHE, SLAMCH
  192. EXTERNAL CLANHE, SLAMCH
  193. * ..
  194. * .. External Subroutines ..
  195. EXTERNAL CGEMM, CHEMM
  196. * ..
  197. * .. Intrinsic Functions ..
  198. INTRINSIC MAX, MIN, REAL
  199. * ..
  200. * .. Executable Statements ..
  201. *
  202. RESULT( 1 ) = ZERO
  203. RESULT( 2 ) = ZERO
  204. IF( N.LE.0 .OR. M.LE.0 )
  205. $ RETURN
  206. *
  207. UNFL = SLAMCH( 'Safe minimum' )
  208. ULP = SLAMCH( 'Precision' )
  209. *
  210. * Do Test 1
  211. *
  212. * Norm of A:
  213. *
  214. ANORM = MAX( CLANHE( '1', UPLO, N, A, LDA, RWORK ), UNFL )
  215. *
  216. * Compute error matrix:
  217. *
  218. * ITYPE=1: error = U' A U - S
  219. *
  220. CALL CHEMM( 'L', UPLO, N, M, CONE, A, LDA, U, LDU, CZERO, WORK,
  221. $ N )
  222. NN = N*N
  223. NNP1 = NN + 1
  224. CALL CGEMM( 'C', 'N', M, M, N, CONE, U, LDU, WORK, N, CZERO,
  225. $ WORK( NNP1 ), N )
  226. DO 10 J = 1, M
  227. JJ = NN + ( J-1 )*N + J
  228. WORK( JJ ) = WORK( JJ ) - D( J )
  229. 10 CONTINUE
  230. IF( KBAND.EQ.1 .AND. N.GT.1 ) THEN
  231. DO 20 J = 2, M
  232. JJ1 = NN + ( J-1 )*N + J - 1
  233. JJ2 = NN + ( J-2 )*N + J
  234. WORK( JJ1 ) = WORK( JJ1 ) - E( J-1 )
  235. WORK( JJ2 ) = WORK( JJ2 ) - E( J-1 )
  236. 20 CONTINUE
  237. END IF
  238. WNORM = CLANHE( '1', UPLO, M, WORK( NNP1 ), N, RWORK )
  239. *
  240. IF( ANORM.GT.WNORM ) THEN
  241. RESULT( 1 ) = ( WNORM / ANORM ) / ( M*ULP )
  242. ELSE
  243. IF( ANORM.LT.ONE ) THEN
  244. RESULT( 1 ) = ( MIN( WNORM, M*ANORM ) / ANORM ) / ( M*ULP )
  245. ELSE
  246. RESULT( 1 ) = MIN( WNORM / ANORM, REAL( M ) ) / ( M*ULP )
  247. END IF
  248. END IF
  249. *
  250. * Do Test 2
  251. *
  252. * Compute U'U - I
  253. *
  254. IF( ITYPE.EQ.1 )
  255. $ CALL CUNT01( 'Columns', N, M, U, LDU, WORK, 2*N*N, RWORK,
  256. $ RESULT( 2 ) )
  257. *
  258. RETURN
  259. *
  260. * End of CHET22
  261. *
  262. END