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.

spbequ.f 6.6 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. *> \brief \b SPBEQU
  2. *
  3. * =========== DOCUMENTATION ===========
  4. *
  5. * Online html documentation available at
  6. * http://www.netlib.org/lapack/explore-html/
  7. *
  8. *> \htmlonly
  9. *> Download SPBEQU + dependencies
  10. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/spbequ.f">
  11. *> [TGZ]</a>
  12. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/spbequ.f">
  13. *> [ZIP]</a>
  14. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/spbequ.f">
  15. *> [TXT]</a>
  16. *> \endhtmlonly
  17. *
  18. * Definition:
  19. * ===========
  20. *
  21. * SUBROUTINE SPBEQU( UPLO, N, KD, AB, LDAB, S, SCOND, AMAX, INFO )
  22. *
  23. * .. Scalar Arguments ..
  24. * CHARACTER UPLO
  25. * INTEGER INFO, KD, LDAB, N
  26. * REAL AMAX, SCOND
  27. * ..
  28. * .. Array Arguments ..
  29. * REAL AB( LDAB, * ), S( * )
  30. * ..
  31. *
  32. *
  33. *> \par Purpose:
  34. * =============
  35. *>
  36. *> \verbatim
  37. *>
  38. *> SPBEQU computes row and column scalings intended to equilibrate a
  39. *> symmetric positive definite band matrix A and reduce its condition
  40. *> number (with respect to the two-norm). S contains the scale factors,
  41. *> S(i) = 1/sqrt(A(i,i)), chosen so that the scaled matrix B with
  42. *> elements B(i,j) = S(i)*A(i,j)*S(j) has ones on the diagonal. This
  43. *> choice of S puts the condition number of B within a factor N of the
  44. *> smallest possible condition number over all possible diagonal
  45. *> scalings.
  46. *> \endverbatim
  47. *
  48. * Arguments:
  49. * ==========
  50. *
  51. *> \param[in] UPLO
  52. *> \verbatim
  53. *> UPLO is CHARACTER*1
  54. *> = 'U': Upper triangular of A is stored;
  55. *> = 'L': Lower triangular of A is stored.
  56. *> \endverbatim
  57. *>
  58. *> \param[in] N
  59. *> \verbatim
  60. *> N is INTEGER
  61. *> The order of the matrix A. N >= 0.
  62. *> \endverbatim
  63. *>
  64. *> \param[in] KD
  65. *> \verbatim
  66. *> KD is INTEGER
  67. *> The number of superdiagonals of the matrix A if UPLO = 'U',
  68. *> or the number of subdiagonals if UPLO = 'L'. KD >= 0.
  69. *> \endverbatim
  70. *>
  71. *> \param[in] AB
  72. *> \verbatim
  73. *> AB is REAL array, dimension (LDAB,N)
  74. *> The upper or lower triangle of the symmetric band matrix A,
  75. *> stored in the first KD+1 rows of the array. The j-th column
  76. *> of A is stored in the j-th column of the array AB as follows:
  77. *> if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for max(1,j-kd)<=i<=j;
  78. *> if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=min(n,j+kd).
  79. *> \endverbatim
  80. *>
  81. *> \param[in] LDAB
  82. *> \verbatim
  83. *> LDAB is INTEGER
  84. *> The leading dimension of the array A. LDAB >= KD+1.
  85. *> \endverbatim
  86. *>
  87. *> \param[out] S
  88. *> \verbatim
  89. *> S is REAL array, dimension (N)
  90. *> If INFO = 0, S contains the scale factors for A.
  91. *> \endverbatim
  92. *>
  93. *> \param[out] SCOND
  94. *> \verbatim
  95. *> SCOND is REAL
  96. *> If INFO = 0, S contains the ratio of the smallest S(i) to
  97. *> the largest S(i). If SCOND >= 0.1 and AMAX is neither too
  98. *> large nor too small, it is not worth scaling by S.
  99. *> \endverbatim
  100. *>
  101. *> \param[out] AMAX
  102. *> \verbatim
  103. *> AMAX is REAL
  104. *> Absolute value of largest matrix element. If AMAX is very
  105. *> close to overflow or very close to underflow, the matrix
  106. *> should be scaled.
  107. *> \endverbatim
  108. *>
  109. *> \param[out] INFO
  110. *> \verbatim
  111. *> INFO is INTEGER
  112. *> = 0: successful exit
  113. *> < 0: if INFO = -i, the i-th argument had an illegal value.
  114. *> > 0: if INFO = i, the i-th diagonal element is nonpositive.
  115. *> \endverbatim
  116. *
  117. * Authors:
  118. * ========
  119. *
  120. *> \author Univ. of Tennessee
  121. *> \author Univ. of California Berkeley
  122. *> \author Univ. of Colorado Denver
  123. *> \author NAG Ltd.
  124. *
  125. *> \date December 2016
  126. *
  127. *> \ingroup realOTHERcomputational
  128. *
  129. * =====================================================================
  130. SUBROUTINE SPBEQU( UPLO, N, KD, AB, LDAB, S, SCOND, AMAX, INFO )
  131. *
  132. * -- LAPACK computational routine (version 3.7.0) --
  133. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  134. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  135. * December 2016
  136. *
  137. * .. Scalar Arguments ..
  138. CHARACTER UPLO
  139. INTEGER INFO, KD, LDAB, N
  140. REAL AMAX, SCOND
  141. * ..
  142. * .. Array Arguments ..
  143. REAL AB( LDAB, * ), S( * )
  144. * ..
  145. *
  146. * =====================================================================
  147. *
  148. * .. Parameters ..
  149. REAL ZERO, ONE
  150. PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0 )
  151. * ..
  152. * .. Local Scalars ..
  153. LOGICAL UPPER
  154. INTEGER I, J
  155. REAL SMIN
  156. * ..
  157. * .. External Functions ..
  158. LOGICAL LSAME
  159. EXTERNAL LSAME
  160. * ..
  161. * .. External Subroutines ..
  162. EXTERNAL XERBLA
  163. * ..
  164. * .. Intrinsic Functions ..
  165. INTRINSIC MAX, MIN, SQRT
  166. * ..
  167. * .. Executable Statements ..
  168. *
  169. * Test the input parameters.
  170. *
  171. INFO = 0
  172. UPPER = LSAME( UPLO, 'U' )
  173. IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN
  174. INFO = -1
  175. ELSE IF( N.LT.0 ) THEN
  176. INFO = -2
  177. ELSE IF( KD.LT.0 ) THEN
  178. INFO = -3
  179. ELSE IF( LDAB.LT.KD+1 ) THEN
  180. INFO = -5
  181. END IF
  182. IF( INFO.NE.0 ) THEN
  183. CALL XERBLA( 'SPBEQU', -INFO )
  184. RETURN
  185. END IF
  186. *
  187. * Quick return if possible
  188. *
  189. IF( N.EQ.0 ) THEN
  190. SCOND = ONE
  191. AMAX = ZERO
  192. RETURN
  193. END IF
  194. *
  195. IF( UPPER ) THEN
  196. J = KD + 1
  197. ELSE
  198. J = 1
  199. END IF
  200. *
  201. * Initialize SMIN and AMAX.
  202. *
  203. S( 1 ) = AB( J, 1 )
  204. SMIN = S( 1 )
  205. AMAX = S( 1 )
  206. *
  207. * Find the minimum and maximum diagonal elements.
  208. *
  209. DO 10 I = 2, N
  210. S( I ) = AB( J, I )
  211. SMIN = MIN( SMIN, S( I ) )
  212. AMAX = MAX( AMAX, S( I ) )
  213. 10 CONTINUE
  214. *
  215. IF( SMIN.LE.ZERO ) THEN
  216. *
  217. * Find the first non-positive diagonal element and return.
  218. *
  219. DO 20 I = 1, N
  220. IF( S( I ).LE.ZERO ) THEN
  221. INFO = I
  222. RETURN
  223. END IF
  224. 20 CONTINUE
  225. ELSE
  226. *
  227. * Set the scale factors to the reciprocals
  228. * of the diagonal elements.
  229. *
  230. DO 30 I = 1, N
  231. S( I ) = ONE / SQRT( S( I ) )
  232. 30 CONTINUE
  233. *
  234. * Compute SCOND = min(S(I)) / max(S(I))
  235. *
  236. SCOND = SQRT( SMIN ) / SQRT( AMAX )
  237. END IF
  238. RETURN
  239. *
  240. * End of SPBEQU
  241. *
  242. END