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.

dlansy.f 7.3 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. *> \brief \b DLANSY returns the value of the 1-norm, or the Frobenius norm, or the infinity norm, or the element of largest absolute value of a real symmetric matrix.
  2. *
  3. * =========== DOCUMENTATION ===========
  4. *
  5. * Online html documentation available at
  6. * http://www.netlib.org/lapack/explore-html/
  7. *
  8. *> \htmlonly
  9. *> Download DLANSY + dependencies
  10. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlansy.f">
  11. *> [TGZ]</a>
  12. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dlansy.f">
  13. *> [ZIP]</a>
  14. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlansy.f">
  15. *> [TXT]</a>
  16. *> \endhtmlonly
  17. *
  18. * Definition:
  19. * ===========
  20. *
  21. * DOUBLE PRECISION FUNCTION DLANSY( NORM, UPLO, N, A, LDA, WORK )
  22. *
  23. * .. Scalar Arguments ..
  24. * CHARACTER NORM, UPLO
  25. * INTEGER LDA, N
  26. * ..
  27. * .. Array Arguments ..
  28. * DOUBLE PRECISION A( LDA, * ), WORK( * )
  29. * ..
  30. *
  31. *
  32. *> \par Purpose:
  33. * =============
  34. *>
  35. *> \verbatim
  36. *>
  37. *> DLANSY returns the value of the one norm, or the Frobenius norm, or
  38. *> the infinity norm, or the element of largest absolute value of a
  39. *> real symmetric matrix A.
  40. *> \endverbatim
  41. *>
  42. *> \return DLANSY
  43. *> \verbatim
  44. *>
  45. *> DLANSY = ( max(abs(A(i,j))), NORM = 'M' or 'm'
  46. *> (
  47. *> ( norm1(A), NORM = '1', 'O' or 'o'
  48. *> (
  49. *> ( normI(A), NORM = 'I' or 'i'
  50. *> (
  51. *> ( normF(A), NORM = 'F', 'f', 'E' or 'e'
  52. *>
  53. *> where norm1 denotes the one norm of a matrix (maximum column sum),
  54. *> normI denotes the infinity norm of a matrix (maximum row sum) and
  55. *> normF denotes the Frobenius norm of a matrix (square root of sum of
  56. *> squares). Note that max(abs(A(i,j))) is not a consistent matrix norm.
  57. *> \endverbatim
  58. *
  59. * Arguments:
  60. * ==========
  61. *
  62. *> \param[in] NORM
  63. *> \verbatim
  64. *> NORM is CHARACTER*1
  65. *> Specifies the value to be returned in DLANSY as described
  66. *> above.
  67. *> \endverbatim
  68. *>
  69. *> \param[in] UPLO
  70. *> \verbatim
  71. *> UPLO is CHARACTER*1
  72. *> Specifies whether the upper or lower triangular part of the
  73. *> symmetric matrix A is to be referenced.
  74. *> = 'U': Upper triangular part of A is referenced
  75. *> = 'L': Lower triangular part of A is referenced
  76. *> \endverbatim
  77. *>
  78. *> \param[in] N
  79. *> \verbatim
  80. *> N is INTEGER
  81. *> The order of the matrix A. N >= 0. When N = 0, DLANSY is
  82. *> set to zero.
  83. *> \endverbatim
  84. *>
  85. *> \param[in] A
  86. *> \verbatim
  87. *> A is DOUBLE PRECISION array, dimension (LDA,N)
  88. *> The symmetric matrix A. If UPLO = 'U', the leading n by n
  89. *> upper triangular part of A contains the upper triangular part
  90. *> of the matrix A, and the strictly lower triangular part of A
  91. *> is not referenced. If UPLO = 'L', the leading n by n lower
  92. *> triangular part of A contains the lower triangular part of
  93. *> the matrix A, and the strictly upper triangular part of A is
  94. *> not referenced.
  95. *> \endverbatim
  96. *>
  97. *> \param[in] LDA
  98. *> \verbatim
  99. *> LDA is INTEGER
  100. *> The leading dimension of the array A. LDA >= max(N,1).
  101. *> \endverbatim
  102. *>
  103. *> \param[out] WORK
  104. *> \verbatim
  105. *> WORK is DOUBLE PRECISION array, dimension (MAX(1,LWORK)),
  106. *> where LWORK >= N when NORM = 'I' or '1' or 'O'; otherwise,
  107. *> WORK is not referenced.
  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 doubleSYauxiliary
  119. *
  120. * =====================================================================
  121. DOUBLE PRECISION FUNCTION DLANSY( NORM, UPLO, N, A, LDA, WORK )
  122. *
  123. * -- LAPACK auxiliary routine --
  124. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  125. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  126. *
  127. * .. Scalar Arguments ..
  128. CHARACTER NORM, UPLO
  129. INTEGER LDA, N
  130. * ..
  131. * .. Array Arguments ..
  132. DOUBLE PRECISION A( LDA, * ), WORK( * )
  133. * ..
  134. *
  135. * =====================================================================
  136. *
  137. * .. Parameters ..
  138. DOUBLE PRECISION ONE, ZERO
  139. PARAMETER ( ONE = 1.0D+0, ZERO = 0.0D+0 )
  140. * ..
  141. * .. Local Scalars ..
  142. INTEGER I, J
  143. DOUBLE PRECISION ABSA, SCALE, SUM, VALUE
  144. * ..
  145. * .. External Subroutines ..
  146. EXTERNAL DLASSQ
  147. * ..
  148. * .. External Functions ..
  149. LOGICAL LSAME, DISNAN
  150. EXTERNAL LSAME, DISNAN
  151. * ..
  152. * .. Intrinsic Functions ..
  153. INTRINSIC ABS, SQRT
  154. * ..
  155. * .. Executable Statements ..
  156. *
  157. IF( N.EQ.0 ) THEN
  158. VALUE = ZERO
  159. ELSE IF( LSAME( NORM, 'M' ) ) THEN
  160. *
  161. * Find max(abs(A(i,j))).
  162. *
  163. VALUE = ZERO
  164. IF( LSAME( UPLO, 'U' ) ) THEN
  165. DO 20 J = 1, N
  166. DO 10 I = 1, J
  167. SUM = ABS( A( I, J ) )
  168. IF( VALUE .LT. SUM .OR. DISNAN( SUM ) ) VALUE = SUM
  169. 10 CONTINUE
  170. 20 CONTINUE
  171. ELSE
  172. DO 40 J = 1, N
  173. DO 30 I = J, N
  174. SUM = ABS( A( I, J ) )
  175. IF( VALUE .LT. SUM .OR. DISNAN( SUM ) ) VALUE = SUM
  176. 30 CONTINUE
  177. 40 CONTINUE
  178. END IF
  179. ELSE IF( ( LSAME( NORM, 'I' ) ) .OR. ( LSAME( NORM, 'O' ) ) .OR.
  180. $ ( NORM.EQ.'1' ) ) THEN
  181. *
  182. * Find normI(A) ( = norm1(A), since A is symmetric).
  183. *
  184. VALUE = ZERO
  185. IF( LSAME( UPLO, 'U' ) ) THEN
  186. DO 60 J = 1, N
  187. SUM = ZERO
  188. DO 50 I = 1, J - 1
  189. ABSA = ABS( A( I, J ) )
  190. SUM = SUM + ABSA
  191. WORK( I ) = WORK( I ) + ABSA
  192. 50 CONTINUE
  193. WORK( J ) = SUM + ABS( A( J, J ) )
  194. 60 CONTINUE
  195. DO 70 I = 1, N
  196. SUM = WORK( I )
  197. IF( VALUE .LT. SUM .OR. DISNAN( SUM ) ) VALUE = SUM
  198. 70 CONTINUE
  199. ELSE
  200. DO 80 I = 1, N
  201. WORK( I ) = ZERO
  202. 80 CONTINUE
  203. DO 100 J = 1, N
  204. SUM = WORK( J ) + ABS( A( J, J ) )
  205. DO 90 I = J + 1, N
  206. ABSA = ABS( A( I, J ) )
  207. SUM = SUM + ABSA
  208. WORK( I ) = WORK( I ) + ABSA
  209. 90 CONTINUE
  210. IF( VALUE .LT. SUM .OR. DISNAN( SUM ) ) VALUE = SUM
  211. 100 CONTINUE
  212. END IF
  213. ELSE IF( ( LSAME( NORM, 'F' ) ) .OR. ( LSAME( NORM, 'E' ) ) ) THEN
  214. *
  215. * Find normF(A).
  216. *
  217. SCALE = ZERO
  218. SUM = ONE
  219. IF( LSAME( UPLO, 'U' ) ) THEN
  220. DO 110 J = 2, N
  221. CALL DLASSQ( J-1, A( 1, J ), 1, SCALE, SUM )
  222. 110 CONTINUE
  223. ELSE
  224. DO 120 J = 1, N - 1
  225. CALL DLASSQ( N-J, A( J+1, J ), 1, SCALE, SUM )
  226. 120 CONTINUE
  227. END IF
  228. SUM = 2*SUM
  229. CALL DLASSQ( N, A, LDA+1, SCALE, SUM )
  230. VALUE = SCALE*SQRT( SUM )
  231. END IF
  232. *
  233. DLANSY = VALUE
  234. RETURN
  235. *
  236. * End of DLANSY
  237. *
  238. END