LAPACK  3.10.0
LAPACK: Linear Algebra PACKage
ctpmv.f
Go to the documentation of this file.
1 *> \brief \b CTPMV
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 CTPMV(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 AP(*),X(*)
19 * ..
20 *
21 *
22 *> \par Purpose:
23 * =============
24 *>
25 *> \verbatim
26 *>
27 *> CTPMV 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 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 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 *> \ingroup complex_blas_level2
124 *
125 *> \par Further Details:
126 * =====================
127 *>
128 *> \verbatim
129 *>
130 *> Level 2 Blas routine.
131 *> The vector and matrix arguments are not referenced when N = 0, or M = 0
132 *>
133 *> -- Written on 22-October-1986.
134 *> Jack Dongarra, Argonne National Lab.
135 *> Jeremy Du Croz, Nag Central Office.
136 *> Sven Hammarling, Nag Central Office.
137 *> Richard Hanson, Sandia National Labs.
138 *> \endverbatim
139 *>
140 * =====================================================================
141  SUBROUTINE ctpmv(UPLO,TRANS,DIAG,N,AP,X,INCX)
142 *
143 * -- Reference BLAS level2 routine --
144 * -- Reference BLAS is a software package provided by Univ. of Tennessee, --
145 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
146 *
147 * .. Scalar Arguments ..
148  INTEGER INCX,N
149  CHARACTER DIAG,TRANS,UPLO
150 * ..
151 * .. Array Arguments ..
152  COMPLEX AP(*),X(*)
153 * ..
154 *
155 * =====================================================================
156 *
157 * .. Parameters ..
158  COMPLEX ZERO
159  parameter(zero= (0.0e+0,0.0e+0))
160 * ..
161 * .. Local Scalars ..
162  COMPLEX TEMP
163  INTEGER I,INFO,IX,J,JX,K,KK,KX
164  LOGICAL NOCONJ,NOUNIT
165 * ..
166 * .. External Functions ..
167  LOGICAL LSAME
168  EXTERNAL lsame
169 * ..
170 * .. External Subroutines ..
171  EXTERNAL xerbla
172 * ..
173 * .. Intrinsic Functions ..
174  INTRINSIC conjg
175 * ..
176 *
177 * Test the input parameters.
178 *
179  info = 0
180  IF (.NOT.lsame(uplo,'U') .AND. .NOT.lsame(uplo,'L')) THEN
181  info = 1
182  ELSE IF (.NOT.lsame(trans,'N') .AND. .NOT.lsame(trans,'T') .AND.
183  + .NOT.lsame(trans,'C')) THEN
184  info = 2
185  ELSE IF (.NOT.lsame(diag,'U') .AND. .NOT.lsame(diag,'N')) THEN
186  info = 3
187  ELSE IF (n.LT.0) THEN
188  info = 4
189  ELSE IF (incx.EQ.0) THEN
190  info = 7
191  END IF
192  IF (info.NE.0) THEN
193  CALL xerbla('CTPMV ',info)
194  RETURN
195  END IF
196 *
197 * Quick return if possible.
198 *
199  IF (n.EQ.0) RETURN
200 *
201  noconj = lsame(trans,'T')
202  nounit = lsame(diag,'N')
203 *
204 * Set up the start point in X if the increment is not unity. This
205 * will be ( N - 1 )*INCX too small for descending loops.
206 *
207  IF (incx.LE.0) THEN
208  kx = 1 - (n-1)*incx
209  ELSE IF (incx.NE.1) THEN
210  kx = 1
211  END IF
212 *
213 * Start the operations. In this version the elements of AP are
214 * accessed sequentially with one pass through AP.
215 *
216  IF (lsame(trans,'N')) THEN
217 *
218 * Form x:= A*x.
219 *
220  IF (lsame(uplo,'U')) THEN
221  kk = 1
222  IF (incx.EQ.1) THEN
223  DO 20 j = 1,n
224  IF (x(j).NE.zero) THEN
225  temp = x(j)
226  k = kk
227  DO 10 i = 1,j - 1
228  x(i) = x(i) + temp*ap(k)
229  k = k + 1
230  10 CONTINUE
231  IF (nounit) x(j) = x(j)*ap(kk+j-1)
232  END IF
233  kk = kk + j
234  20 CONTINUE
235  ELSE
236  jx = kx
237  DO 40 j = 1,n
238  IF (x(jx).NE.zero) THEN
239  temp = x(jx)
240  ix = kx
241  DO 30 k = kk,kk + j - 2
242  x(ix) = x(ix) + temp*ap(k)
243  ix = ix + incx
244  30 CONTINUE
245  IF (nounit) x(jx) = x(jx)*ap(kk+j-1)
246  END IF
247  jx = jx + incx
248  kk = kk + j
249  40 CONTINUE
250  END IF
251  ELSE
252  kk = (n* (n+1))/2
253  IF (incx.EQ.1) THEN
254  DO 60 j = n,1,-1
255  IF (x(j).NE.zero) THEN
256  temp = x(j)
257  k = kk
258  DO 50 i = n,j + 1,-1
259  x(i) = x(i) + temp*ap(k)
260  k = k - 1
261  50 CONTINUE
262  IF (nounit) x(j) = x(j)*ap(kk-n+j)
263  END IF
264  kk = kk - (n-j+1)
265  60 CONTINUE
266  ELSE
267  kx = kx + (n-1)*incx
268  jx = kx
269  DO 80 j = n,1,-1
270  IF (x(jx).NE.zero) THEN
271  temp = x(jx)
272  ix = kx
273  DO 70 k = kk,kk - (n- (j+1)),-1
274  x(ix) = x(ix) + temp*ap(k)
275  ix = ix - incx
276  70 CONTINUE
277  IF (nounit) x(jx) = x(jx)*ap(kk-n+j)
278  END IF
279  jx = jx - incx
280  kk = kk - (n-j+1)
281  80 CONTINUE
282  END IF
283  END IF
284  ELSE
285 *
286 * Form x := A**T*x or x := A**H*x.
287 *
288  IF (lsame(uplo,'U')) THEN
289  kk = (n* (n+1))/2
290  IF (incx.EQ.1) THEN
291  DO 110 j = n,1,-1
292  temp = x(j)
293  k = kk - 1
294  IF (noconj) THEN
295  IF (nounit) temp = temp*ap(kk)
296  DO 90 i = j - 1,1,-1
297  temp = temp + ap(k)*x(i)
298  k = k - 1
299  90 CONTINUE
300  ELSE
301  IF (nounit) temp = temp*conjg(ap(kk))
302  DO 100 i = j - 1,1,-1
303  temp = temp + conjg(ap(k))*x(i)
304  k = k - 1
305  100 CONTINUE
306  END IF
307  x(j) = temp
308  kk = kk - j
309  110 CONTINUE
310  ELSE
311  jx = kx + (n-1)*incx
312  DO 140 j = n,1,-1
313  temp = x(jx)
314  ix = jx
315  IF (noconj) THEN
316  IF (nounit) temp = temp*ap(kk)
317  DO 120 k = kk - 1,kk - j + 1,-1
318  ix = ix - incx
319  temp = temp + ap(k)*x(ix)
320  120 CONTINUE
321  ELSE
322  IF (nounit) temp = temp*conjg(ap(kk))
323  DO 130 k = kk - 1,kk - j + 1,-1
324  ix = ix - incx
325  temp = temp + conjg(ap(k))*x(ix)
326  130 CONTINUE
327  END IF
328  x(jx) = temp
329  jx = jx - incx
330  kk = kk - j
331  140 CONTINUE
332  END IF
333  ELSE
334  kk = 1
335  IF (incx.EQ.1) THEN
336  DO 170 j = 1,n
337  temp = x(j)
338  k = kk + 1
339  IF (noconj) THEN
340  IF (nounit) temp = temp*ap(kk)
341  DO 150 i = j + 1,n
342  temp = temp + ap(k)*x(i)
343  k = k + 1
344  150 CONTINUE
345  ELSE
346  IF (nounit) temp = temp*conjg(ap(kk))
347  DO 160 i = j + 1,n
348  temp = temp + conjg(ap(k))*x(i)
349  k = k + 1
350  160 CONTINUE
351  END IF
352  x(j) = temp
353  kk = kk + (n-j+1)
354  170 CONTINUE
355  ELSE
356  jx = kx
357  DO 200 j = 1,n
358  temp = x(jx)
359  ix = jx
360  IF (noconj) THEN
361  IF (nounit) temp = temp*ap(kk)
362  DO 180 k = kk + 1,kk + n - j
363  ix = ix + incx
364  temp = temp + ap(k)*x(ix)
365  180 CONTINUE
366  ELSE
367  IF (nounit) temp = temp*conjg(ap(kk))
368  DO 190 k = kk + 1,kk + n - j
369  ix = ix + incx
370  temp = temp + conjg(ap(k))*x(ix)
371  190 CONTINUE
372  END IF
373  x(jx) = temp
374  jx = jx + incx
375  kk = kk + (n-j+1)
376  200 CONTINUE
377  END IF
378  END IF
379  END IF
380 *
381  RETURN
382 *
383 * End of CTPMV
384 *
385  END
subroutine xerbla(SRNAME, INFO)
XERBLA
Definition: xerbla.f:60
subroutine ctpmv(UPLO, TRANS, DIAG, N, AP, X, INCX)
CTPMV
Definition: ctpmv.f:142