root / src / blas / dsyrk.f @ 5
Historique | Voir | Annoter | Télécharger (9,04 ko)
1 | 1 | pfleura2 | SUBROUTINE DSYRK(UPLO,TRANS,N,K,ALPHA,A,LDA,BETA,C,LDC) |
---|---|---|---|
2 | 1 | pfleura2 | * .. Scalar Arguments .. |
3 | 1 | pfleura2 | DOUBLE PRECISION ALPHA,BETA |
4 | 1 | pfleura2 | INTEGER K,LDA,LDC,N |
5 | 1 | pfleura2 | CHARACTER TRANS,UPLO |
6 | 1 | pfleura2 | * .. |
7 | 1 | pfleura2 | * .. Array Arguments .. |
8 | 1 | pfleura2 | DOUBLE PRECISION A(LDA,*),C(LDC,*) |
9 | 1 | pfleura2 | * .. |
10 | 1 | pfleura2 | * |
11 | 1 | pfleura2 | * Purpose |
12 | 1 | pfleura2 | * ======= |
13 | 1 | pfleura2 | * |
14 | 1 | pfleura2 | * DSYRK performs one of the symmetric rank k operations |
15 | 1 | pfleura2 | * |
16 | 1 | pfleura2 | * C := alpha*A*A' + beta*C, |
17 | 1 | pfleura2 | * |
18 | 1 | pfleura2 | * or |
19 | 1 | pfleura2 | * |
20 | 1 | pfleura2 | * C := alpha*A'*A + beta*C, |
21 | 1 | pfleura2 | * |
22 | 1 | pfleura2 | * where alpha and beta are scalars, C is an n by n symmetric matrix |
23 | 1 | pfleura2 | * and A is an n by k matrix in the first case and a k by n matrix |
24 | 1 | pfleura2 | * in the second case. |
25 | 1 | pfleura2 | * |
26 | 1 | pfleura2 | * Arguments |
27 | 1 | pfleura2 | * ========== |
28 | 1 | pfleura2 | * |
29 | 1 | pfleura2 | * UPLO - CHARACTER*1. |
30 | 1 | pfleura2 | * On entry, UPLO specifies whether the upper or lower |
31 | 1 | pfleura2 | * triangular part of the array C is to be referenced as |
32 | 1 | pfleura2 | * follows: |
33 | 1 | pfleura2 | * |
34 | 1 | pfleura2 | * UPLO = 'U' or 'u' Only the upper triangular part of C |
35 | 1 | pfleura2 | * is to be referenced. |
36 | 1 | pfleura2 | * |
37 | 1 | pfleura2 | * UPLO = 'L' or 'l' Only the lower triangular part of C |
38 | 1 | pfleura2 | * is to be referenced. |
39 | 1 | pfleura2 | * |
40 | 1 | pfleura2 | * Unchanged on exit. |
41 | 1 | pfleura2 | * |
42 | 1 | pfleura2 | * TRANS - CHARACTER*1. |
43 | 1 | pfleura2 | * On entry, TRANS specifies the operation to be performed as |
44 | 1 | pfleura2 | * follows: |
45 | 1 | pfleura2 | * |
46 | 1 | pfleura2 | * TRANS = 'N' or 'n' C := alpha*A*A' + beta*C. |
47 | 1 | pfleura2 | * |
48 | 1 | pfleura2 | * TRANS = 'T' or 't' C := alpha*A'*A + beta*C. |
49 | 1 | pfleura2 | * |
50 | 1 | pfleura2 | * TRANS = 'C' or 'c' C := alpha*A'*A + beta*C. |
51 | 1 | pfleura2 | * |
52 | 1 | pfleura2 | * Unchanged on exit. |
53 | 1 | pfleura2 | * |
54 | 1 | pfleura2 | * N - INTEGER. |
55 | 1 | pfleura2 | * On entry, N specifies the order of the matrix C. N must be |
56 | 1 | pfleura2 | * at least zero. |
57 | 1 | pfleura2 | * Unchanged on exit. |
58 | 1 | pfleura2 | * |
59 | 1 | pfleura2 | * K - INTEGER. |
60 | 1 | pfleura2 | * On entry with TRANS = 'N' or 'n', K specifies the number |
61 | 1 | pfleura2 | * of columns of the matrix A, and on entry with |
62 | 1 | pfleura2 | * TRANS = 'T' or 't' or 'C' or 'c', K specifies the number |
63 | 1 | pfleura2 | * of rows of the matrix A. K must be at least zero. |
64 | 1 | pfleura2 | * Unchanged on exit. |
65 | 1 | pfleura2 | * |
66 | 1 | pfleura2 | * ALPHA - DOUBLE PRECISION. |
67 | 1 | pfleura2 | * On entry, ALPHA specifies the scalar alpha. |
68 | 1 | pfleura2 | * Unchanged on exit. |
69 | 1 | pfleura2 | * |
70 | 1 | pfleura2 | * A - DOUBLE PRECISION array of DIMENSION ( LDA, ka ), where ka is |
71 | 1 | pfleura2 | * k when TRANS = 'N' or 'n', and is n otherwise. |
72 | 1 | pfleura2 | * Before entry with TRANS = 'N' or 'n', the leading n by k |
73 | 1 | pfleura2 | * part of the array A must contain the matrix A, otherwise |
74 | 1 | pfleura2 | * the leading k by n part of the array A must contain the |
75 | 1 | pfleura2 | * matrix A. |
76 | 1 | pfleura2 | * Unchanged on exit. |
77 | 1 | pfleura2 | * |
78 | 1 | pfleura2 | * LDA - INTEGER. |
79 | 1 | pfleura2 | * On entry, LDA specifies the first dimension of A as declared |
80 | 1 | pfleura2 | * in the calling (sub) program. When TRANS = 'N' or 'n' |
81 | 1 | pfleura2 | * then LDA must be at least max( 1, n ), otherwise LDA must |
82 | 1 | pfleura2 | * be at least max( 1, k ). |
83 | 1 | pfleura2 | * Unchanged on exit. |
84 | 1 | pfleura2 | * |
85 | 1 | pfleura2 | * BETA - DOUBLE PRECISION. |
86 | 1 | pfleura2 | * On entry, BETA specifies the scalar beta. |
87 | 1 | pfleura2 | * Unchanged on exit. |
88 | 1 | pfleura2 | * |
89 | 1 | pfleura2 | * C - DOUBLE PRECISION array of DIMENSION ( LDC, n ). |
90 | 1 | pfleura2 | * Before entry with UPLO = 'U' or 'u', the leading n by n |
91 | 1 | pfleura2 | * upper triangular part of the array C must contain the upper |
92 | 1 | pfleura2 | * triangular part of the symmetric matrix and the strictly |
93 | 1 | pfleura2 | * lower triangular part of C is not referenced. On exit, the |
94 | 1 | pfleura2 | * upper triangular part of the array C is overwritten by the |
95 | 1 | pfleura2 | * upper triangular part of the updated matrix. |
96 | 1 | pfleura2 | * Before entry with UPLO = 'L' or 'l', the leading n by n |
97 | 1 | pfleura2 | * lower triangular part of the array C must contain the lower |
98 | 1 | pfleura2 | * triangular part of the symmetric matrix and the strictly |
99 | 1 | pfleura2 | * upper triangular part of C is not referenced. On exit, the |
100 | 1 | pfleura2 | * lower triangular part of the array C is overwritten by the |
101 | 1 | pfleura2 | * lower triangular part of the updated matrix. |
102 | 1 | pfleura2 | * |
103 | 1 | pfleura2 | * LDC - INTEGER. |
104 | 1 | pfleura2 | * On entry, LDC specifies the first dimension of C as declared |
105 | 1 | pfleura2 | * in the calling (sub) program. LDC must be at least |
106 | 1 | pfleura2 | * max( 1, n ). |
107 | 1 | pfleura2 | * Unchanged on exit. |
108 | 1 | pfleura2 | * |
109 | 1 | pfleura2 | * |
110 | 1 | pfleura2 | * Level 3 Blas routine. |
111 | 1 | pfleura2 | * |
112 | 1 | pfleura2 | * -- Written on 8-February-1989. |
113 | 1 | pfleura2 | * Jack Dongarra, Argonne National Laboratory. |
114 | 1 | pfleura2 | * Iain Duff, AERE Harwell. |
115 | 1 | pfleura2 | * Jeremy Du Croz, Numerical Algorithms Group Ltd. |
116 | 1 | pfleura2 | * Sven Hammarling, Numerical Algorithms Group Ltd. |
117 | 1 | pfleura2 | * |
118 | 1 | pfleura2 | * |
119 | 1 | pfleura2 | * .. External Functions .. |
120 | 1 | pfleura2 | LOGICAL LSAME |
121 | 1 | pfleura2 | EXTERNAL LSAME |
122 | 1 | pfleura2 | * .. |
123 | 1 | pfleura2 | * .. External Subroutines .. |
124 | 1 | pfleura2 | EXTERNAL XERBLA |
125 | 1 | pfleura2 | * .. |
126 | 1 | pfleura2 | * .. Intrinsic Functions .. |
127 | 1 | pfleura2 | INTRINSIC MAX |
128 | 1 | pfleura2 | * .. |
129 | 1 | pfleura2 | * .. Local Scalars .. |
130 | 1 | pfleura2 | DOUBLE PRECISION TEMP |
131 | 1 | pfleura2 | INTEGER I,INFO,J,L,NROWA |
132 | 1 | pfleura2 | LOGICAL UPPER |
133 | 1 | pfleura2 | * .. |
134 | 1 | pfleura2 | * .. Parameters .. |
135 | 1 | pfleura2 | DOUBLE PRECISION ONE,ZERO |
136 | 1 | pfleura2 | PARAMETER (ONE=1.0D+0,ZERO=0.0D+0) |
137 | 1 | pfleura2 | * .. |
138 | 1 | pfleura2 | * |
139 | 1 | pfleura2 | * Test the input parameters. |
140 | 1 | pfleura2 | * |
141 | 1 | pfleura2 | IF (LSAME(TRANS,'N')) THEN |
142 | 1 | pfleura2 | NROWA = N |
143 | 1 | pfleura2 | ELSE |
144 | 1 | pfleura2 | NROWA = K |
145 | 1 | pfleura2 | END IF |
146 | 1 | pfleura2 | UPPER = LSAME(UPLO,'U') |
147 | 1 | pfleura2 | * |
148 | 1 | pfleura2 | INFO = 0 |
149 | 1 | pfleura2 | IF ((.NOT.UPPER) .AND. (.NOT.LSAME(UPLO,'L'))) THEN |
150 | 1 | pfleura2 | INFO = 1 |
151 | 1 | pfleura2 | ELSE IF ((.NOT.LSAME(TRANS,'N')) .AND. |
152 | 1 | pfleura2 | + (.NOT.LSAME(TRANS,'T')) .AND. |
153 | 1 | pfleura2 | + (.NOT.LSAME(TRANS,'C'))) THEN |
154 | 1 | pfleura2 | INFO = 2 |
155 | 1 | pfleura2 | ELSE IF (N.LT.0) THEN |
156 | 1 | pfleura2 | INFO = 3 |
157 | 1 | pfleura2 | ELSE IF (K.LT.0) THEN |
158 | 1 | pfleura2 | INFO = 4 |
159 | 1 | pfleura2 | ELSE IF (LDA.LT.MAX(1,NROWA)) THEN |
160 | 1 | pfleura2 | INFO = 7 |
161 | 1 | pfleura2 | ELSE IF (LDC.LT.MAX(1,N)) THEN |
162 | 1 | pfleura2 | INFO = 10 |
163 | 1 | pfleura2 | END IF |
164 | 1 | pfleura2 | IF (INFO.NE.0) THEN |
165 | 1 | pfleura2 | CALL XERBLA('DSYRK ',INFO) |
166 | 1 | pfleura2 | RETURN |
167 | 1 | pfleura2 | END IF |
168 | 1 | pfleura2 | * |
169 | 1 | pfleura2 | * Quick return if possible. |
170 | 1 | pfleura2 | * |
171 | 1 | pfleura2 | IF ((N.EQ.0) .OR. (((ALPHA.EQ.ZERO).OR. |
172 | 1 | pfleura2 | + (K.EQ.0)).AND. (BETA.EQ.ONE))) RETURN |
173 | 1 | pfleura2 | * |
174 | 1 | pfleura2 | * And when alpha.eq.zero. |
175 | 1 | pfleura2 | * |
176 | 1 | pfleura2 | IF (ALPHA.EQ.ZERO) THEN |
177 | 1 | pfleura2 | IF (UPPER) THEN |
178 | 1 | pfleura2 | IF (BETA.EQ.ZERO) THEN |
179 | 1 | pfleura2 | DO 20 J = 1,N |
180 | 1 | pfleura2 | DO 10 I = 1,J |
181 | 1 | pfleura2 | C(I,J) = ZERO |
182 | 1 | pfleura2 | 10 CONTINUE |
183 | 1 | pfleura2 | 20 CONTINUE |
184 | 1 | pfleura2 | ELSE |
185 | 1 | pfleura2 | DO 40 J = 1,N |
186 | 1 | pfleura2 | DO 30 I = 1,J |
187 | 1 | pfleura2 | C(I,J) = BETA*C(I,J) |
188 | 1 | pfleura2 | 30 CONTINUE |
189 | 1 | pfleura2 | 40 CONTINUE |
190 | 1 | pfleura2 | END IF |
191 | 1 | pfleura2 | ELSE |
192 | 1 | pfleura2 | IF (BETA.EQ.ZERO) THEN |
193 | 1 | pfleura2 | DO 60 J = 1,N |
194 | 1 | pfleura2 | DO 50 I = J,N |
195 | 1 | pfleura2 | C(I,J) = ZERO |
196 | 1 | pfleura2 | 50 CONTINUE |
197 | 1 | pfleura2 | 60 CONTINUE |
198 | 1 | pfleura2 | ELSE |
199 | 1 | pfleura2 | DO 80 J = 1,N |
200 | 1 | pfleura2 | DO 70 I = J,N |
201 | 1 | pfleura2 | C(I,J) = BETA*C(I,J) |
202 | 1 | pfleura2 | 70 CONTINUE |
203 | 1 | pfleura2 | 80 CONTINUE |
204 | 1 | pfleura2 | END IF |
205 | 1 | pfleura2 | END IF |
206 | 1 | pfleura2 | RETURN |
207 | 1 | pfleura2 | END IF |
208 | 1 | pfleura2 | * |
209 | 1 | pfleura2 | * Start the operations. |
210 | 1 | pfleura2 | * |
211 | 1 | pfleura2 | IF (LSAME(TRANS,'N')) THEN |
212 | 1 | pfleura2 | * |
213 | 1 | pfleura2 | * Form C := alpha*A*A' + beta*C. |
214 | 1 | pfleura2 | * |
215 | 1 | pfleura2 | IF (UPPER) THEN |
216 | 1 | pfleura2 | DO 130 J = 1,N |
217 | 1 | pfleura2 | IF (BETA.EQ.ZERO) THEN |
218 | 1 | pfleura2 | DO 90 I = 1,J |
219 | 1 | pfleura2 | C(I,J) = ZERO |
220 | 1 | pfleura2 | 90 CONTINUE |
221 | 1 | pfleura2 | ELSE IF (BETA.NE.ONE) THEN |
222 | 1 | pfleura2 | DO 100 I = 1,J |
223 | 1 | pfleura2 | C(I,J) = BETA*C(I,J) |
224 | 1 | pfleura2 | 100 CONTINUE |
225 | 1 | pfleura2 | END IF |
226 | 1 | pfleura2 | DO 120 L = 1,K |
227 | 1 | pfleura2 | IF (A(J,L).NE.ZERO) THEN |
228 | 1 | pfleura2 | TEMP = ALPHA*A(J,L) |
229 | 1 | pfleura2 | DO 110 I = 1,J |
230 | 1 | pfleura2 | C(I,J) = C(I,J) + TEMP*A(I,L) |
231 | 1 | pfleura2 | 110 CONTINUE |
232 | 1 | pfleura2 | END IF |
233 | 1 | pfleura2 | 120 CONTINUE |
234 | 1 | pfleura2 | 130 CONTINUE |
235 | 1 | pfleura2 | ELSE |
236 | 1 | pfleura2 | DO 180 J = 1,N |
237 | 1 | pfleura2 | IF (BETA.EQ.ZERO) THEN |
238 | 1 | pfleura2 | DO 140 I = J,N |
239 | 1 | pfleura2 | C(I,J) = ZERO |
240 | 1 | pfleura2 | 140 CONTINUE |
241 | 1 | pfleura2 | ELSE IF (BETA.NE.ONE) THEN |
242 | 1 | pfleura2 | DO 150 I = J,N |
243 | 1 | pfleura2 | C(I,J) = BETA*C(I,J) |
244 | 1 | pfleura2 | 150 CONTINUE |
245 | 1 | pfleura2 | END IF |
246 | 1 | pfleura2 | DO 170 L = 1,K |
247 | 1 | pfleura2 | IF (A(J,L).NE.ZERO) THEN |
248 | 1 | pfleura2 | TEMP = ALPHA*A(J,L) |
249 | 1 | pfleura2 | DO 160 I = J,N |
250 | 1 | pfleura2 | C(I,J) = C(I,J) + TEMP*A(I,L) |
251 | 1 | pfleura2 | 160 CONTINUE |
252 | 1 | pfleura2 | END IF |
253 | 1 | pfleura2 | 170 CONTINUE |
254 | 1 | pfleura2 | 180 CONTINUE |
255 | 1 | pfleura2 | END IF |
256 | 1 | pfleura2 | ELSE |
257 | 1 | pfleura2 | * |
258 | 1 | pfleura2 | * Form C := alpha*A'*A + beta*C. |
259 | 1 | pfleura2 | * |
260 | 1 | pfleura2 | IF (UPPER) THEN |
261 | 1 | pfleura2 | DO 210 J = 1,N |
262 | 1 | pfleura2 | DO 200 I = 1,J |
263 | 1 | pfleura2 | TEMP = ZERO |
264 | 1 | pfleura2 | DO 190 L = 1,K |
265 | 1 | pfleura2 | TEMP = TEMP + A(L,I)*A(L,J) |
266 | 1 | pfleura2 | 190 CONTINUE |
267 | 1 | pfleura2 | IF (BETA.EQ.ZERO) THEN |
268 | 1 | pfleura2 | C(I,J) = ALPHA*TEMP |
269 | 1 | pfleura2 | ELSE |
270 | 1 | pfleura2 | C(I,J) = ALPHA*TEMP + BETA*C(I,J) |
271 | 1 | pfleura2 | END IF |
272 | 1 | pfleura2 | 200 CONTINUE |
273 | 1 | pfleura2 | 210 CONTINUE |
274 | 1 | pfleura2 | ELSE |
275 | 1 | pfleura2 | DO 240 J = 1,N |
276 | 1 | pfleura2 | DO 230 I = J,N |
277 | 1 | pfleura2 | TEMP = ZERO |
278 | 1 | pfleura2 | DO 220 L = 1,K |
279 | 1 | pfleura2 | TEMP = TEMP + A(L,I)*A(L,J) |
280 | 1 | pfleura2 | 220 CONTINUE |
281 | 1 | pfleura2 | IF (BETA.EQ.ZERO) THEN |
282 | 1 | pfleura2 | C(I,J) = ALPHA*TEMP |
283 | 1 | pfleura2 | ELSE |
284 | 1 | pfleura2 | C(I,J) = ALPHA*TEMP + BETA*C(I,J) |
285 | 1 | pfleura2 | END IF |
286 | 1 | pfleura2 | 230 CONTINUE |
287 | 1 | pfleura2 | 240 CONTINUE |
288 | 1 | pfleura2 | END IF |
289 | 1 | pfleura2 | END IF |
290 | 1 | pfleura2 | * |
291 | 1 | pfleura2 | RETURN |
292 | 1 | pfleura2 | * |
293 | 1 | pfleura2 | * End of DSYRK . |
294 | 1 | pfleura2 | * |
295 | 1 | pfleura2 | END |