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.5 kB

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