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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  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[in] WORK
  106. *> \verbatim
  107. *> WORK is COMPLEX array, dimension (2*N).
  108. *> Workspace.
  109. *> \endverbatim
  110. *>
  111. *> \param[in] 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. *> \date June 2016
  126. *
  127. *> \ingroup complexPOcomputational
  128. *
  129. * =====================================================================
  130. REAL FUNCTION CLA_PORCOND_C( UPLO, N, A, LDA, AF, LDAF, C, CAPPLY,
  131. $ INFO, WORK, RWORK )
  132. *
  133. * -- LAPACK computational routine (version 3.7.0) --
  134. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  135. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  136. * June 2016
  137. *
  138. * .. Scalar Arguments ..
  139. CHARACTER UPLO
  140. LOGICAL CAPPLY
  141. INTEGER N, LDA, LDAF, INFO
  142. * ..
  143. * .. Array Arguments ..
  144. COMPLEX A( LDA, * ), AF( LDAF, * ), WORK( * )
  145. REAL C( * ), RWORK( * )
  146. * ..
  147. *
  148. * =====================================================================
  149. *
  150. * .. Local Scalars ..
  151. INTEGER KASE
  152. REAL AINVNM, ANORM, TMP
  153. INTEGER I, J
  154. LOGICAL UP, UPPER
  155. COMPLEX ZDUM
  156. * ..
  157. * .. Local Arrays ..
  158. INTEGER ISAVE( 3 )
  159. * ..
  160. * .. External Functions ..
  161. LOGICAL LSAME
  162. EXTERNAL LSAME
  163. * ..
  164. * .. External Subroutines ..
  165. EXTERNAL CLACN2, CPOTRS, XERBLA
  166. * ..
  167. * .. Intrinsic Functions ..
  168. INTRINSIC ABS, MAX, REAL, AIMAG
  169. * ..
  170. * .. Statement Functions ..
  171. REAL CABS1
  172. * ..
  173. * .. Statement Function Definitions ..
  174. CABS1( ZDUM ) = ABS( REAL( ZDUM ) ) + ABS( AIMAG( ZDUM ) )
  175. * ..
  176. * .. Executable Statements ..
  177. *
  178. CLA_PORCOND_C = 0.0E+0
  179. *
  180. INFO = 0
  181. UPPER = LSAME( UPLO, 'U' )
  182. IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN
  183. INFO = -1
  184. ELSE IF( N.LT.0 ) THEN
  185. INFO = -2
  186. ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
  187. INFO = -4
  188. ELSE IF( LDAF.LT.MAX( 1, N ) ) THEN
  189. INFO = -6
  190. END IF
  191. IF( INFO.NE.0 ) THEN
  192. CALL XERBLA( 'CLA_PORCOND_C', -INFO )
  193. RETURN
  194. END IF
  195. UP = .FALSE.
  196. IF ( LSAME( UPLO, 'U' ) ) UP = .TRUE.
  197. *
  198. * Compute norm of op(A)*op2(C).
  199. *
  200. ANORM = 0.0E+0
  201. IF ( UP ) THEN
  202. DO I = 1, N
  203. TMP = 0.0E+0
  204. IF ( CAPPLY ) THEN
  205. DO J = 1, I
  206. TMP = TMP + CABS1( A( J, I ) ) / C( J )
  207. END DO
  208. DO J = I+1, N
  209. TMP = TMP + CABS1( A( I, J ) ) / C( J )
  210. END DO
  211. ELSE
  212. DO J = 1, I
  213. TMP = TMP + CABS1( A( J, I ) )
  214. END DO
  215. DO J = I+1, N
  216. TMP = TMP + CABS1( A( I, J ) )
  217. END DO
  218. END IF
  219. RWORK( I ) = TMP
  220. ANORM = MAX( ANORM, TMP )
  221. END DO
  222. ELSE
  223. DO I = 1, N
  224. TMP = 0.0E+0
  225. IF ( CAPPLY ) THEN
  226. DO J = 1, I
  227. TMP = TMP + CABS1( A( I, J ) ) / C( J )
  228. END DO
  229. DO J = I+1, N
  230. TMP = TMP + CABS1( A( J, I ) ) / C( J )
  231. END DO
  232. ELSE
  233. DO J = 1, I
  234. TMP = TMP + CABS1( A( I, J ) )
  235. END DO
  236. DO J = I+1, N
  237. TMP = TMP + CABS1( A( J, I ) )
  238. END DO
  239. END IF
  240. RWORK( I ) = TMP
  241. ANORM = MAX( ANORM, TMP )
  242. END DO
  243. END IF
  244. *
  245. * Quick return if possible.
  246. *
  247. IF( N.EQ.0 ) THEN
  248. CLA_PORCOND_C = 1.0E+0
  249. RETURN
  250. ELSE IF( ANORM .EQ. 0.0E+0 ) THEN
  251. RETURN
  252. END IF
  253. *
  254. * Estimate the norm of inv(op(A)).
  255. *
  256. AINVNM = 0.0E+0
  257. *
  258. KASE = 0
  259. 10 CONTINUE
  260. CALL CLACN2( N, WORK( N+1 ), WORK, AINVNM, KASE, ISAVE )
  261. IF( KASE.NE.0 ) THEN
  262. IF( KASE.EQ.2 ) THEN
  263. *
  264. * Multiply by R.
  265. *
  266. DO I = 1, N
  267. WORK( I ) = WORK( I ) * RWORK( I )
  268. END DO
  269. *
  270. IF ( UP ) THEN
  271. CALL CPOTRS( 'U', N, 1, AF, LDAF,
  272. $ WORK, N, INFO )
  273. ELSE
  274. CALL CPOTRS( 'L', N, 1, AF, LDAF,
  275. $ WORK, N, INFO )
  276. ENDIF
  277. *
  278. * Multiply by inv(C).
  279. *
  280. IF ( CAPPLY ) THEN
  281. DO I = 1, N
  282. WORK( I ) = WORK( I ) * C( I )
  283. END DO
  284. END IF
  285. ELSE
  286. *
  287. * Multiply by inv(C**H).
  288. *
  289. IF ( CAPPLY ) THEN
  290. DO I = 1, N
  291. WORK( I ) = WORK( I ) * C( I )
  292. END DO
  293. END IF
  294. *
  295. IF ( UP ) THEN
  296. CALL CPOTRS( 'U', N, 1, AF, LDAF,
  297. $ WORK, N, INFO )
  298. ELSE
  299. CALL CPOTRS( 'L', N, 1, AF, LDAF,
  300. $ WORK, N, INFO )
  301. END IF
  302. *
  303. * Multiply by R.
  304. *
  305. DO I = 1, N
  306. WORK( I ) = WORK( I ) * RWORK( I )
  307. END DO
  308. END IF
  309. GO TO 10
  310. END IF
  311. *
  312. * Compute the estimate of the reciprocal condition number.
  313. *
  314. IF( AINVNM .NE. 0.0E+0 )
  315. $ CLA_PORCOND_C = 1.0E+0 / AINVNM
  316. *
  317. RETURN
  318. *
  319. END