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_x.f 7.8 kB

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