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.

zlantp.f 12 kB

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