Statistiques
| Révision :

root / src / blas / ssyr2k.f @ 5

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

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