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.

chet01_3.f 7.5 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. *> \brief \b CHET01_3
  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 CHET01_3( UPLO, N, A, LDA, AFAC, LDAFAC, E, IPIV, C,
  12. * LDC, RWORK, RESID )
  13. *
  14. * .. Scalar Arguments ..
  15. * CHARACTER UPLO
  16. * INTEGER LDA, LDAFAC, LDC, N
  17. * REAL RESID
  18. * ..
  19. * .. Array Arguments ..
  20. * INTEGER IPIV( * )
  21. * REAL RWORK( * )
  22. * COMPLEX A( LDA, * ), AFAC( LDAFAC, * ), C( LDC, * ),
  23. * E( * )
  24. * ..
  25. *
  26. *
  27. *> \par Purpose:
  28. * =============
  29. *>
  30. *> \verbatim
  31. *>
  32. *> CHET01_3 reconstructs a Hermitian indefinite matrix A from its
  33. *> block L*D*L' or U*D*U' factorization computed by CHETRF_RK
  34. *> (or CHETRF_BK) and computes the residual
  35. *> norm( C - A ) / ( N * norm(A) * EPS ),
  36. *> where C is the reconstructed matrix and EPS is the machine epsilon.
  37. *> \endverbatim
  38. *
  39. * Arguments:
  40. * ==========
  41. *
  42. *> \param[in] UPLO
  43. *> \verbatim
  44. *> UPLO is CHARACTER*1
  45. *> Specifies whether the upper or lower triangular part of the
  46. *> Hermitian matrix A is stored:
  47. *> = 'U': Upper triangular
  48. *> = 'L': Lower triangular
  49. *> \endverbatim
  50. *>
  51. *> \param[in] N
  52. *> \verbatim
  53. *> N is INTEGER
  54. *> The number of rows and columns of the matrix A. N >= 0.
  55. *> \endverbatim
  56. *>
  57. *> \param[in] A
  58. *> \verbatim
  59. *> A is COMPLEX*16 array, dimension (LDA,N)
  60. *> The original Hermitian matrix A.
  61. *> \endverbatim
  62. *>
  63. *> \param[in] LDA
  64. *> \verbatim
  65. *> LDA is INTEGER
  66. *> The leading dimension of the array A. LDA >= max(1,N)
  67. *> \endverbatim
  68. *>
  69. *> \param[in] AFAC
  70. *> \verbatim
  71. *> AFAC is COMPLEX array, dimension (LDAFAC,N)
  72. *> Diagonal of the block diagonal matrix D and factors U or L
  73. *> as computed by CHETRF_RK and CHETRF_BK:
  74. *> a) ONLY diagonal elements of the Hermitian block diagonal
  75. *> matrix D on the diagonal of A, i.e. D(k,k) = A(k,k);
  76. *> (superdiagonal (or subdiagonal) elements of D
  77. *> should be provided on entry in array E), and
  78. *> b) If UPLO = 'U': factor U in the superdiagonal part of A.
  79. *> If UPLO = 'L': factor L in the subdiagonal part of A.
  80. *> \endverbatim
  81. *>
  82. *> \param[in] LDAFAC
  83. *> \verbatim
  84. *> LDAFAC is INTEGER
  85. *> The leading dimension of the array AFAC.
  86. *> LDAFAC >= max(1,N).
  87. *> \endverbatim
  88. *>
  89. *> \param[in] E
  90. *> \verbatim
  91. *> E is COMPLEX array, dimension (N)
  92. *> On entry, contains the superdiagonal (or subdiagonal)
  93. *> elements of the Hermitian block diagonal matrix D
  94. *> with 1-by-1 or 2-by-2 diagonal blocks, where
  95. *> If UPLO = 'U': E(i) = D(i-1,i),i=2:N, E(1) not referenced;
  96. *> If UPLO = 'L': E(i) = D(i+1,i),i=1:N-1, E(N) not referenced.
  97. *> \endverbatim
  98. *>
  99. *> \param[in] IPIV
  100. *> \verbatim
  101. *> IPIV is INTEGER array, dimension (N)
  102. *> The pivot indices from CHETRF_RK (or CHETRF_BK).
  103. *> \endverbatim
  104. *>
  105. *> \param[out] C
  106. *> \verbatim
  107. *> C is COMPLEX array, dimension (LDC,N)
  108. *> \endverbatim
  109. *>
  110. *> \param[in] LDC
  111. *> \verbatim
  112. *> LDC is INTEGER
  113. *> The leading dimension of the array C. LDC >= max(1,N).
  114. *> \endverbatim
  115. *>
  116. *> \param[out] RWORK
  117. *> \verbatim
  118. *> RWORK is REAL array, dimension (N)
  119. *> \endverbatim
  120. *>
  121. *> \param[out] RESID
  122. *> \verbatim
  123. *> RESID is REAL
  124. *> If UPLO = 'L', norm(L*D*L' - A) / ( N * norm(A) * EPS )
  125. *> If UPLO = 'U', norm(U*D*U' - A) / ( N * norm(A) * EPS )
  126. *> \endverbatim
  127. *
  128. * Authors:
  129. * ========
  130. *
  131. *> \author Univ. of Tennessee
  132. *> \author Univ. of California Berkeley
  133. *> \author Univ. of Colorado Denver
  134. *> \author NAG Ltd.
  135. *
  136. *> \ingroup complex_lin
  137. *
  138. * =====================================================================
  139. SUBROUTINE CHET01_3( UPLO, N, A, LDA, AFAC, LDAFAC, E, IPIV, C,
  140. $ LDC, RWORK, RESID )
  141. *
  142. * -- LAPACK test routine --
  143. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  144. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  145. *
  146. * .. Scalar Arguments ..
  147. CHARACTER UPLO
  148. INTEGER LDA, LDAFAC, LDC, N
  149. REAL RESID
  150. * ..
  151. * .. Array Arguments ..
  152. INTEGER IPIV( * )
  153. REAL RWORK( * )
  154. COMPLEX A( LDA, * ), AFAC( LDAFAC, * ), C( LDC, * ),
  155. $ E( * )
  156. * ..
  157. *
  158. * =====================================================================
  159. *
  160. * .. Parameters ..
  161. REAL ZERO, ONE
  162. PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0 )
  163. COMPLEX CZERO, CONE
  164. PARAMETER ( CZERO = ( 0.0E+0, 0.0E+0 ),
  165. $ CONE = ( 1.0E+0, 0.0E+0 ) )
  166. * ..
  167. * .. Local Scalars ..
  168. INTEGER I, INFO, J
  169. REAL ANORM, EPS
  170. * ..
  171. * .. External Functions ..
  172. LOGICAL LSAME
  173. REAL CLANHE, SLAMCH
  174. EXTERNAL LSAME, CLANHE, SLAMCH
  175. * ..
  176. * .. External Subroutines ..
  177. EXTERNAL CLASET, CLAVHE_ROOK, CSYCONVF_ROOK
  178. * ..
  179. * .. Intrinsic Functions ..
  180. INTRINSIC AIMAG, REAL
  181. * ..
  182. * .. Executable Statements ..
  183. *
  184. * Quick exit if N = 0.
  185. *
  186. IF( N.LE.0 ) THEN
  187. RESID = ZERO
  188. RETURN
  189. END IF
  190. *
  191. * a) Revert to multiplyers of L
  192. *
  193. CALL CSYCONVF_ROOK( UPLO, 'R', N, AFAC, LDAFAC, E, IPIV, INFO )
  194. *
  195. * 1) Determine EPS and the norm of A.
  196. *
  197. EPS = SLAMCH( 'Epsilon' )
  198. ANORM = CLANHE( '1', UPLO, N, A, LDA, RWORK )
  199. *
  200. * Check the imaginary parts of the diagonal elements and return with
  201. * an error code if any are nonzero.
  202. *
  203. DO J = 1, N
  204. IF( AIMAG( AFAC( J, J ) ).NE.ZERO ) THEN
  205. RESID = ONE / EPS
  206. RETURN
  207. END IF
  208. END DO
  209. *
  210. * 2) Initialize C to the identity matrix.
  211. *
  212. CALL CLASET( 'Full', N, N, CZERO, CONE, C, LDC )
  213. *
  214. * 3) Call CLAVHE_ROOK to form the product D * U' (or D * L' ).
  215. *
  216. CALL CLAVHE_ROOK( UPLO, 'Conjugate', 'Non-unit', N, N, AFAC,
  217. $ LDAFAC, IPIV, C, LDC, INFO )
  218. *
  219. * 4) Call ZLAVHE_RK again to multiply by U (or L ).
  220. *
  221. CALL CLAVHE_ROOK( UPLO, 'No transpose', 'Unit', N, N, AFAC,
  222. $ LDAFAC, IPIV, C, LDC, INFO )
  223. *
  224. * 5) Compute the difference C - A .
  225. *
  226. IF( LSAME( UPLO, 'U' ) ) THEN
  227. DO J = 1, N
  228. DO I = 1, J - 1
  229. C( I, J ) = C( I, J ) - A( I, J )
  230. END DO
  231. C( J, J ) = C( J, J ) - REAL( A( J, J ) )
  232. END DO
  233. ELSE
  234. DO J = 1, N
  235. C( J, J ) = C( J, J ) - REAL( A( J, J ) )
  236. DO I = J + 1, N
  237. C( I, J ) = C( I, J ) - A( I, J )
  238. END DO
  239. END DO
  240. END IF
  241. *
  242. * 6) Compute norm( C - A ) / ( N * norm(A) * EPS )
  243. *
  244. RESID = CLANHE( '1', UPLO, N, C, LDC, RWORK )
  245. *
  246. IF( ANORM.LE.ZERO ) THEN
  247. IF( RESID.NE.ZERO )
  248. $ RESID = ONE / EPS
  249. ELSE
  250. RESID = ( ( RESID/REAL( N ) )/ANORM ) / EPS
  251. END IF
  252. *
  253. * b) Convert to factor of L (or U)
  254. *
  255. CALL CSYCONVF_ROOK( UPLO, 'C', N, AFAC, LDAFAC, E, IPIV, INFO )
  256. *
  257. RETURN
  258. *
  259. * End of CHET01_3
  260. *
  261. END