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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  1. *> \brief \b ZTPMV
  2. *
  3. * =========== DOCUMENTATION ===========
  4. *
  5. * Online html documentation available at
  6. * http://www.netlib.org/lapack/explore-html/
  7. *
  8. * Definition:
  9. * ===========
  10. *
  11. * SUBROUTINE ZTPMV(UPLO,TRANS,DIAG,N,AP,X,INCX)
  12. *
  13. * .. Scalar Arguments ..
  14. * INTEGER INCX,N
  15. * CHARACTER DIAG,TRANS,UPLO
  16. * ..
  17. * .. Array Arguments ..
  18. * COMPLEX*16 AP(*),X(*)
  19. * ..
  20. *
  21. *
  22. *> \par Purpose:
  23. * =============
  24. *>
  25. *> \verbatim
  26. *>
  27. *> ZTPMV performs one of the matrix-vector operations
  28. *>
  29. *> x := A*x, or x := A**T*x, or x := A**H*x,
  30. *>
  31. *> where x is an n element vector and A is an n by n unit, or non-unit,
  32. *> upper or lower triangular matrix, supplied in packed form.
  33. *> \endverbatim
  34. *
  35. * Arguments:
  36. * ==========
  37. *
  38. *> \param[in] UPLO
  39. *> \verbatim
  40. *> UPLO is CHARACTER*1
  41. *> On entry, UPLO specifies whether the matrix is an upper or
  42. *> lower triangular matrix as follows:
  43. *>
  44. *> UPLO = 'U' or 'u' A is an upper triangular matrix.
  45. *>
  46. *> UPLO = 'L' or 'l' A is a lower triangular matrix.
  47. *> \endverbatim
  48. *>
  49. *> \param[in] TRANS
  50. *> \verbatim
  51. *> TRANS is CHARACTER*1
  52. *> On entry, TRANS specifies the operation to be performed as
  53. *> follows:
  54. *>
  55. *> TRANS = 'N' or 'n' x := A*x.
  56. *>
  57. *> TRANS = 'T' or 't' x := A**T*x.
  58. *>
  59. *> TRANS = 'C' or 'c' x := A**H*x.
  60. *> \endverbatim
  61. *>
  62. *> \param[in] DIAG
  63. *> \verbatim
  64. *> DIAG is CHARACTER*1
  65. *> On entry, DIAG specifies whether or not A is unit
  66. *> triangular as follows:
  67. *>
  68. *> DIAG = 'U' or 'u' A is assumed to be unit triangular.
  69. *>
  70. *> DIAG = 'N' or 'n' A is not assumed to be unit
  71. *> triangular.
  72. *> \endverbatim
  73. *>
  74. *> \param[in] N
  75. *> \verbatim
  76. *> N is INTEGER
  77. *> On entry, N specifies the order of the matrix A.
  78. *> N must be at least zero.
  79. *> \endverbatim
  80. *>
  81. *> \param[in] AP
  82. *> \verbatim
  83. *> AP is COMPLEX*16 array, dimension at least
  84. *> ( ( n*( n + 1 ) )/2 ).
  85. *> Before entry with UPLO = 'U' or 'u', the array AP must
  86. *> contain the upper triangular matrix packed sequentially,
  87. *> column by column, so that AP( 1 ) contains a( 1, 1 ),
  88. *> AP( 2 ) and AP( 3 ) contain a( 1, 2 ) and a( 2, 2 )
  89. *> respectively, and so on.
  90. *> Before entry with UPLO = 'L' or 'l', the array AP must
  91. *> contain the lower triangular matrix packed sequentially,
  92. *> column by column, so that AP( 1 ) contains a( 1, 1 ),
  93. *> AP( 2 ) and AP( 3 ) contain a( 2, 1 ) and a( 3, 1 )
  94. *> respectively, and so on.
  95. *> Note that when DIAG = 'U' or 'u', the diagonal elements of
  96. *> A are not referenced, but are assumed to be unity.
  97. *> \endverbatim
  98. *>
  99. *> \param[in,out] X
  100. *> \verbatim
  101. *> X is COMPLEX*16 array, dimension at least
  102. *> ( 1 + ( n - 1 )*abs( INCX ) ).
  103. *> Before entry, the incremented array X must contain the n
  104. *> element vector x. On exit, X is overwritten with the
  105. *> transformed vector x.
  106. *> \endverbatim
  107. *>
  108. *> \param[in] INCX
  109. *> \verbatim
  110. *> INCX is INTEGER
  111. *> On entry, INCX specifies the increment for the elements of
  112. *> X. INCX must not be zero.
  113. *> \endverbatim
  114. *
  115. * Authors:
  116. * ========
  117. *
  118. *> \author Univ. of Tennessee
  119. *> \author Univ. of California Berkeley
  120. *> \author Univ. of Colorado Denver
  121. *> \author NAG Ltd.
  122. *
  123. *> \date December 2016
  124. *
  125. *> \ingroup complex16_blas_level2
  126. *
  127. *> \par Further Details:
  128. * =====================
  129. *>
  130. *> \verbatim
  131. *>
  132. *> Level 2 Blas routine.
  133. *> The vector and matrix arguments are not referenced when N = 0, or M = 0
  134. *>
  135. *> -- Written on 22-October-1986.
  136. *> Jack Dongarra, Argonne National Lab.
  137. *> Jeremy Du Croz, Nag Central Office.
  138. *> Sven Hammarling, Nag Central Office.
  139. *> Richard Hanson, Sandia National Labs.
  140. *> \endverbatim
  141. *>
  142. * =====================================================================
  143. SUBROUTINE ZTPMV(UPLO,TRANS,DIAG,N,AP,X,INCX)
  144. *
  145. * -- Reference BLAS level2 routine (version 3.7.0) --
  146. * -- Reference BLAS is a software package provided by Univ. of Tennessee, --
  147. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  148. * December 2016
  149. *
  150. * .. Scalar Arguments ..
  151. INTEGER INCX,N
  152. CHARACTER DIAG,TRANS,UPLO
  153. * ..
  154. * .. Array Arguments ..
  155. COMPLEX*16 AP(*),X(*)
  156. * ..
  157. *
  158. * =====================================================================
  159. *
  160. * .. Parameters ..
  161. COMPLEX*16 ZERO
  162. PARAMETER (ZERO= (0.0D+0,0.0D+0))
  163. * ..
  164. * .. Local Scalars ..
  165. COMPLEX*16 TEMP
  166. INTEGER I,INFO,IX,J,JX,K,KK,KX
  167. LOGICAL NOCONJ,NOUNIT
  168. * ..
  169. * .. External Functions ..
  170. LOGICAL LSAME
  171. EXTERNAL LSAME
  172. * ..
  173. * .. External Subroutines ..
  174. EXTERNAL XERBLA
  175. * ..
  176. * .. Intrinsic Functions ..
  177. INTRINSIC DCONJG
  178. * ..
  179. *
  180. * Test the input parameters.
  181. *
  182. INFO = 0
  183. IF (.NOT.LSAME(UPLO,'U') .AND. .NOT.LSAME(UPLO,'L')) THEN
  184. INFO = 1
  185. ELSE IF (.NOT.LSAME(TRANS,'N') .AND. .NOT.LSAME(TRANS,'T') .AND.
  186. + .NOT.LSAME(TRANS,'C')) THEN
  187. INFO = 2
  188. ELSE IF (.NOT.LSAME(DIAG,'U') .AND. .NOT.LSAME(DIAG,'N')) THEN
  189. INFO = 3
  190. ELSE IF (N.LT.0) THEN
  191. INFO = 4
  192. ELSE IF (INCX.EQ.0) THEN
  193. INFO = 7
  194. END IF
  195. IF (INFO.NE.0) THEN
  196. CALL XERBLA('ZTPMV ',INFO)
  197. RETURN
  198. END IF
  199. *
  200. * Quick return if possible.
  201. *
  202. IF (N.EQ.0) RETURN
  203. *
  204. NOCONJ = LSAME(TRANS,'T')
  205. NOUNIT = LSAME(DIAG,'N')
  206. *
  207. * Set up the start point in X if the increment is not unity. This
  208. * will be ( N - 1 )*INCX too small for descending loops.
  209. *
  210. IF (INCX.LE.0) THEN
  211. KX = 1 - (N-1)*INCX
  212. ELSE IF (INCX.NE.1) THEN
  213. KX = 1
  214. END IF
  215. *
  216. * Start the operations. In this version the elements of AP are
  217. * accessed sequentially with one pass through AP.
  218. *
  219. IF (LSAME(TRANS,'N')) THEN
  220. *
  221. * Form x:= A*x.
  222. *
  223. IF (LSAME(UPLO,'U')) THEN
  224. KK = 1
  225. IF (INCX.EQ.1) THEN
  226. DO 20 J = 1,N
  227. IF (X(J).NE.ZERO) THEN
  228. TEMP = X(J)
  229. K = KK
  230. DO 10 I = 1,J - 1
  231. X(I) = X(I) + TEMP*AP(K)
  232. K = K + 1
  233. 10 CONTINUE
  234. IF (NOUNIT) X(J) = X(J)*AP(KK+J-1)
  235. END IF
  236. KK = KK + J
  237. 20 CONTINUE
  238. ELSE
  239. JX = KX
  240. DO 40 J = 1,N
  241. IF (X(JX).NE.ZERO) THEN
  242. TEMP = X(JX)
  243. IX = KX
  244. DO 30 K = KK,KK + J - 2
  245. X(IX) = X(IX) + TEMP*AP(K)
  246. IX = IX + INCX
  247. 30 CONTINUE
  248. IF (NOUNIT) X(JX) = X(JX)*AP(KK+J-1)
  249. END IF
  250. JX = JX + INCX
  251. KK = KK + J
  252. 40 CONTINUE
  253. END IF
  254. ELSE
  255. KK = (N* (N+1))/2
  256. IF (INCX.EQ.1) THEN
  257. DO 60 J = N,1,-1
  258. IF (X(J).NE.ZERO) THEN
  259. TEMP = X(J)
  260. K = KK
  261. DO 50 I = N,J + 1,-1
  262. X(I) = X(I) + TEMP*AP(K)
  263. K = K - 1
  264. 50 CONTINUE
  265. IF (NOUNIT) X(J) = X(J)*AP(KK-N+J)
  266. END IF
  267. KK = KK - (N-J+1)
  268. 60 CONTINUE
  269. ELSE
  270. KX = KX + (N-1)*INCX
  271. JX = KX
  272. DO 80 J = N,1,-1
  273. IF (X(JX).NE.ZERO) THEN
  274. TEMP = X(JX)
  275. IX = KX
  276. DO 70 K = KK,KK - (N- (J+1)),-1
  277. X(IX) = X(IX) + TEMP*AP(K)
  278. IX = IX - INCX
  279. 70 CONTINUE
  280. IF (NOUNIT) X(JX) = X(JX)*AP(KK-N+J)
  281. END IF
  282. JX = JX - INCX
  283. KK = KK - (N-J+1)
  284. 80 CONTINUE
  285. END IF
  286. END IF
  287. ELSE
  288. *
  289. * Form x := A**T*x or x := A**H*x.
  290. *
  291. IF (LSAME(UPLO,'U')) THEN
  292. KK = (N* (N+1))/2
  293. IF (INCX.EQ.1) THEN
  294. DO 110 J = N,1,-1
  295. TEMP = X(J)
  296. K = KK - 1
  297. IF (NOCONJ) THEN
  298. IF (NOUNIT) TEMP = TEMP*AP(KK)
  299. DO 90 I = J - 1,1,-1
  300. TEMP = TEMP + AP(K)*X(I)
  301. K = K - 1
  302. 90 CONTINUE
  303. ELSE
  304. IF (NOUNIT) TEMP = TEMP*DCONJG(AP(KK))
  305. DO 100 I = J - 1,1,-1
  306. TEMP = TEMP + DCONJG(AP(K))*X(I)
  307. K = K - 1
  308. 100 CONTINUE
  309. END IF
  310. X(J) = TEMP
  311. KK = KK - J
  312. 110 CONTINUE
  313. ELSE
  314. JX = KX + (N-1)*INCX
  315. DO 140 J = N,1,-1
  316. TEMP = X(JX)
  317. IX = JX
  318. IF (NOCONJ) THEN
  319. IF (NOUNIT) TEMP = TEMP*AP(KK)
  320. DO 120 K = KK - 1,KK - J + 1,-1
  321. IX = IX - INCX
  322. TEMP = TEMP + AP(K)*X(IX)
  323. 120 CONTINUE
  324. ELSE
  325. IF (NOUNIT) TEMP = TEMP*DCONJG(AP(KK))
  326. DO 130 K = KK - 1,KK - J + 1,-1
  327. IX = IX - INCX
  328. TEMP = TEMP + DCONJG(AP(K))*X(IX)
  329. 130 CONTINUE
  330. END IF
  331. X(JX) = TEMP
  332. JX = JX - INCX
  333. KK = KK - J
  334. 140 CONTINUE
  335. END IF
  336. ELSE
  337. KK = 1
  338. IF (INCX.EQ.1) THEN
  339. DO 170 J = 1,N
  340. TEMP = X(J)
  341. K = KK + 1
  342. IF (NOCONJ) THEN
  343. IF (NOUNIT) TEMP = TEMP*AP(KK)
  344. DO 150 I = J + 1,N
  345. TEMP = TEMP + AP(K)*X(I)
  346. K = K + 1
  347. 150 CONTINUE
  348. ELSE
  349. IF (NOUNIT) TEMP = TEMP*DCONJG(AP(KK))
  350. DO 160 I = J + 1,N
  351. TEMP = TEMP + DCONJG(AP(K))*X(I)
  352. K = K + 1
  353. 160 CONTINUE
  354. END IF
  355. X(J) = TEMP
  356. KK = KK + (N-J+1)
  357. 170 CONTINUE
  358. ELSE
  359. JX = KX
  360. DO 200 J = 1,N
  361. TEMP = X(JX)
  362. IX = JX
  363. IF (NOCONJ) THEN
  364. IF (NOUNIT) TEMP = TEMP*AP(KK)
  365. DO 180 K = KK + 1,KK + N - J
  366. IX = IX + INCX
  367. TEMP = TEMP + AP(K)*X(IX)
  368. 180 CONTINUE
  369. ELSE
  370. IF (NOUNIT) TEMP = TEMP*DCONJG(AP(KK))
  371. DO 190 K = KK + 1,KK + N - J
  372. IX = IX + INCX
  373. TEMP = TEMP + DCONJG(AP(K))*X(IX)
  374. 190 CONTINUE
  375. END IF
  376. X(JX) = TEMP
  377. JX = JX + INCX
  378. KK = KK + (N-J+1)
  379. 200 CONTINUE
  380. END IF
  381. END IF
  382. END IF
  383. *
  384. RETURN
  385. *
  386. * End of ZTPMV .
  387. *
  388. END