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_syrpvgrw.f 9.6 kB

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