Statistiques
| Révision :

root / src / blas / zsyr2k.f @ 4

Historique | Voir | Annoter | Télécharger (10,49 ko)

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