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.

zla_syrpvgrw.f 10 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. *> \brief \b ZLA_SYRPVGRW computes the reciprocal pivot growth factor norm(A)/norm(U) for a symmetric indefinite matrix.
  2. *
  3. * =========== DOCUMENTATION ===========
  4. *
  5. * Online html documentation available at
  6. * http://www.netlib.org/lapack/explore-html/
  7. *
  8. *> \htmlonly
  9. *> Download ZLA_SYRPVGRW + dependencies
  10. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zla_syrpvgrw.f">
  11. *> [TGZ]</a>
  12. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zla_syrpvgrw.f">
  13. *> [ZIP]</a>
  14. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zla_syrpvgrw.f">
  15. *> [TXT]</a>
  16. *> \endhtmlonly
  17. *
  18. * Definition:
  19. * ===========
  20. *
  21. * DOUBLE PRECISION FUNCTION ZLA_SYRPVGRW( UPLO, N, INFO, A, LDA, AF,
  22. * LDAF, IPIV, WORK )
  23. *
  24. * .. Scalar Arguments ..
  25. * CHARACTER*1 UPLO
  26. * INTEGER N, INFO, LDA, LDAF
  27. * ..
  28. * .. Array Arguments ..
  29. * COMPLEX*16 A( LDA, * ), AF( LDAF, * )
  30. * DOUBLE PRECISION WORK( * )
  31. * INTEGER IPIV( * )
  32. * ..
  33. *
  34. *
  35. *> \par Purpose:
  36. * =============
  37. *>
  38. *> \verbatim
  39. *>
  40. *>
  41. *> ZLA_SYRPVGRW computes the reciprocal pivot growth factor
  42. *> norm(A)/norm(U). The "max absolute element" norm is used. If this is
  43. *> much less than 1, the stability of the LU factorization of the
  44. *> (equilibrated) matrix A could be poor. This also means that the
  45. *> solution X, estimated condition numbers, and error bounds could be
  46. *> unreliable.
  47. *> \endverbatim
  48. *
  49. * Arguments:
  50. * ==========
  51. *
  52. *> \param[in] UPLO
  53. *> \verbatim
  54. *> UPLO is CHARACTER*1
  55. *> = 'U': Upper triangle of A is stored;
  56. *> = 'L': Lower triangle of A is stored.
  57. *> \endverbatim
  58. *>
  59. *> \param[in] N
  60. *> \verbatim
  61. *> N is INTEGER
  62. *> The number of linear equations, i.e., the order of the
  63. *> matrix A. N >= 0.
  64. *> \endverbatim
  65. *>
  66. *> \param[in] INFO
  67. *> \verbatim
  68. *> INFO is INTEGER
  69. *> The value of INFO returned from ZSYTRF, .i.e., the pivot in
  70. *> column INFO is exactly 0.
  71. *> \endverbatim
  72. *>
  73. *> \param[in] A
  74. *> \verbatim
  75. *> A is COMPLEX*16 array, dimension (LDA,N)
  76. *> On entry, the N-by-N matrix A.
  77. *> \endverbatim
  78. *>
  79. *> \param[in] LDA
  80. *> \verbatim
  81. *> LDA is INTEGER
  82. *> The leading dimension of the array A. LDA >= max(1,N).
  83. *> \endverbatim
  84. *>
  85. *> \param[in] AF
  86. *> \verbatim
  87. *> AF is COMPLEX*16 array, dimension (LDAF,N)
  88. *> The block diagonal matrix D and the multipliers used to
  89. *> obtain the factor U or L as computed by ZSYTRF.
  90. *> \endverbatim
  91. *>
  92. *> \param[in] LDAF
  93. *> \verbatim
  94. *> LDAF is INTEGER
  95. *> The leading dimension of the array AF. LDAF >= max(1,N).
  96. *> \endverbatim
  97. *>
  98. *> \param[in] IPIV
  99. *> \verbatim
  100. *> IPIV is INTEGER array, dimension (N)
  101. *> Details of the interchanges and the block structure of D
  102. *> as determined by ZSYTRF.
  103. *> \endverbatim
  104. *>
  105. *> \param[out] WORK
  106. *> \verbatim
  107. *> WORK is DOUBLE PRECISION array, dimension (2*N)
  108. *> \endverbatim
  109. *
  110. * Authors:
  111. * ========
  112. *
  113. *> \author Univ. of Tennessee
  114. *> \author Univ. of California Berkeley
  115. *> \author Univ. of Colorado Denver
  116. *> \author NAG Ltd.
  117. *
  118. *> \ingroup complex16SYcomputational
  119. *
  120. * =====================================================================
  121. DOUBLE PRECISION FUNCTION ZLA_SYRPVGRW( UPLO, N, INFO, A, LDA, AF,
  122. $ LDAF, IPIV, WORK )
  123. *
  124. * -- LAPACK computational routine --
  125. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  126. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  127. *
  128. * .. Scalar Arguments ..
  129. CHARACTER*1 UPLO
  130. INTEGER N, INFO, LDA, LDAF
  131. * ..
  132. * .. Array Arguments ..
  133. COMPLEX*16 A( LDA, * ), AF( LDAF, * )
  134. DOUBLE PRECISION WORK( * )
  135. INTEGER IPIV( * )
  136. * ..
  137. *
  138. * =====================================================================
  139. *
  140. * .. Local Scalars ..
  141. INTEGER NCOLS, I, J, K, KP
  142. DOUBLE PRECISION AMAX, UMAX, RPVGRW, TMP
  143. LOGICAL UPPER
  144. COMPLEX*16 ZDUM
  145. * ..
  146. * .. Intrinsic Functions ..
  147. INTRINSIC ABS, REAL, DIMAG, MAX, MIN
  148. * ..
  149. * .. External Subroutines ..
  150. EXTERNAL LSAME
  151. LOGICAL LSAME
  152. * ..
  153. * .. Statement Functions ..
  154. DOUBLE PRECISION CABS1
  155. * ..
  156. * .. Statement Function Definitions ..
  157. CABS1( ZDUM ) = ABS( DBLE ( ZDUM ) ) + ABS( DIMAG ( ZDUM ) )
  158. * ..
  159. * .. Executable Statements ..
  160. *
  161. UPPER = LSAME( 'Upper', UPLO )
  162. IF ( INFO.EQ.0 ) THEN
  163. IF ( UPPER ) THEN
  164. NCOLS = 1
  165. ELSE
  166. NCOLS = N
  167. END IF
  168. ELSE
  169. NCOLS = INFO
  170. END IF
  171. RPVGRW = 1.0D+0
  172. DO I = 1, 2*N
  173. WORK( I ) = 0.0D+0
  174. END DO
  175. *
  176. * Find the max magnitude entry of each column of A. Compute the max
  177. * for all N columns so we can apply the pivot permutation while
  178. * looping below. Assume a full factorization is the common case.
  179. *
  180. IF ( UPPER ) THEN
  181. DO J = 1, N
  182. DO I = 1, J
  183. WORK( N+I ) = MAX( CABS1( A( I, J ) ), WORK( N+I ) )
  184. WORK( N+J ) = MAX( CABS1( A( I, J ) ), WORK( N+J ) )
  185. END DO
  186. END DO
  187. ELSE
  188. DO J = 1, N
  189. DO I = J, N
  190. WORK( N+I ) = MAX( CABS1( A( I, J ) ), WORK( N+I ) )
  191. WORK( N+J ) = MAX( CABS1( A( I, J ) ), WORK( N+J ) )
  192. END DO
  193. END DO
  194. END IF
  195. *
  196. * Now find the max magnitude entry of each column of U or L. Also
  197. * permute the magnitudes of A above so they're in the same order as
  198. * the factor.
  199. *
  200. * The iteration orders and permutations were copied from zsytrs.
  201. * Calls to SSWAP would be severe overkill.
  202. *
  203. IF ( UPPER ) THEN
  204. K = N
  205. DO WHILE ( K .LT. NCOLS .AND. K.GT.0 )
  206. IF ( IPIV( K ).GT.0 ) THEN
  207. ! 1x1 pivot
  208. KP = IPIV( K )
  209. IF ( KP .NE. K ) THEN
  210. TMP = WORK( N+K )
  211. WORK( N+K ) = WORK( N+KP )
  212. WORK( N+KP ) = TMP
  213. END IF
  214. DO I = 1, K
  215. WORK( K ) = MAX( CABS1( AF( I, K ) ), WORK( K ) )
  216. END DO
  217. K = K - 1
  218. ELSE
  219. ! 2x2 pivot
  220. KP = -IPIV( K )
  221. TMP = WORK( N+K-1 )
  222. WORK( N+K-1 ) = WORK( N+KP )
  223. WORK( N+KP ) = TMP
  224. DO I = 1, K-1
  225. WORK( K ) = MAX( CABS1( AF( I, K ) ), WORK( K ) )
  226. WORK( K-1 ) =
  227. $ MAX( CABS1( AF( I, K-1 ) ), WORK( K-1 ) )
  228. END DO
  229. WORK( K ) = MAX( CABS1( AF( K, K ) ), WORK( K ) )
  230. K = K - 2
  231. END IF
  232. END DO
  233. K = NCOLS
  234. DO WHILE ( K .LE. N )
  235. IF ( IPIV( K ).GT.0 ) THEN
  236. KP = IPIV( K )
  237. IF ( KP .NE. K ) THEN
  238. TMP = WORK( N+K )
  239. WORK( N+K ) = WORK( N+KP )
  240. WORK( N+KP ) = TMP
  241. END IF
  242. K = K + 1
  243. ELSE
  244. KP = -IPIV( K )
  245. TMP = WORK( N+K )
  246. WORK( N+K ) = WORK( N+KP )
  247. WORK( N+KP ) = TMP
  248. K = K + 2
  249. END IF
  250. END DO
  251. ELSE
  252. K = 1
  253. DO WHILE ( K .LE. NCOLS )
  254. IF ( IPIV( K ).GT.0 ) THEN
  255. ! 1x1 pivot
  256. KP = IPIV( K )
  257. IF ( KP .NE. K ) THEN
  258. TMP = WORK( N+K )
  259. WORK( N+K ) = WORK( N+KP )
  260. WORK( N+KP ) = TMP
  261. END IF
  262. DO I = K, N
  263. WORK( K ) = MAX( CABS1( AF( I, K ) ), WORK( K ) )
  264. END DO
  265. K = K + 1
  266. ELSE
  267. ! 2x2 pivot
  268. KP = -IPIV( K )
  269. TMP = WORK( N+K+1 )
  270. WORK( N+K+1 ) = WORK( N+KP )
  271. WORK( N+KP ) = TMP
  272. DO I = K+1, N
  273. WORK( K ) = MAX( CABS1( AF( I, K ) ), WORK( K ) )
  274. WORK( K+1 ) =
  275. $ MAX( CABS1( AF( I, K+1 ) ), WORK( K+1 ) )
  276. END DO
  277. WORK( K ) = MAX( CABS1( AF( K, K ) ), WORK( K ) )
  278. K = K + 2
  279. END IF
  280. END DO
  281. K = NCOLS
  282. DO WHILE ( K .GE. 1 )
  283. IF ( IPIV( K ).GT.0 ) THEN
  284. KP = IPIV( K )
  285. IF ( KP .NE. K ) THEN
  286. TMP = WORK( N+K )
  287. WORK( N+K ) = WORK( N+KP )
  288. WORK( N+KP ) = TMP
  289. END IF
  290. K = K - 1
  291. ELSE
  292. KP = -IPIV( K )
  293. TMP = WORK( N+K )
  294. WORK( N+K ) = WORK( N+KP )
  295. WORK( N+KP ) = TMP
  296. K = K - 2
  297. ENDIF
  298. END DO
  299. END IF
  300. *
  301. * Compute the *inverse* of the max element growth factor. Dividing
  302. * by zero would imply the largest entry of the factor's column is
  303. * zero. Than can happen when either the column of A is zero or
  304. * massive pivots made the factor underflow to zero. Neither counts
  305. * as growth in itself, so simply ignore terms with zero
  306. * denominators.
  307. *
  308. IF ( UPPER ) THEN
  309. DO I = NCOLS, N
  310. UMAX = WORK( I )
  311. AMAX = WORK( N+I )
  312. IF ( UMAX /= 0.0D+0 ) THEN
  313. RPVGRW = MIN( AMAX / UMAX, RPVGRW )
  314. END IF
  315. END DO
  316. ELSE
  317. DO I = 1, NCOLS
  318. UMAX = WORK( I )
  319. AMAX = WORK( N+I )
  320. IF ( UMAX /= 0.0D+0 ) THEN
  321. RPVGRW = MIN( AMAX / UMAX, RPVGRW )
  322. END IF
  323. END DO
  324. END IF
  325. ZLA_SYRPVGRW = RPVGRW
  326. *
  327. * End of ZLA_SYRPVGRW
  328. *
  329. END