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.

cla_porcond_c.f 8.4 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. *> \brief \b CLA_PORCOND_C computes the infinity norm condition number of op(A)*inv(diag(c)) for Hermitian positive-definite matrices.
  2. *
  3. * =========== DOCUMENTATION ===========
  4. *
  5. * Online html documentation available at
  6. * http://www.netlib.org/lapack/explore-html/
  7. *
  8. *> \htmlonly
  9. *> Download CLA_PORCOND_C + dependencies
  10. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cla_porcond_c.f">
  11. *> [TGZ]</a>
  12. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cla_porcond_c.f">
  13. *> [ZIP]</a>
  14. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cla_porcond_c.f">
  15. *> [TXT]</a>
  16. *> \endhtmlonly
  17. *
  18. * Definition:
  19. * ===========
  20. *
  21. * REAL FUNCTION CLA_PORCOND_C( UPLO, N, A, LDA, AF, LDAF, C, CAPPLY,
  22. * INFO, WORK, RWORK )
  23. *
  24. * .. Scalar Arguments ..
  25. * CHARACTER UPLO
  26. * LOGICAL CAPPLY
  27. * INTEGER N, LDA, LDAF, INFO
  28. * ..
  29. * .. Array Arguments ..
  30. * COMPLEX A( LDA, * ), AF( LDAF, * ), WORK( * )
  31. * REAL C( * ), RWORK( * )
  32. * ..
  33. *
  34. *
  35. *> \par Purpose:
  36. * =============
  37. *>
  38. *> \verbatim
  39. *>
  40. *> CLA_PORCOND_C Computes the infinity norm condition number of
  41. *> op(A) * inv(diag(C)) where C is a REAL vector
  42. *> \endverbatim
  43. *
  44. * Arguments:
  45. * ==========
  46. *
  47. *> \param[in] UPLO
  48. *> \verbatim
  49. *> UPLO is CHARACTER*1
  50. *> = 'U': Upper triangle of A is stored;
  51. *> = 'L': Lower triangle of A is stored.
  52. *> \endverbatim
  53. *>
  54. *> \param[in] N
  55. *> \verbatim
  56. *> N is INTEGER
  57. *> The number of linear equations, i.e., the order of the
  58. *> matrix A. N >= 0.
  59. *> \endverbatim
  60. *>
  61. *> \param[in] A
  62. *> \verbatim
  63. *> A is COMPLEX array, dimension (LDA,N)
  64. *> On entry, the N-by-N matrix A
  65. *> \endverbatim
  66. *>
  67. *> \param[in] LDA
  68. *> \verbatim
  69. *> LDA is INTEGER
  70. *> The leading dimension of the array A. LDA >= max(1,N).
  71. *> \endverbatim
  72. *>
  73. *> \param[in] AF
  74. *> \verbatim
  75. *> AF is COMPLEX array, dimension (LDAF,N)
  76. *> The triangular factor U or L from the Cholesky factorization
  77. *> A = U**H*U or A = L*L**H, as computed by CPOTRF.
  78. *> \endverbatim
  79. *>
  80. *> \param[in] LDAF
  81. *> \verbatim
  82. *> LDAF is INTEGER
  83. *> The leading dimension of the array AF. LDAF >= max(1,N).
  84. *> \endverbatim
  85. *>
  86. *> \param[in] C
  87. *> \verbatim
  88. *> C is REAL array, dimension (N)
  89. *> The vector C in the formula op(A) * inv(diag(C)).
  90. *> \endverbatim
  91. *>
  92. *> \param[in] CAPPLY
  93. *> \verbatim
  94. *> CAPPLY is LOGICAL
  95. *> If .TRUE. then access the vector C in the formula above.
  96. *> \endverbatim
  97. *>
  98. *> \param[out] INFO
  99. *> \verbatim
  100. *> INFO is INTEGER
  101. *> = 0: Successful exit.
  102. *> i > 0: The ith argument is invalid.
  103. *> \endverbatim
  104. *>
  105. *> \param[out] WORK
  106. *> \verbatim
  107. *> WORK is COMPLEX array, dimension (2*N).
  108. *> Workspace.
  109. *> \endverbatim
  110. *>
  111. *> \param[out] RWORK
  112. *> \verbatim
  113. *> RWORK is REAL array, dimension (N).
  114. *> Workspace.
  115. *> \endverbatim
  116. *
  117. * Authors:
  118. * ========
  119. *
  120. *> \author Univ. of Tennessee
  121. *> \author Univ. of California Berkeley
  122. *> \author Univ. of Colorado Denver
  123. *> \author NAG Ltd.
  124. *
  125. *> \ingroup complexPOcomputational
  126. *
  127. * =====================================================================
  128. REAL FUNCTION CLA_PORCOND_C( UPLO, N, A, LDA, AF, LDAF, C, CAPPLY,
  129. $ INFO, WORK, RWORK )
  130. *
  131. * -- LAPACK computational routine --
  132. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  133. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  134. *
  135. * .. Scalar Arguments ..
  136. CHARACTER UPLO
  137. LOGICAL CAPPLY
  138. INTEGER N, LDA, LDAF, INFO
  139. * ..
  140. * .. Array Arguments ..
  141. COMPLEX A( LDA, * ), AF( LDAF, * ), WORK( * )
  142. REAL C( * ), RWORK( * )
  143. * ..
  144. *
  145. * =====================================================================
  146. *
  147. * .. Local Scalars ..
  148. INTEGER KASE
  149. REAL AINVNM, ANORM, TMP
  150. INTEGER I, J
  151. LOGICAL UP, UPPER
  152. COMPLEX ZDUM
  153. * ..
  154. * .. Local Arrays ..
  155. INTEGER ISAVE( 3 )
  156. * ..
  157. * .. External Functions ..
  158. LOGICAL LSAME
  159. EXTERNAL LSAME
  160. * ..
  161. * .. External Subroutines ..
  162. EXTERNAL CLACN2, CPOTRS, XERBLA
  163. * ..
  164. * .. Intrinsic Functions ..
  165. INTRINSIC ABS, MAX, REAL, AIMAG
  166. * ..
  167. * .. Statement Functions ..
  168. REAL CABS1
  169. * ..
  170. * .. Statement Function Definitions ..
  171. CABS1( ZDUM ) = ABS( REAL( ZDUM ) ) + ABS( AIMAG( ZDUM ) )
  172. * ..
  173. * .. Executable Statements ..
  174. *
  175. CLA_PORCOND_C = 0.0E+0
  176. *
  177. INFO = 0
  178. UPPER = LSAME( UPLO, 'U' )
  179. IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN
  180. INFO = -1
  181. ELSE IF( N.LT.0 ) THEN
  182. INFO = -2
  183. ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
  184. INFO = -4
  185. ELSE IF( LDAF.LT.MAX( 1, N ) ) THEN
  186. INFO = -6
  187. END IF
  188. IF( INFO.NE.0 ) THEN
  189. CALL XERBLA( 'CLA_PORCOND_C', -INFO )
  190. RETURN
  191. END IF
  192. UP = .FALSE.
  193. IF ( LSAME( UPLO, 'U' ) ) UP = .TRUE.
  194. *
  195. * Compute norm of op(A)*op2(C).
  196. *
  197. ANORM = 0.0E+0
  198. IF ( UP ) THEN
  199. DO I = 1, N
  200. TMP = 0.0E+0
  201. IF ( CAPPLY ) THEN
  202. DO J = 1, I
  203. TMP = TMP + CABS1( A( J, I ) ) / C( J )
  204. END DO
  205. DO J = I+1, N
  206. TMP = TMP + CABS1( A( I, J ) ) / C( J )
  207. END DO
  208. ELSE
  209. DO J = 1, I
  210. TMP = TMP + CABS1( A( J, I ) )
  211. END DO
  212. DO J = I+1, N
  213. TMP = TMP + CABS1( A( I, J ) )
  214. END DO
  215. END IF
  216. RWORK( I ) = TMP
  217. ANORM = MAX( ANORM, TMP )
  218. END DO
  219. ELSE
  220. DO I = 1, N
  221. TMP = 0.0E+0
  222. IF ( CAPPLY ) THEN
  223. DO J = 1, I
  224. TMP = TMP + CABS1( A( I, J ) ) / C( J )
  225. END DO
  226. DO J = I+1, N
  227. TMP = TMP + CABS1( A( J, I ) ) / C( J )
  228. END DO
  229. ELSE
  230. DO J = 1, I
  231. TMP = TMP + CABS1( A( I, J ) )
  232. END DO
  233. DO J = I+1, N
  234. TMP = TMP + CABS1( A( J, I ) )
  235. END DO
  236. END IF
  237. RWORK( I ) = TMP
  238. ANORM = MAX( ANORM, TMP )
  239. END DO
  240. END IF
  241. *
  242. * Quick return if possible.
  243. *
  244. IF( N.EQ.0 ) THEN
  245. CLA_PORCOND_C = 1.0E+0
  246. RETURN
  247. ELSE IF( ANORM .EQ. 0.0E+0 ) THEN
  248. RETURN
  249. END IF
  250. *
  251. * Estimate the norm of inv(op(A)).
  252. *
  253. AINVNM = 0.0E+0
  254. *
  255. KASE = 0
  256. 10 CONTINUE
  257. CALL CLACN2( N, WORK( N+1 ), WORK, AINVNM, KASE, ISAVE )
  258. IF( KASE.NE.0 ) THEN
  259. IF( KASE.EQ.2 ) THEN
  260. *
  261. * Multiply by R.
  262. *
  263. DO I = 1, N
  264. WORK( I ) = WORK( I ) * RWORK( I )
  265. END DO
  266. *
  267. IF ( UP ) THEN
  268. CALL CPOTRS( 'U', N, 1, AF, LDAF,
  269. $ WORK, N, INFO )
  270. ELSE
  271. CALL CPOTRS( 'L', N, 1, AF, LDAF,
  272. $ WORK, N, INFO )
  273. ENDIF
  274. *
  275. * Multiply by inv(C).
  276. *
  277. IF ( CAPPLY ) THEN
  278. DO I = 1, N
  279. WORK( I ) = WORK( I ) * C( I )
  280. END DO
  281. END IF
  282. ELSE
  283. *
  284. * Multiply by inv(C**H).
  285. *
  286. IF ( CAPPLY ) THEN
  287. DO I = 1, N
  288. WORK( I ) = WORK( I ) * C( I )
  289. END DO
  290. END IF
  291. *
  292. IF ( UP ) THEN
  293. CALL CPOTRS( 'U', N, 1, AF, LDAF,
  294. $ WORK, N, INFO )
  295. ELSE
  296. CALL CPOTRS( 'L', N, 1, AF, LDAF,
  297. $ WORK, N, INFO )
  298. END IF
  299. *
  300. * Multiply by R.
  301. *
  302. DO I = 1, N
  303. WORK( I ) = WORK( I ) * RWORK( I )
  304. END DO
  305. END IF
  306. GO TO 10
  307. END IF
  308. *
  309. * Compute the estimate of the reciprocal condition number.
  310. *
  311. IF( AINVNM .NE. 0.0E+0 )
  312. $ CLA_PORCOND_C = 1.0E+0 / AINVNM
  313. *
  314. RETURN
  315. *
  316. * End of CLA_PORCOND_C
  317. *
  318. END