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.7 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[in] 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. *> \date September 2012
  118. *
  119. *> \ingroup doubleSYcomputational
  120. *
  121. * =====================================================================
  122. DOUBLE PRECISION FUNCTION DLA_SYRPVGRW( UPLO, N, INFO, A, LDA, AF,
  123. $ LDAF, IPIV, WORK )
  124. *
  125. * -- LAPACK computational routine (version 3.4.2) --
  126. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  127. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  128. * September 2012
  129. *
  130. * .. Scalar Arguments ..
  131. CHARACTER*1 UPLO
  132. INTEGER N, INFO, LDA, LDAF
  133. * ..
  134. * .. Array Arguments ..
  135. INTEGER IPIV( * )
  136. DOUBLE PRECISION A( LDA, * ), AF( LDAF, * ), WORK( * )
  137. * ..
  138. *
  139. * =====================================================================
  140. *
  141. * .. Local Scalars ..
  142. INTEGER NCOLS, I, J, K, KP
  143. DOUBLE PRECISION AMAX, UMAX, RPVGRW, TMP
  144. LOGICAL UPPER
  145. * ..
  146. * .. Intrinsic Functions ..
  147. INTRINSIC ABS, MAX, MIN
  148. * ..
  149. * .. External Functions ..
  150. EXTERNAL LSAME, DLASET
  151. LOGICAL LSAME
  152. * ..
  153. * .. Executable Statements ..
  154. *
  155. UPPER = LSAME( 'Upper', UPLO )
  156. IF ( INFO.EQ.0 ) THEN
  157. IF ( UPPER ) THEN
  158. NCOLS = 1
  159. ELSE
  160. NCOLS = N
  161. END IF
  162. ELSE
  163. NCOLS = INFO
  164. END IF
  165. RPVGRW = 1.0D+0
  166. DO I = 1, 2*N
  167. WORK( I ) = 0.0D+0
  168. END DO
  169. *
  170. * Find the max magnitude entry of each column of A. Compute the max
  171. * for all N columns so we can apply the pivot permutation while
  172. * looping below. Assume a full factorization is the common case.
  173. *
  174. IF ( UPPER ) THEN
  175. DO J = 1, N
  176. DO I = 1, J
  177. WORK( N+I ) = MAX( ABS( A( I, J ) ), WORK( N+I ) )
  178. WORK( N+J ) = MAX( ABS( A( I, J ) ), WORK( N+J ) )
  179. END DO
  180. END DO
  181. ELSE
  182. DO J = 1, N
  183. DO I = J, N
  184. WORK( N+I ) = MAX( ABS( A( I, J ) ), WORK( N+I ) )
  185. WORK( N+J ) = MAX( ABS( A( I, J ) ), WORK( N+J ) )
  186. END DO
  187. END DO
  188. END IF
  189. *
  190. * Now find the max magnitude entry of each column of U or L. Also
  191. * permute the magnitudes of A above so they're in the same order as
  192. * the factor.
  193. *
  194. * The iteration orders and permutations were copied from dsytrs.
  195. * Calls to SSWAP would be severe overkill.
  196. *
  197. IF ( UPPER ) THEN
  198. K = N
  199. DO WHILE ( K .LT. NCOLS .AND. K.GT.0 )
  200. IF ( IPIV( K ).GT.0 ) THEN
  201. ! 1x1 pivot
  202. KP = IPIV( K )
  203. IF ( KP .NE. K ) THEN
  204. TMP = WORK( N+K )
  205. WORK( N+K ) = WORK( N+KP )
  206. WORK( N+KP ) = TMP
  207. END IF
  208. DO I = 1, K
  209. WORK( K ) = MAX( ABS( AF( I, K ) ), WORK( K ) )
  210. END DO
  211. K = K - 1
  212. ELSE
  213. ! 2x2 pivot
  214. KP = -IPIV( K )
  215. TMP = WORK( N+K-1 )
  216. WORK( N+K-1 ) = WORK( N+KP )
  217. WORK( N+KP ) = TMP
  218. DO I = 1, K-1
  219. WORK( K ) = MAX( ABS( AF( I, K ) ), WORK( K ) )
  220. WORK( K-1 ) = MAX( ABS( AF( I, K-1 ) ), WORK( K-1 ) )
  221. END DO
  222. WORK( K ) = MAX( ABS( AF( K, K ) ), WORK( K ) )
  223. K = K - 2
  224. END IF
  225. END DO
  226. K = NCOLS
  227. DO WHILE ( K .LE. N )
  228. IF ( IPIV( K ).GT.0 ) THEN
  229. KP = IPIV( K )
  230. IF ( KP .NE. K ) THEN
  231. TMP = WORK( N+K )
  232. WORK( N+K ) = WORK( N+KP )
  233. WORK( N+KP ) = TMP
  234. END IF
  235. K = K + 1
  236. ELSE
  237. KP = -IPIV( K )
  238. TMP = WORK( N+K )
  239. WORK( N+K ) = WORK( N+KP )
  240. WORK( N+KP ) = TMP
  241. K = K + 2
  242. END IF
  243. END DO
  244. ELSE
  245. K = 1
  246. DO WHILE ( K .LE. NCOLS )
  247. IF ( IPIV( K ).GT.0 ) THEN
  248. ! 1x1 pivot
  249. KP = IPIV( K )
  250. IF ( KP .NE. K ) THEN
  251. TMP = WORK( N+K )
  252. WORK( N+K ) = WORK( N+KP )
  253. WORK( N+KP ) = TMP
  254. END IF
  255. DO I = K, N
  256. WORK( K ) = MAX( ABS( AF( I, K ) ), WORK( K ) )
  257. END DO
  258. K = K + 1
  259. ELSE
  260. ! 2x2 pivot
  261. KP = -IPIV( K )
  262. TMP = WORK( N+K+1 )
  263. WORK( N+K+1 ) = WORK( N+KP )
  264. WORK( N+KP ) = TMP
  265. DO I = K+1, N
  266. WORK( K ) = MAX( ABS( AF( I, K ) ), WORK( K ) )
  267. WORK( K+1 ) = MAX( ABS( AF(I, K+1 ) ), WORK( K+1 ) )
  268. END DO
  269. WORK( K ) = MAX( ABS( AF( K, K ) ), WORK( K ) )
  270. K = K + 2
  271. END IF
  272. END DO
  273. K = NCOLS
  274. DO WHILE ( K .GE. 1 )
  275. IF ( IPIV( K ).GT.0 ) THEN
  276. KP = IPIV( K )
  277. IF ( KP .NE. K ) THEN
  278. TMP = WORK( N+K )
  279. WORK( N+K ) = WORK( N+KP )
  280. WORK( N+KP ) = TMP
  281. END IF
  282. K = K - 1
  283. ELSE
  284. KP = -IPIV( K )
  285. TMP = WORK( N+K )
  286. WORK( N+K ) = WORK( N+KP )
  287. WORK( N+KP ) = TMP
  288. K = K - 2
  289. ENDIF
  290. END DO
  291. END IF
  292. *
  293. * Compute the *inverse* of the max element growth factor. Dividing
  294. * by zero would imply the largest entry of the factor's column is
  295. * zero. Than can happen when either the column of A is zero or
  296. * massive pivots made the factor underflow to zero. Neither counts
  297. * as growth in itself, so simply ignore terms with zero
  298. * denominators.
  299. *
  300. IF ( UPPER ) THEN
  301. DO I = NCOLS, N
  302. UMAX = WORK( I )
  303. AMAX = WORK( N+I )
  304. IF ( UMAX /= 0.0D+0 ) THEN
  305. RPVGRW = MIN( AMAX / UMAX, RPVGRW )
  306. END IF
  307. END DO
  308. ELSE
  309. DO I = 1, NCOLS
  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. END IF
  317. DLA_SYRPVGRW = RPVGRW
  318. END