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_gercond_c.f 8.4 kB

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