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