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