Statistiques
| Révision :

root / src / blas / csyrk.f @ 4

Historique | Voir | Annoter | Télécharger (8,94 ko)

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