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.

slantp.f 11 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  1. *> \brief \b SLANTP returns the value of the 1-norm, or the Frobenius norm, or the infinity norm, or the element of largest absolute value of a triangular matrix supplied in packed form.
  2. *
  3. * =========== DOCUMENTATION ===========
  4. *
  5. * Online html documentation available at
  6. * http://www.netlib.org/lapack/explore-html/
  7. *
  8. *> \htmlonly
  9. *> Download SLANTP + dependencies
  10. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/slantp.f">
  11. *> [TGZ]</a>
  12. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/slantp.f">
  13. *> [ZIP]</a>
  14. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/slantp.f">
  15. *> [TXT]</a>
  16. *> \endhtmlonly
  17. *
  18. * Definition:
  19. * ===========
  20. *
  21. * REAL FUNCTION SLANTP( NORM, UPLO, DIAG, N, AP, WORK )
  22. *
  23. * .. Scalar Arguments ..
  24. * CHARACTER DIAG, NORM, UPLO
  25. * INTEGER N
  26. * ..
  27. * .. Array Arguments ..
  28. * REAL AP( * ), WORK( * )
  29. * ..
  30. *
  31. *
  32. *> \par Purpose:
  33. * =============
  34. *>
  35. *> \verbatim
  36. *>
  37. *> SLANTP 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. *> triangular matrix A, supplied in packed form.
  40. *> \endverbatim
  41. *>
  42. *> \return SLANTP
  43. *> \verbatim
  44. *>
  45. *> SLANTP = ( 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 SLANTP as described
  66. *> above.
  67. *> \endverbatim
  68. *>
  69. *> \param[in] UPLO
  70. *> \verbatim
  71. *> UPLO is CHARACTER*1
  72. *> Specifies whether the matrix A is upper or lower triangular.
  73. *> = 'U': Upper triangular
  74. *> = 'L': Lower triangular
  75. *> \endverbatim
  76. *>
  77. *> \param[in] DIAG
  78. *> \verbatim
  79. *> DIAG is CHARACTER*1
  80. *> Specifies whether or not the matrix A is unit triangular.
  81. *> = 'N': Non-unit triangular
  82. *> = 'U': Unit triangular
  83. *> \endverbatim
  84. *>
  85. *> \param[in] N
  86. *> \verbatim
  87. *> N is INTEGER
  88. *> The order of the matrix A. N >= 0. When N = 0, SLANTP is
  89. *> set to zero.
  90. *> \endverbatim
  91. *>
  92. *> \param[in] AP
  93. *> \verbatim
  94. *> AP is REAL array, dimension (N*(N+1)/2)
  95. *> The upper or lower triangular matrix A, packed columnwise in
  96. *> a linear array. The j-th column of A is stored in the array
  97. *> AP as follows:
  98. *> if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j;
  99. *> if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = A(i,j) for j<=i<=n.
  100. *> Note that when DIAG = 'U', the elements of the array AP
  101. *> corresponding to the diagonal elements of the matrix A are
  102. *> not referenced, but are assumed to be one.
  103. *> \endverbatim
  104. *>
  105. *> \param[out] WORK
  106. *> \verbatim
  107. *> WORK is REAL array, dimension (MAX(1,LWORK)),
  108. *> where LWORK >= N when NORM = 'I'; otherwise, WORK is not
  109. *> referenced.
  110. *> \endverbatim
  111. *
  112. * Authors:
  113. * ========
  114. *
  115. *> \author Univ. of Tennessee
  116. *> \author Univ. of California Berkeley
  117. *> \author Univ. of Colorado Denver
  118. *> \author NAG Ltd.
  119. *
  120. *> \ingroup realOTHERauxiliary
  121. *
  122. * =====================================================================
  123. REAL FUNCTION SLANTP( NORM, UPLO, DIAG, N, AP, WORK )
  124. *
  125. * -- LAPACK auxiliary routine --
  126. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  127. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  128. *
  129. * .. Scalar Arguments ..
  130. CHARACTER DIAG, NORM, UPLO
  131. INTEGER N
  132. * ..
  133. * .. Array Arguments ..
  134. REAL AP( * ), WORK( * )
  135. * ..
  136. *
  137. * =====================================================================
  138. *
  139. * .. Parameters ..
  140. REAL ONE, ZERO
  141. PARAMETER ( ONE = 1.0E+0, ZERO = 0.0E+0 )
  142. * ..
  143. * .. Local Scalars ..
  144. LOGICAL UDIAG
  145. INTEGER I, J, K
  146. REAL SCALE, SUM, VALUE
  147. * ..
  148. * .. External Subroutines ..
  149. EXTERNAL SLASSQ
  150. * ..
  151. * .. External Functions ..
  152. LOGICAL LSAME, SISNAN
  153. EXTERNAL LSAME, SISNAN
  154. * ..
  155. * .. Intrinsic Functions ..
  156. INTRINSIC ABS, SQRT
  157. * ..
  158. * .. Executable Statements ..
  159. *
  160. IF( N.EQ.0 ) THEN
  161. VALUE = ZERO
  162. ELSE IF( LSAME( NORM, 'M' ) ) THEN
  163. *
  164. * Find max(abs(A(i,j))).
  165. *
  166. K = 1
  167. IF( LSAME( DIAG, 'U' ) ) THEN
  168. VALUE = ONE
  169. IF( LSAME( UPLO, 'U' ) ) THEN
  170. DO 20 J = 1, N
  171. DO 10 I = K, K + J - 2
  172. SUM = ABS( AP( I ) )
  173. IF( VALUE .LT. SUM .OR. SISNAN( SUM ) ) VALUE = SUM
  174. 10 CONTINUE
  175. K = K + J
  176. 20 CONTINUE
  177. ELSE
  178. DO 40 J = 1, N
  179. DO 30 I = K + 1, K + N - J
  180. SUM = ABS( AP( I ) )
  181. IF( VALUE .LT. SUM .OR. SISNAN( SUM ) ) VALUE = SUM
  182. 30 CONTINUE
  183. K = K + N - J + 1
  184. 40 CONTINUE
  185. END IF
  186. ELSE
  187. VALUE = ZERO
  188. IF( LSAME( UPLO, 'U' ) ) THEN
  189. DO 60 J = 1, N
  190. DO 50 I = K, K + J - 1
  191. SUM = ABS( AP( I ) )
  192. IF( VALUE .LT. SUM .OR. SISNAN( SUM ) ) VALUE = SUM
  193. 50 CONTINUE
  194. K = K + J
  195. 60 CONTINUE
  196. ELSE
  197. DO 80 J = 1, N
  198. DO 70 I = K, K + N - J
  199. SUM = ABS( AP( I ) )
  200. IF( VALUE .LT. SUM .OR. SISNAN( SUM ) ) VALUE = SUM
  201. 70 CONTINUE
  202. K = K + N - J + 1
  203. 80 CONTINUE
  204. END IF
  205. END IF
  206. ELSE IF( ( LSAME( NORM, 'O' ) ) .OR. ( NORM.EQ.'1' ) ) THEN
  207. *
  208. * Find norm1(A).
  209. *
  210. VALUE = ZERO
  211. K = 1
  212. UDIAG = LSAME( DIAG, 'U' )
  213. IF( LSAME( UPLO, 'U' ) ) THEN
  214. DO 110 J = 1, N
  215. IF( UDIAG ) THEN
  216. SUM = ONE
  217. DO 90 I = K, K + J - 2
  218. SUM = SUM + ABS( AP( I ) )
  219. 90 CONTINUE
  220. ELSE
  221. SUM = ZERO
  222. DO 100 I = K, K + J - 1
  223. SUM = SUM + ABS( AP( I ) )
  224. 100 CONTINUE
  225. END IF
  226. K = K + J
  227. IF( VALUE .LT. SUM .OR. SISNAN( SUM ) ) VALUE = SUM
  228. 110 CONTINUE
  229. ELSE
  230. DO 140 J = 1, N
  231. IF( UDIAG ) THEN
  232. SUM = ONE
  233. DO 120 I = K + 1, K + N - J
  234. SUM = SUM + ABS( AP( I ) )
  235. 120 CONTINUE
  236. ELSE
  237. SUM = ZERO
  238. DO 130 I = K, K + N - J
  239. SUM = SUM + ABS( AP( I ) )
  240. 130 CONTINUE
  241. END IF
  242. K = K + N - J + 1
  243. IF( VALUE .LT. SUM .OR. SISNAN( SUM ) ) VALUE = SUM
  244. 140 CONTINUE
  245. END IF
  246. ELSE IF( LSAME( NORM, 'I' ) ) THEN
  247. *
  248. * Find normI(A).
  249. *
  250. K = 1
  251. IF( LSAME( UPLO, 'U' ) ) THEN
  252. IF( LSAME( DIAG, 'U' ) ) THEN
  253. DO 150 I = 1, N
  254. WORK( I ) = ONE
  255. 150 CONTINUE
  256. DO 170 J = 1, N
  257. DO 160 I = 1, J - 1
  258. WORK( I ) = WORK( I ) + ABS( AP( K ) )
  259. K = K + 1
  260. 160 CONTINUE
  261. K = K + 1
  262. 170 CONTINUE
  263. ELSE
  264. DO 180 I = 1, N
  265. WORK( I ) = ZERO
  266. 180 CONTINUE
  267. DO 200 J = 1, N
  268. DO 190 I = 1, J
  269. WORK( I ) = WORK( I ) + ABS( AP( K ) )
  270. K = K + 1
  271. 190 CONTINUE
  272. 200 CONTINUE
  273. END IF
  274. ELSE
  275. IF( LSAME( DIAG, 'U' ) ) THEN
  276. DO 210 I = 1, N
  277. WORK( I ) = ONE
  278. 210 CONTINUE
  279. DO 230 J = 1, N
  280. K = K + 1
  281. DO 220 I = J + 1, N
  282. WORK( I ) = WORK( I ) + ABS( AP( K ) )
  283. K = K + 1
  284. 220 CONTINUE
  285. 230 CONTINUE
  286. ELSE
  287. DO 240 I = 1, N
  288. WORK( I ) = ZERO
  289. 240 CONTINUE
  290. DO 260 J = 1, N
  291. DO 250 I = J, N
  292. WORK( I ) = WORK( I ) + ABS( AP( K ) )
  293. K = K + 1
  294. 250 CONTINUE
  295. 260 CONTINUE
  296. END IF
  297. END IF
  298. VALUE = ZERO
  299. DO 270 I = 1, N
  300. SUM = WORK( I )
  301. IF( VALUE .LT. SUM .OR. SISNAN( SUM ) ) VALUE = SUM
  302. 270 CONTINUE
  303. ELSE IF( ( LSAME( NORM, 'F' ) ) .OR. ( LSAME( NORM, 'E' ) ) ) THEN
  304. *
  305. * Find normF(A).
  306. *
  307. IF( LSAME( UPLO, 'U' ) ) THEN
  308. IF( LSAME( DIAG, 'U' ) ) THEN
  309. SCALE = ONE
  310. SUM = N
  311. K = 2
  312. DO 280 J = 2, N
  313. CALL SLASSQ( J-1, AP( K ), 1, SCALE, SUM )
  314. K = K + J
  315. 280 CONTINUE
  316. ELSE
  317. SCALE = ZERO
  318. SUM = ONE
  319. K = 1
  320. DO 290 J = 1, N
  321. CALL SLASSQ( J, AP( K ), 1, SCALE, SUM )
  322. K = K + J
  323. 290 CONTINUE
  324. END IF
  325. ELSE
  326. IF( LSAME( DIAG, 'U' ) ) THEN
  327. SCALE = ONE
  328. SUM = N
  329. K = 2
  330. DO 300 J = 1, N - 1
  331. CALL SLASSQ( N-J, AP( K ), 1, SCALE, SUM )
  332. K = K + N - J + 1
  333. 300 CONTINUE
  334. ELSE
  335. SCALE = ZERO
  336. SUM = ONE
  337. K = 1
  338. DO 310 J = 1, N
  339. CALL SLASSQ( N-J+1, AP( K ), 1, SCALE, SUM )
  340. K = K + N - J + 1
  341. 310 CONTINUE
  342. END IF
  343. END IF
  344. VALUE = SCALE*SQRT( SUM )
  345. END IF
  346. *
  347. SLANTP = VALUE
  348. RETURN
  349. *
  350. * End of SLANTP
  351. *
  352. END