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