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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. *> \brief \b CLA_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 CLA_SYRPVGRW + dependencies
  10. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cla_syrpvgrw.f">
  11. *> [TGZ]</a>
  12. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cla_syrpvgrw.f">
  13. *> [ZIP]</a>
  14. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cla_syrpvgrw.f">
  15. *> [TXT]</a>
  16. *> \endhtmlonly
  17. *
  18. * Definition:
  19. * ===========
  20. *
  21. * REAL FUNCTION CLA_SYRPVGRW( UPLO, N, INFO, A, LDA, AF, LDAF, IPIV,
  22. * WORK )
  23. *
  24. * .. Scalar Arguments ..
  25. * CHARACTER*1 UPLO
  26. * INTEGER N, INFO, LDA, LDAF
  27. * ..
  28. * .. Array Arguments ..
  29. * COMPLEX A( LDA, * ), AF( LDAF, * )
  30. * REAL WORK( * )
  31. * INTEGER IPIV( * )
  32. * ..
  33. *
  34. *
  35. *> \par Purpose:
  36. * =============
  37. *>
  38. *> \verbatim
  39. *>
  40. *>
  41. *> CLA_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 CSYTRF, .i.e., the pivot in
  70. *> column INFO is exactly 0.
  71. *> \endverbatim
  72. *>
  73. *> \param[in] A
  74. *> \verbatim
  75. *> A is COMPLEX 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 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 CSYTRF.
  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 CSYTRF.
  103. *> \endverbatim
  104. *>
  105. *> \param[in] WORK
  106. *> \verbatim
  107. *> WORK is COMPLEX 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. *> \date September 2012
  119. *
  120. *> \ingroup complexSYcomputational
  121. *
  122. * =====================================================================
  123. REAL FUNCTION CLA_SYRPVGRW( UPLO, N, INFO, A, LDA, AF, LDAF, IPIV,
  124. $ WORK )
  125. *
  126. * -- LAPACK computational routine (version 3.4.2) --
  127. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  128. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  129. * September 2012
  130. *
  131. * .. Scalar Arguments ..
  132. CHARACTER*1 UPLO
  133. INTEGER N, INFO, LDA, LDAF
  134. * ..
  135. * .. Array Arguments ..
  136. COMPLEX A( LDA, * ), AF( LDAF, * )
  137. REAL WORK( * )
  138. INTEGER IPIV( * )
  139. * ..
  140. *
  141. * =====================================================================
  142. *
  143. * .. Local Scalars ..
  144. INTEGER NCOLS, I, J, K, KP
  145. REAL AMAX, UMAX, RPVGRW, TMP
  146. LOGICAL UPPER
  147. COMPLEX ZDUM
  148. * ..
  149. * .. Intrinsic Functions ..
  150. INTRINSIC ABS, REAL, AIMAG, MAX, MIN
  151. * ..
  152. * .. External Subroutines ..
  153. EXTERNAL LSAME, CLASET
  154. LOGICAL LSAME
  155. * ..
  156. * .. Statement Functions ..
  157. REAL CABS1
  158. * ..
  159. * .. Statement Function Definitions ..
  160. CABS1( ZDUM ) = ABS( REAL ( ZDUM ) ) + ABS( AIMAG ( ZDUM ) )
  161. * ..
  162. * .. Executable Statements ..
  163. *
  164. UPPER = LSAME( 'Upper', UPLO )
  165. IF ( INFO.EQ.0 ) THEN
  166. IF ( UPPER ) THEN
  167. NCOLS = 1
  168. ELSE
  169. NCOLS = N
  170. END IF
  171. ELSE
  172. NCOLS = INFO
  173. END IF
  174. RPVGRW = 1.0
  175. DO I = 1, 2*N
  176. WORK( I ) = 0.0
  177. END DO
  178. *
  179. * Find the max magnitude entry of each column of A. Compute the max
  180. * for all N columns so we can apply the pivot permutation while
  181. * looping below. Assume a full factorization is the common case.
  182. *
  183. IF ( UPPER ) THEN
  184. DO J = 1, N
  185. DO I = 1, J
  186. WORK( N+I ) = MAX( CABS1( A( I, J ) ), WORK( N+I ) )
  187. WORK( N+J ) = MAX( CABS1( A( I, J ) ), WORK( N+J ) )
  188. END DO
  189. END DO
  190. ELSE
  191. DO J = 1, N
  192. DO I = J, N
  193. WORK( N+I ) = MAX( CABS1( A( I, J ) ), WORK( N+I ) )
  194. WORK( N+J ) = MAX( CABS1( A( I, J ) ), WORK( N+J ) )
  195. END DO
  196. END DO
  197. END IF
  198. *
  199. * Now find the max magnitude entry of each column of U or L. Also
  200. * permute the magnitudes of A above so they're in the same order as
  201. * the factor.
  202. *
  203. * The iteration orders and permutations were copied from csytrs.
  204. * Calls to SSWAP would be severe overkill.
  205. *
  206. IF ( UPPER ) THEN
  207. K = N
  208. DO WHILE ( K .LT. NCOLS .AND. K.GT.0 )
  209. IF ( IPIV( K ).GT.0 ) THEN
  210. ! 1x1 pivot
  211. KP = IPIV( K )
  212. IF ( KP .NE. K ) THEN
  213. TMP = WORK( N+K )
  214. WORK( N+K ) = WORK( N+KP )
  215. WORK( N+KP ) = TMP
  216. END IF
  217. DO I = 1, K
  218. WORK( K ) = MAX( CABS1( AF( I, K ) ), WORK( K ) )
  219. END DO
  220. K = K - 1
  221. ELSE
  222. ! 2x2 pivot
  223. KP = -IPIV( K )
  224. TMP = WORK( N+K-1 )
  225. WORK( N+K-1 ) = WORK( N+KP )
  226. WORK( N+KP ) = TMP
  227. DO I = 1, K-1
  228. WORK( K ) = MAX( CABS1( AF( I, K ) ), WORK( K ) )
  229. WORK( K-1 ) =
  230. $ MAX( CABS1( AF( I, K-1 ) ), WORK( K-1 ) )
  231. END DO
  232. WORK( K ) = MAX( CABS1( AF( K, K ) ), WORK( K ) )
  233. K = K - 2
  234. END IF
  235. END DO
  236. K = NCOLS
  237. DO WHILE ( K .LE. N )
  238. IF ( IPIV( K ).GT.0 ) THEN
  239. KP = IPIV( K )
  240. IF ( KP .NE. K ) THEN
  241. TMP = WORK( N+K )
  242. WORK( N+K ) = WORK( N+KP )
  243. WORK( N+KP ) = TMP
  244. END IF
  245. K = K + 1
  246. ELSE
  247. KP = -IPIV( K )
  248. TMP = WORK( N+K )
  249. WORK( N+K ) = WORK( N+KP )
  250. WORK( N+KP ) = TMP
  251. K = K + 2
  252. END IF
  253. END DO
  254. ELSE
  255. K = 1
  256. DO WHILE ( K .LE. NCOLS )
  257. IF ( IPIV( K ).GT.0 ) THEN
  258. ! 1x1 pivot
  259. KP = IPIV( K )
  260. IF ( KP .NE. K ) THEN
  261. TMP = WORK( N+K )
  262. WORK( N+K ) = WORK( N+KP )
  263. WORK( N+KP ) = TMP
  264. END IF
  265. DO I = K, N
  266. WORK( K ) = MAX( CABS1( AF( I, K ) ), WORK( K ) )
  267. END DO
  268. K = K + 1
  269. ELSE
  270. ! 2x2 pivot
  271. KP = -IPIV( K )
  272. TMP = WORK( N+K+1 )
  273. WORK( N+K+1 ) = WORK( N+KP )
  274. WORK( N+KP ) = TMP
  275. DO I = K+1, N
  276. WORK( K ) = MAX( CABS1( AF( I, K ) ), WORK( K ) )
  277. WORK( K+1 ) =
  278. $ MAX( CABS1( AF( I, K+1 ) ), WORK( K+1 ) )
  279. END DO
  280. WORK( K ) = MAX( CABS1( AF( K, K ) ), WORK( K ) )
  281. K = K + 2
  282. END IF
  283. END DO
  284. K = NCOLS
  285. DO WHILE ( K .GE. 1 )
  286. IF ( IPIV( K ).GT.0 ) THEN
  287. KP = IPIV( K )
  288. IF ( KP .NE. K ) THEN
  289. TMP = WORK( N+K )
  290. WORK( N+K ) = WORK( N+KP )
  291. WORK( N+KP ) = TMP
  292. END IF
  293. K = K - 1
  294. ELSE
  295. KP = -IPIV( K )
  296. TMP = WORK( N+K )
  297. WORK( N+K ) = WORK( N+KP )
  298. WORK( N+KP ) = TMP
  299. K = K - 2
  300. ENDIF
  301. END DO
  302. END IF
  303. *
  304. * Compute the *inverse* of the max element growth factor. Dividing
  305. * by zero would imply the largest entry of the factor's column is
  306. * zero. Than can happen when either the column of A is zero or
  307. * massive pivots made the factor underflow to zero. Neither counts
  308. * as growth in itself, so simply ignore terms with zero
  309. * denominators.
  310. *
  311. IF ( UPPER ) THEN
  312. DO I = NCOLS, N
  313. UMAX = WORK( I )
  314. AMAX = WORK( N+I )
  315. IF ( UMAX /= 0.0 ) THEN
  316. RPVGRW = MIN( AMAX / UMAX, RPVGRW )
  317. END IF
  318. END DO
  319. ELSE
  320. DO I = 1, NCOLS
  321. UMAX = WORK( I )
  322. AMAX = WORK( N+I )
  323. IF ( UMAX /= 0.0 ) THEN
  324. RPVGRW = MIN( AMAX / UMAX, RPVGRW )
  325. END IF
  326. END DO
  327. END IF
  328. CLA_SYRPVGRW = RPVGRW
  329. END