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_gbrcond_x.f 8.8 kB

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