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.

dpoequ.f 5.5 kB

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