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