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.

slansb.f 8.6 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. *> \brief \b SLANSB returns the value of the 1-norm, or the Frobenius norm, or the infinity norm, or the element of largest absolute value of a symmetric band matrix.
  2. *
  3. * =========== DOCUMENTATION ===========
  4. *
  5. * Online html documentation available at
  6. * http://www.netlib.org/lapack/explore-html/
  7. *
  8. *> \htmlonly
  9. *> Download SLANSB + dependencies
  10. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/slansb.f">
  11. *> [TGZ]</a>
  12. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/slansb.f">
  13. *> [ZIP]</a>
  14. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/slansb.f">
  15. *> [TXT]</a>
  16. *> \endhtmlonly
  17. *
  18. * Definition:
  19. * ===========
  20. *
  21. * REAL FUNCTION SLANSB( NORM, UPLO, N, K, AB, LDAB,
  22. * WORK )
  23. *
  24. * .. Scalar Arguments ..
  25. * CHARACTER NORM, UPLO
  26. * INTEGER K, LDAB, N
  27. * ..
  28. * .. Array Arguments ..
  29. * REAL AB( LDAB, * ), WORK( * )
  30. * ..
  31. *
  32. *
  33. *> \par Purpose:
  34. * =============
  35. *>
  36. *> \verbatim
  37. *>
  38. *> SLANSB returns the value of the one norm, or the Frobenius norm, or
  39. *> the infinity norm, or the element of largest absolute value of an
  40. *> n by n symmetric band matrix A, with k super-diagonals.
  41. *> \endverbatim
  42. *>
  43. *> \return SLANSB
  44. *> \verbatim
  45. *>
  46. *> SLANSB = ( max(abs(A(i,j))), NORM = 'M' or 'm'
  47. *> (
  48. *> ( norm1(A), NORM = '1', 'O' or 'o'
  49. *> (
  50. *> ( normI(A), NORM = 'I' or 'i'
  51. *> (
  52. *> ( normF(A), NORM = 'F', 'f', 'E' or 'e'
  53. *>
  54. *> where norm1 denotes the one norm of a matrix (maximum column sum),
  55. *> normI denotes the infinity norm of a matrix (maximum row sum) and
  56. *> normF denotes the Frobenius norm of a matrix (square root of sum of
  57. *> squares). Note that max(abs(A(i,j))) is not a consistent matrix norm.
  58. *> \endverbatim
  59. *
  60. * Arguments:
  61. * ==========
  62. *
  63. *> \param[in] NORM
  64. *> \verbatim
  65. *> NORM is CHARACTER*1
  66. *> Specifies the value to be returned in SLANSB as described
  67. *> above.
  68. *> \endverbatim
  69. *>
  70. *> \param[in] UPLO
  71. *> \verbatim
  72. *> UPLO is CHARACTER*1
  73. *> Specifies whether the upper or lower triangular part of the
  74. *> band matrix A is supplied.
  75. *> = 'U': Upper triangular part is supplied
  76. *> = 'L': Lower triangular part is supplied
  77. *> \endverbatim
  78. *>
  79. *> \param[in] N
  80. *> \verbatim
  81. *> N is INTEGER
  82. *> The order of the matrix A. N >= 0. When N = 0, SLANSB is
  83. *> set to zero.
  84. *> \endverbatim
  85. *>
  86. *> \param[in] K
  87. *> \verbatim
  88. *> K is INTEGER
  89. *> The number of super-diagonals or sub-diagonals of the
  90. *> band matrix A. K >= 0.
  91. *> \endverbatim
  92. *>
  93. *> \param[in] AB
  94. *> \verbatim
  95. *> AB is REAL array, dimension (LDAB,N)
  96. *> The upper or lower triangle of the symmetric band matrix A,
  97. *> stored in the first K+1 rows of AB. The j-th column of A is
  98. *> stored in the j-th column of the array AB as follows:
  99. *> if UPLO = 'U', AB(k+1+i-j,j) = A(i,j) for max(1,j-k)<=i<=j;
  100. *> if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=min(n,j+k).
  101. *> \endverbatim
  102. *>
  103. *> \param[in] LDAB
  104. *> \verbatim
  105. *> LDAB is INTEGER
  106. *> The leading dimension of the array AB. LDAB >= K+1.
  107. *> \endverbatim
  108. *>
  109. *> \param[out] WORK
  110. *> \verbatim
  111. *> WORK is REAL array, dimension (MAX(1,LWORK)),
  112. *> where LWORK >= N when NORM = 'I' or '1' or 'O'; otherwise,
  113. *> WORK is not referenced.
  114. *> \endverbatim
  115. *
  116. * Authors:
  117. * ========
  118. *
  119. *> \author Univ. of Tennessee
  120. *> \author Univ. of California Berkeley
  121. *> \author Univ. of Colorado Denver
  122. *> \author NAG Ltd.
  123. *
  124. *> \date December 2016
  125. *
  126. *> \ingroup realOTHERauxiliary
  127. *
  128. * =====================================================================
  129. REAL FUNCTION SLANSB( NORM, UPLO, N, K, AB, LDAB,
  130. $ WORK )
  131. *
  132. * -- LAPACK auxiliary 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. IMPLICIT NONE
  138. * .. Scalar Arguments ..
  139. CHARACTER NORM, UPLO
  140. INTEGER K, LDAB, N
  141. * ..
  142. * .. Array Arguments ..
  143. REAL AB( LDAB, * ), WORK( * )
  144. * ..
  145. *
  146. * =====================================================================
  147. *
  148. * .. Parameters ..
  149. REAL ONE, ZERO
  150. PARAMETER ( ONE = 1.0E+0, ZERO = 0.0E+0 )
  151. * ..
  152. * .. Local Scalars ..
  153. INTEGER I, J, L
  154. REAL ABSA, SUM, VALUE
  155. * ..
  156. * .. Local Arrays ..
  157. REAL SSQ( 2 ), COLSSQ( 2 )
  158. * ..
  159. * .. External Functions ..
  160. LOGICAL LSAME, SISNAN
  161. EXTERNAL LSAME, SISNAN
  162. * ..
  163. * .. External Subroutines ..
  164. EXTERNAL SLASSQ, SCOMBSSQ
  165. * ..
  166. * .. Intrinsic Functions ..
  167. INTRINSIC ABS, MAX, MIN, SQRT
  168. * ..
  169. * .. Executable Statements ..
  170. *
  171. IF( N.EQ.0 ) THEN
  172. VALUE = ZERO
  173. ELSE IF( LSAME( NORM, 'M' ) ) THEN
  174. *
  175. * Find max(abs(A(i,j))).
  176. *
  177. VALUE = ZERO
  178. IF( LSAME( UPLO, 'U' ) ) THEN
  179. DO 20 J = 1, N
  180. DO 10 I = MAX( K+2-J, 1 ), K + 1
  181. SUM = ABS( AB( I, J ) )
  182. IF( VALUE .LT. SUM .OR. SISNAN( SUM ) ) VALUE = SUM
  183. 10 CONTINUE
  184. 20 CONTINUE
  185. ELSE
  186. DO 40 J = 1, N
  187. DO 30 I = 1, MIN( N+1-J, K+1 )
  188. SUM = ABS( AB( I, J ) )
  189. IF( VALUE .LT. SUM .OR. SISNAN( SUM ) ) VALUE = SUM
  190. 30 CONTINUE
  191. 40 CONTINUE
  192. END IF
  193. ELSE IF( ( LSAME( NORM, 'I' ) ) .OR. ( LSAME( NORM, 'O' ) ) .OR.
  194. $ ( NORM.EQ.'1' ) ) THEN
  195. *
  196. * Find normI(A) ( = norm1(A), since A is symmetric).
  197. *
  198. VALUE = ZERO
  199. IF( LSAME( UPLO, 'U' ) ) THEN
  200. DO 60 J = 1, N
  201. SUM = ZERO
  202. L = K + 1 - J
  203. DO 50 I = MAX( 1, J-K ), J - 1
  204. ABSA = ABS( AB( L+I, J ) )
  205. SUM = SUM + ABSA
  206. WORK( I ) = WORK( I ) + ABSA
  207. 50 CONTINUE
  208. WORK( J ) = SUM + ABS( AB( K+1, J ) )
  209. 60 CONTINUE
  210. DO 70 I = 1, N
  211. SUM = WORK( I )
  212. IF( VALUE .LT. SUM .OR. SISNAN( SUM ) ) VALUE = SUM
  213. 70 CONTINUE
  214. ELSE
  215. DO 80 I = 1, N
  216. WORK( I ) = ZERO
  217. 80 CONTINUE
  218. DO 100 J = 1, N
  219. SUM = WORK( J ) + ABS( AB( 1, J ) )
  220. L = 1 - J
  221. DO 90 I = J + 1, MIN( N, J+K )
  222. ABSA = ABS( AB( L+I, J ) )
  223. SUM = SUM + ABSA
  224. WORK( I ) = WORK( I ) + ABSA
  225. 90 CONTINUE
  226. IF( VALUE .LT. SUM .OR. SISNAN( SUM ) ) VALUE = SUM
  227. 100 CONTINUE
  228. END IF
  229. ELSE IF( ( LSAME( NORM, 'F' ) ) .OR. ( LSAME( NORM, 'E' ) ) ) THEN
  230. *
  231. * Find normF(A).
  232. * SSQ(1) is scale
  233. * SSQ(2) is sum-of-squares
  234. * For better accuracy, sum each column separately.
  235. *
  236. SSQ( 1 ) = ZERO
  237. SSQ( 2 ) = ONE
  238. *
  239. * Sum off-diagonals
  240. *
  241. IF( K.GT.0 ) THEN
  242. IF( LSAME( UPLO, 'U' ) ) THEN
  243. DO 110 J = 2, N
  244. COLSSQ( 1 ) = ZERO
  245. COLSSQ( 2 ) = ONE
  246. CALL SLASSQ( MIN( J-1, K ), AB( MAX( K+2-J, 1 ), J ),
  247. $ 1, COLSSQ( 1 ), COLSSQ( 2 ) )
  248. CALL SCOMBSSQ( SSQ, COLSSQ )
  249. 110 CONTINUE
  250. L = K + 1
  251. ELSE
  252. DO 120 J = 1, N - 1
  253. COLSSQ( 1 ) = ZERO
  254. COLSSQ( 2 ) = ONE
  255. CALL SLASSQ( MIN( N-J, K ), AB( 2, J ), 1,
  256. $ COLSSQ( 1 ), COLSSQ( 2 ) )
  257. CALL SCOMBSSQ( SSQ, COLSSQ )
  258. 120 CONTINUE
  259. L = 1
  260. END IF
  261. SSQ( 2 ) = 2*SSQ( 2 )
  262. ELSE
  263. L = 1
  264. END IF
  265. *
  266. * Sum diagonal
  267. *
  268. COLSSQ( 1 ) = ZERO
  269. COLSSQ( 2 ) = ONE
  270. CALL SLASSQ( N, AB( L, 1 ), LDAB, COLSSQ( 1 ), COLSSQ( 2 ) )
  271. CALL SCOMBSSQ( SSQ, COLSSQ )
  272. VALUE = SSQ( 1 )*SQRT( SSQ( 2 ) )
  273. END IF
  274. *
  275. SLANSB = VALUE
  276. RETURN
  277. *
  278. * End of SLANSB
  279. *
  280. END