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