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