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.

dla_gbrcond.f 10 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. *> \brief \b DLA_GBRCOND estimates the Skeel condition number for a general banded matrix.
  2. *
  3. * =========== DOCUMENTATION ===========
  4. *
  5. * Online html documentation available at
  6. * http://www.netlib.org/lapack/explore-html/
  7. *
  8. *> \htmlonly
  9. *> Download DLA_GBRCOND + dependencies
  10. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dla_gbrcond.f">
  11. *> [TGZ]</a>
  12. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dla_gbrcond.f">
  13. *> [ZIP]</a>
  14. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dla_gbrcond.f">
  15. *> [TXT]</a>
  16. *> \endhtmlonly
  17. *
  18. * Definition:
  19. * ===========
  20. *
  21. * DOUBLE PRECISION FUNCTION DLA_GBRCOND( TRANS, N, KL, KU, AB, LDAB,
  22. * AFB, LDAFB, IPIV, CMODE, C,
  23. * INFO, WORK, IWORK )
  24. *
  25. * .. Scalar Arguments ..
  26. * CHARACTER TRANS
  27. * INTEGER N, LDAB, LDAFB, INFO, KL, KU, CMODE
  28. * ..
  29. * .. Array Arguments ..
  30. * INTEGER IWORK( * ), IPIV( * )
  31. * DOUBLE PRECISION AB( LDAB, * ), AFB( LDAFB, * ), WORK( * ),
  32. * $ C( * )
  33. * ..
  34. *
  35. *
  36. *> \par Purpose:
  37. * =============
  38. *>
  39. *> \verbatim
  40. *>
  41. *> DLA_GBRCOND Estimates the Skeel condition number of op(A) * op2(C)
  42. *> where op2 is determined by CMODE as follows
  43. *> CMODE = 1 op2(C) = C
  44. *> CMODE = 0 op2(C) = I
  45. *> CMODE = -1 op2(C) = inv(C)
  46. *> The Skeel condition number cond(A) = norminf( |inv(A)||A| )
  47. *> is computed by computing scaling factors R such that
  48. *> diag(R)*A*op2(C) is row equilibrated and computing the standard
  49. *> infinity-norm condition number.
  50. *> \endverbatim
  51. *
  52. * Arguments:
  53. * ==========
  54. *
  55. *> \param[in] TRANS
  56. *> \verbatim
  57. *> TRANS is CHARACTER*1
  58. *> Specifies the form of the system of equations:
  59. *> = 'N': A * X = B (No transpose)
  60. *> = 'T': A**T * X = B (Transpose)
  61. *> = 'C': A**H * X = B (Conjugate Transpose = Transpose)
  62. *> \endverbatim
  63. *>
  64. *> \param[in] N
  65. *> \verbatim
  66. *> N is INTEGER
  67. *> The number of linear equations, i.e., the order of the
  68. *> matrix A. N >= 0.
  69. *> \endverbatim
  70. *>
  71. *> \param[in] KL
  72. *> \verbatim
  73. *> KL is INTEGER
  74. *> The number of subdiagonals within the band of A. KL >= 0.
  75. *> \endverbatim
  76. *>
  77. *> \param[in] KU
  78. *> \verbatim
  79. *> KU is INTEGER
  80. *> The number of superdiagonals within the band of A. KU >= 0.
  81. *> \endverbatim
  82. *>
  83. *> \param[in] AB
  84. *> \verbatim
  85. *> AB is DOUBLE PRECISION array, dimension (LDAB,N)
  86. *> On entry, the matrix A in band storage, in rows 1 to KL+KU+1.
  87. *> The j-th column of A is stored in the j-th column of the
  88. *> array AB as follows:
  89. *> AB(KU+1+i-j,j) = A(i,j) for max(1,j-KU)<=i<=min(N,j+kl)
  90. *> \endverbatim
  91. *>
  92. *> \param[in] LDAB
  93. *> \verbatim
  94. *> LDAB is INTEGER
  95. *> The leading dimension of the array AB. LDAB >= KL+KU+1.
  96. *> \endverbatim
  97. *>
  98. *> \param[in] AFB
  99. *> \verbatim
  100. *> AFB is DOUBLE PRECISION array, dimension (LDAFB,N)
  101. *> Details of the LU factorization of the band matrix A, as
  102. *> computed by DGBTRF. U is stored as an upper triangular
  103. *> band matrix with KL+KU superdiagonals in rows 1 to KL+KU+1,
  104. *> and the multipliers used during the factorization are stored
  105. *> in rows KL+KU+2 to 2*KL+KU+1.
  106. *> \endverbatim
  107. *>
  108. *> \param[in] LDAFB
  109. *> \verbatim
  110. *> LDAFB is INTEGER
  111. *> The leading dimension of the array AFB. LDAFB >= 2*KL+KU+1.
  112. *> \endverbatim
  113. *>
  114. *> \param[in] IPIV
  115. *> \verbatim
  116. *> IPIV is INTEGER array, dimension (N)
  117. *> The pivot indices from the factorization A = P*L*U
  118. *> as computed by DGBTRF; row i of the matrix was interchanged
  119. *> with row IPIV(i).
  120. *> \endverbatim
  121. *>
  122. *> \param[in] CMODE
  123. *> \verbatim
  124. *> CMODE is INTEGER
  125. *> Determines op2(C) in the formula op(A) * op2(C) as follows:
  126. *> CMODE = 1 op2(C) = C
  127. *> CMODE = 0 op2(C) = I
  128. *> CMODE = -1 op2(C) = inv(C)
  129. *> \endverbatim
  130. *>
  131. *> \param[in] C
  132. *> \verbatim
  133. *> C is DOUBLE PRECISION array, dimension (N)
  134. *> The vector C in the formula op(A) * op2(C).
  135. *> \endverbatim
  136. *>
  137. *> \param[out] INFO
  138. *> \verbatim
  139. *> INFO is INTEGER
  140. *> = 0: Successful exit.
  141. *> i > 0: The ith argument is invalid.
  142. *> \endverbatim
  143. *>
  144. *> \param[in] WORK
  145. *> \verbatim
  146. *> WORK is DOUBLE PRECISION array, dimension (5*N).
  147. *> Workspace.
  148. *> \endverbatim
  149. *>
  150. *> \param[in] IWORK
  151. *> \verbatim
  152. *> IWORK is INTEGER array, dimension (N).
  153. *> Workspace.
  154. *> \endverbatim
  155. *
  156. * Authors:
  157. * ========
  158. *
  159. *> \author Univ. of Tennessee
  160. *> \author Univ. of California Berkeley
  161. *> \author Univ. of Colorado Denver
  162. *> \author NAG Ltd.
  163. *
  164. *> \date September 2012
  165. *
  166. *> \ingroup doubleGBcomputational
  167. *
  168. * =====================================================================
  169. DOUBLE PRECISION FUNCTION DLA_GBRCOND( TRANS, N, KL, KU, AB, LDAB,
  170. $ AFB, LDAFB, IPIV, CMODE, C,
  171. $ INFO, WORK, IWORK )
  172. *
  173. * -- LAPACK computational routine (version 3.4.2) --
  174. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  175. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  176. * September 2012
  177. *
  178. * .. Scalar Arguments ..
  179. CHARACTER TRANS
  180. INTEGER N, LDAB, LDAFB, INFO, KL, KU, CMODE
  181. * ..
  182. * .. Array Arguments ..
  183. INTEGER IWORK( * ), IPIV( * )
  184. DOUBLE PRECISION AB( LDAB, * ), AFB( LDAFB, * ), WORK( * ),
  185. $ C( * )
  186. * ..
  187. *
  188. * =====================================================================
  189. *
  190. * .. Local Scalars ..
  191. LOGICAL NOTRANS
  192. INTEGER KASE, I, J, KD, KE
  193. DOUBLE PRECISION AINVNM, TMP
  194. * ..
  195. * .. Local Arrays ..
  196. INTEGER ISAVE( 3 )
  197. * ..
  198. * .. External Functions ..
  199. LOGICAL LSAME
  200. EXTERNAL LSAME
  201. * ..
  202. * .. External Subroutines ..
  203. EXTERNAL DLACN2, DGBTRS, XERBLA
  204. * ..
  205. * .. Intrinsic Functions ..
  206. INTRINSIC ABS, MAX
  207. * ..
  208. * .. Executable Statements ..
  209. *
  210. DLA_GBRCOND = 0.0D+0
  211. *
  212. INFO = 0
  213. NOTRANS = LSAME( TRANS, 'N' )
  214. IF ( .NOT. NOTRANS .AND. .NOT. LSAME(TRANS, 'T')
  215. $ .AND. .NOT. LSAME(TRANS, 'C') ) THEN
  216. INFO = -1
  217. ELSE IF( N.LT.0 ) THEN
  218. INFO = -2
  219. ELSE IF( KL.LT.0 .OR. KL.GT.N-1 ) THEN
  220. INFO = -3
  221. ELSE IF( KU.LT.0 .OR. KU.GT.N-1 ) THEN
  222. INFO = -4
  223. ELSE IF( LDAB.LT.KL+KU+1 ) THEN
  224. INFO = -6
  225. ELSE IF( LDAFB.LT.2*KL+KU+1 ) THEN
  226. INFO = -8
  227. END IF
  228. IF( INFO.NE.0 ) THEN
  229. CALL XERBLA( 'DLA_GBRCOND', -INFO )
  230. RETURN
  231. END IF
  232. IF( N.EQ.0 ) THEN
  233. DLA_GBRCOND = 1.0D+0
  234. RETURN
  235. END IF
  236. *
  237. * Compute the equilibration matrix R such that
  238. * inv(R)*A*C has unit 1-norm.
  239. *
  240. KD = KU + 1
  241. KE = KL + 1
  242. IF ( NOTRANS ) THEN
  243. DO I = 1, N
  244. TMP = 0.0D+0
  245. IF ( CMODE .EQ. 1 ) THEN
  246. DO J = MAX( I-KL, 1 ), MIN( I+KU, N )
  247. TMP = TMP + ABS( AB( KD+I-J, J ) * C( J ) )
  248. END DO
  249. ELSE IF ( CMODE .EQ. 0 ) THEN
  250. DO J = MAX( I-KL, 1 ), MIN( I+KU, N )
  251. TMP = TMP + ABS( AB( KD+I-J, J ) )
  252. END DO
  253. ELSE
  254. DO J = MAX( I-KL, 1 ), MIN( I+KU, N )
  255. TMP = TMP + ABS( AB( KD+I-J, J ) / C( J ) )
  256. END DO
  257. END IF
  258. WORK( 2*N+I ) = TMP
  259. END DO
  260. ELSE
  261. DO I = 1, N
  262. TMP = 0.0D+0
  263. IF ( CMODE .EQ. 1 ) THEN
  264. DO J = MAX( I-KL, 1 ), MIN( I+KU, N )
  265. TMP = TMP + ABS( AB( KE-I+J, I ) * C( J ) )
  266. END DO
  267. ELSE IF ( CMODE .EQ. 0 ) THEN
  268. DO J = MAX( I-KL, 1 ), MIN( I+KU, N )
  269. TMP = TMP + ABS( AB( KE-I+J, I ) )
  270. END DO
  271. ELSE
  272. DO J = MAX( I-KL, 1 ), MIN( I+KU, N )
  273. TMP = TMP + ABS( AB( KE-I+J, I ) / C( J ) )
  274. END DO
  275. END IF
  276. WORK( 2*N+I ) = TMP
  277. END DO
  278. END IF
  279. *
  280. * Estimate the norm of inv(op(A)).
  281. *
  282. AINVNM = 0.0D+0
  283. KASE = 0
  284. 10 CONTINUE
  285. CALL DLACN2( N, WORK( N+1 ), WORK, IWORK, AINVNM, KASE, ISAVE )
  286. IF( KASE.NE.0 ) THEN
  287. IF( KASE.EQ.2 ) THEN
  288. *
  289. * Multiply by R.
  290. *
  291. DO I = 1, N
  292. WORK( I ) = WORK( I ) * WORK( 2*N+I )
  293. END DO
  294. IF ( NOTRANS ) THEN
  295. CALL DGBTRS( 'No transpose', N, KL, KU, 1, AFB, LDAFB,
  296. $ IPIV, WORK, N, INFO )
  297. ELSE
  298. CALL DGBTRS( 'Transpose', N, KL, KU, 1, AFB, LDAFB, IPIV,
  299. $ WORK, N, INFO )
  300. END IF
  301. *
  302. * Multiply by inv(C).
  303. *
  304. IF ( CMODE .EQ. 1 ) THEN
  305. DO I = 1, N
  306. WORK( I ) = WORK( I ) / C( I )
  307. END DO
  308. ELSE IF ( CMODE .EQ. -1 ) THEN
  309. DO I = 1, N
  310. WORK( I ) = WORK( I ) * C( I )
  311. END DO
  312. END IF
  313. ELSE
  314. *
  315. * Multiply by inv(C**T).
  316. *
  317. IF ( CMODE .EQ. 1 ) THEN
  318. DO I = 1, N
  319. WORK( I ) = WORK( I ) / C( I )
  320. END DO
  321. ELSE IF ( CMODE .EQ. -1 ) THEN
  322. DO I = 1, N
  323. WORK( I ) = WORK( I ) * C( I )
  324. END DO
  325. END IF
  326. IF ( NOTRANS ) THEN
  327. CALL DGBTRS( 'Transpose', N, KL, KU, 1, AFB, LDAFB, IPIV,
  328. $ WORK, N, INFO )
  329. ELSE
  330. CALL DGBTRS( 'No transpose', N, KL, KU, 1, AFB, LDAFB,
  331. $ IPIV, WORK, N, INFO )
  332. END IF
  333. *
  334. * Multiply by R.
  335. *
  336. DO I = 1, N
  337. WORK( I ) = WORK( I ) * WORK( 2*N+I )
  338. END DO
  339. END IF
  340. GO TO 10
  341. END IF
  342. *
  343. * Compute the estimate of the reciprocal condition number.
  344. *
  345. IF( AINVNM .NE. 0.0D+0 )
  346. $ DLA_GBRCOND = ( 1.0D+0 / AINVNM )
  347. *
  348. RETURN
  349. *
  350. END