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.

cppt03.f 6.7 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. *> \brief \b CPPT03
  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 CPPT03( UPLO, N, A, AINV, WORK, LDWORK, RWORK, RCOND,
  12. * RESID )
  13. *
  14. * .. Scalar Arguments ..
  15. * CHARACTER UPLO
  16. * INTEGER LDWORK, N
  17. * REAL RCOND, RESID
  18. * ..
  19. * .. Array Arguments ..
  20. * REAL RWORK( * )
  21. * COMPLEX A( * ), AINV( * ), WORK( LDWORK, * )
  22. * ..
  23. *
  24. *
  25. *> \par Purpose:
  26. * =============
  27. *>
  28. *> \verbatim
  29. *>
  30. *> CPPT03 computes the residual for a Hermitian packed matrix times its
  31. *> inverse:
  32. *> norm( I - A*AINV ) / ( N * norm(A) * norm(AINV) * EPS ),
  33. *> where EPS is the machine epsilon.
  34. *> \endverbatim
  35. *
  36. * Arguments:
  37. * ==========
  38. *
  39. *> \param[in] UPLO
  40. *> \verbatim
  41. *> UPLO is CHARACTER*1
  42. *> Specifies whether the upper or lower triangular part of the
  43. *> Hermitian matrix A is stored:
  44. *> = 'U': Upper triangular
  45. *> = 'L': Lower triangular
  46. *> \endverbatim
  47. *>
  48. *> \param[in] N
  49. *> \verbatim
  50. *> N is INTEGER
  51. *> The number of rows and columns of the matrix A. N >= 0.
  52. *> \endverbatim
  53. *>
  54. *> \param[in] A
  55. *> \verbatim
  56. *> A is COMPLEX array, dimension (N*(N+1)/2)
  57. *> The original Hermitian matrix A, stored as a packed
  58. *> triangular matrix.
  59. *> \endverbatim
  60. *>
  61. *> \param[in] AINV
  62. *> \verbatim
  63. *> AINV is COMPLEX array, dimension (N*(N+1)/2)
  64. *> The (Hermitian) inverse of the matrix A, stored as a packed
  65. *> triangular matrix.
  66. *> \endverbatim
  67. *>
  68. *> \param[out] WORK
  69. *> \verbatim
  70. *> WORK is COMPLEX array, dimension (LDWORK,N)
  71. *> \endverbatim
  72. *>
  73. *> \param[in] LDWORK
  74. *> \verbatim
  75. *> LDWORK is INTEGER
  76. *> The leading dimension of the array WORK. LDWORK >= max(1,N).
  77. *> \endverbatim
  78. *>
  79. *> \param[out] RWORK
  80. *> \verbatim
  81. *> RWORK is REAL array, dimension (N)
  82. *> \endverbatim
  83. *>
  84. *> \param[out] RCOND
  85. *> \verbatim
  86. *> RCOND is REAL
  87. *> The reciprocal of the condition number of A, computed as
  88. *> ( 1/norm(A) ) / norm(AINV).
  89. *> \endverbatim
  90. *>
  91. *> \param[out] RESID
  92. *> \verbatim
  93. *> RESID is REAL
  94. *> norm(I - A*AINV) / ( N * norm(A) * norm(AINV) * EPS )
  95. *> \endverbatim
  96. *
  97. * Authors:
  98. * ========
  99. *
  100. *> \author Univ. of Tennessee
  101. *> \author Univ. of California Berkeley
  102. *> \author Univ. of Colorado Denver
  103. *> \author NAG Ltd.
  104. *
  105. *> \ingroup complex_lin
  106. *
  107. * =====================================================================
  108. SUBROUTINE CPPT03( UPLO, N, A, AINV, WORK, LDWORK, RWORK, RCOND,
  109. $ RESID )
  110. *
  111. * -- LAPACK test routine --
  112. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  113. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  114. *
  115. * .. Scalar Arguments ..
  116. CHARACTER UPLO
  117. INTEGER LDWORK, N
  118. REAL RCOND, RESID
  119. * ..
  120. * .. Array Arguments ..
  121. REAL RWORK( * )
  122. COMPLEX A( * ), AINV( * ), WORK( LDWORK, * )
  123. * ..
  124. *
  125. * =====================================================================
  126. *
  127. * .. Parameters ..
  128. REAL ZERO, ONE
  129. PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0 )
  130. COMPLEX CZERO, CONE
  131. PARAMETER ( CZERO = ( 0.0E+0, 0.0E+0 ),
  132. $ CONE = ( 1.0E+0, 0.0E+0 ) )
  133. * ..
  134. * .. Local Scalars ..
  135. INTEGER I, J, JJ
  136. REAL AINVNM, ANORM, EPS
  137. * ..
  138. * .. External Functions ..
  139. LOGICAL LSAME
  140. REAL CLANGE, CLANHP, SLAMCH
  141. EXTERNAL LSAME, CLANGE, CLANHP, SLAMCH
  142. * ..
  143. * .. Intrinsic Functions ..
  144. INTRINSIC CONJG, REAL
  145. * ..
  146. * .. External Subroutines ..
  147. EXTERNAL CCOPY, CHPMV
  148. * ..
  149. * .. Executable Statements ..
  150. *
  151. * Quick exit if N = 0.
  152. *
  153. IF( N.LE.0 ) THEN
  154. RCOND = ONE
  155. RESID = ZERO
  156. RETURN
  157. END IF
  158. *
  159. * Exit with RESID = 1/EPS if ANORM = 0 or AINVNM = 0.
  160. *
  161. EPS = SLAMCH( 'Epsilon' )
  162. ANORM = CLANHP( '1', UPLO, N, A, RWORK )
  163. AINVNM = CLANHP( '1', UPLO, N, AINV, RWORK )
  164. IF( ANORM.LE.ZERO .OR. AINVNM.LE.ZERO ) THEN
  165. RCOND = ZERO
  166. RESID = ONE / EPS
  167. RETURN
  168. END IF
  169. RCOND = ( ONE/ANORM ) / AINVNM
  170. *
  171. * UPLO = 'U':
  172. * Copy the leading N-1 x N-1 submatrix of AINV to WORK(1:N,2:N) and
  173. * expand it to a full matrix, then multiply by A one column at a
  174. * time, moving the result one column to the left.
  175. *
  176. IF( LSAME( UPLO, 'U' ) ) THEN
  177. *
  178. * Copy AINV
  179. *
  180. JJ = 1
  181. DO 20 J = 1, N - 1
  182. CALL CCOPY( J, AINV( JJ ), 1, WORK( 1, J+1 ), 1 )
  183. DO 10 I = 1, J - 1
  184. WORK( J, I+1 ) = CONJG( AINV( JJ+I-1 ) )
  185. 10 CONTINUE
  186. JJ = JJ + J
  187. 20 CONTINUE
  188. JJ = ( ( N-1 )*N ) / 2 + 1
  189. DO 30 I = 1, N - 1
  190. WORK( N, I+1 ) = CONJG( AINV( JJ+I-1 ) )
  191. 30 CONTINUE
  192. *
  193. * Multiply by A
  194. *
  195. DO 40 J = 1, N - 1
  196. CALL CHPMV( 'Upper', N, -CONE, A, WORK( 1, J+1 ), 1, CZERO,
  197. $ WORK( 1, J ), 1 )
  198. 40 CONTINUE
  199. CALL CHPMV( 'Upper', N, -CONE, A, AINV( JJ ), 1, CZERO,
  200. $ WORK( 1, N ), 1 )
  201. *
  202. * UPLO = 'L':
  203. * Copy the trailing N-1 x N-1 submatrix of AINV to WORK(1:N,1:N-1)
  204. * and multiply by A, moving each column to the right.
  205. *
  206. ELSE
  207. *
  208. * Copy AINV
  209. *
  210. DO 50 I = 1, N - 1
  211. WORK( 1, I ) = CONJG( AINV( I+1 ) )
  212. 50 CONTINUE
  213. JJ = N + 1
  214. DO 70 J = 2, N
  215. CALL CCOPY( N-J+1, AINV( JJ ), 1, WORK( J, J-1 ), 1 )
  216. DO 60 I = 1, N - J
  217. WORK( J, J+I-1 ) = CONJG( AINV( JJ+I ) )
  218. 60 CONTINUE
  219. JJ = JJ + N - J + 1
  220. 70 CONTINUE
  221. *
  222. * Multiply by A
  223. *
  224. DO 80 J = N, 2, -1
  225. CALL CHPMV( 'Lower', N, -CONE, A, WORK( 1, J-1 ), 1, CZERO,
  226. $ WORK( 1, J ), 1 )
  227. 80 CONTINUE
  228. CALL CHPMV( 'Lower', N, -CONE, A, AINV( 1 ), 1, CZERO,
  229. $ WORK( 1, 1 ), 1 )
  230. *
  231. END IF
  232. *
  233. * Add the identity matrix to WORK .
  234. *
  235. DO 90 I = 1, N
  236. WORK( I, I ) = WORK( I, I ) + CONE
  237. 90 CONTINUE
  238. *
  239. * Compute norm(I - A*AINV) / (N * norm(A) * norm(AINV) * EPS)
  240. *
  241. RESID = CLANGE( '1', N, N, WORK, LDWORK, RWORK )
  242. *
  243. RESID = ( ( RESID*RCOND )/EPS ) / REAL( N )
  244. *
  245. RETURN
  246. *
  247. * End of CPPT03
  248. *
  249. END