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_herpvgrw.f 9.8 kB

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