| 1 |
/* ./src_f77/dgemm.f -- translated by f2c (version 20030320). |
| 2 |
You must link the resulting object file with the libraries: |
| 3 |
-lf2c -lm (in that order) |
| 4 |
*/ |
| 5 |
|
| 6 |
#include <punc/vf2c.h> |
| 7 |
|
| 8 |
/* Subroutine */ int dgemm_(char *transa, char *transb, integer *m, integer * |
| 9 |
n, integer *k, doublereal *alpha, doublereal *a, integer *lda, |
| 10 |
doublereal *b, integer *ldb, doublereal *beta, doublereal *c__, |
| 11 |
integer *ldc, ftnlen transa_len, ftnlen transb_len) |
| 12 |
{ |
| 13 |
/* System generated locals */ |
| 14 |
integer a_dim1, a_offset, b_dim1, b_offset, c_dim1, c_offset, i__1, i__2, |
| 15 |
i__3; |
| 16 |
|
| 17 |
/* Local variables */ |
| 18 |
static integer i__, j, l, info; |
| 19 |
static logical nota, notb; |
| 20 |
static doublereal temp; |
| 21 |
static integer ncola; |
| 22 |
extern logical lsame_(char *, char *, ftnlen, ftnlen); |
| 23 |
static integer nrowa, nrowb; |
| 24 |
extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen); |
| 25 |
|
| 26 |
/* .. Scalar Arguments .. */ |
| 27 |
/* .. Array Arguments .. */ |
| 28 |
/* .. */ |
| 29 |
|
| 30 |
/* Purpose */ |
| 31 |
/* ======= */ |
| 32 |
|
| 33 |
/* DGEMM performs one of the matrix-matrix operations */ |
| 34 |
|
| 35 |
/* C := alpha*op( A )*op( B ) + beta*C, */ |
| 36 |
|
| 37 |
/* where op( X ) is one of */ |
| 38 |
|
| 39 |
/* op( X ) = X or op( X ) = X', */ |
| 40 |
|
| 41 |
/* alpha and beta are scalars, and A, B and C are matrices, with op( A ) */ |
| 42 |
/* an m by k matrix, op( B ) a k by n matrix and C an m by n matrix. */ |
| 43 |
|
| 44 |
/* Parameters */ |
| 45 |
/* ========== */ |
| 46 |
|
| 47 |
/* TRANSA - CHARACTER*1. */ |
| 48 |
/* On entry, TRANSA specifies the form of op( A ) to be used in */ |
| 49 |
/* the matrix multiplication as follows: */ |
| 50 |
|
| 51 |
/* TRANSA = 'N' or 'n', op( A ) = A. */ |
| 52 |
|
| 53 |
/* TRANSA = 'T' or 't', op( A ) = A'. */ |
| 54 |
|
| 55 |
/* TRANSA = 'C' or 'c', op( A ) = A'. */ |
| 56 |
|
| 57 |
/* Unchanged on exit. */ |
| 58 |
|
| 59 |
/* TRANSB - CHARACTER*1. */ |
| 60 |
/* On entry, TRANSB specifies the form of op( B ) to be used in */ |
| 61 |
/* the matrix multiplication as follows: */ |
| 62 |
|
| 63 |
/* TRANSB = 'N' or 'n', op( B ) = B. */ |
| 64 |
|
| 65 |
/* TRANSB = 'T' or 't', op( B ) = B'. */ |
| 66 |
|
| 67 |
/* TRANSB = 'C' or 'c', op( B ) = B'. */ |
| 68 |
|
| 69 |
/* Unchanged on exit. */ |
| 70 |
|
| 71 |
/* M - INTEGER. */ |
| 72 |
/* On entry, M specifies the number of rows of the matrix */ |
| 73 |
/* op( A ) and of the matrix C. M must be at least zero. */ |
| 74 |
/* Unchanged on exit. */ |
| 75 |
|
| 76 |
/* N - INTEGER. */ |
| 77 |
/* On entry, N specifies the number of columns of the matrix */ |
| 78 |
/* op( B ) and the number of columns of the matrix C. N must be */ |
| 79 |
/* at least zero. */ |
| 80 |
/* Unchanged on exit. */ |
| 81 |
|
| 82 |
/* K - INTEGER. */ |
| 83 |
/* On entry, K specifies the number of columns of the matrix */ |
| 84 |
/* op( A ) and the number of rows of the matrix op( B ). K must */ |
| 85 |
/* be at least zero. */ |
| 86 |
/* Unchanged on exit. */ |
| 87 |
|
| 88 |
/* ALPHA - DOUBLE PRECISION. */ |
| 89 |
/* On entry, ALPHA specifies the scalar alpha. */ |
| 90 |
/* Unchanged on exit. */ |
| 91 |
|
| 92 |
/* A - DOUBLE PRECISION array of DIMENSION ( LDA, ka ), where ka is */ |
| 93 |
/* k when TRANSA = 'N' or 'n', and is m otherwise. */ |
| 94 |
/* Before entry with TRANSA = 'N' or 'n', the leading m by k */ |
| 95 |
/* part of the array A must contain the matrix A, otherwise */ |
| 96 |
/* the leading k by m part of the array A must contain the */ |
| 97 |
/* matrix A. */ |
| 98 |
/* Unchanged on exit. */ |
| 99 |
|
| 100 |
/* LDA - INTEGER. */ |
| 101 |
/* On entry, LDA specifies the first dimension of A as declared */ |
| 102 |
/* in the calling (sub) program. When TRANSA = 'N' or 'n' then */ |
| 103 |
/* LDA must be at least max( 1, m ), otherwise LDA must be at */ |
| 104 |
/* least max( 1, k ). */ |
| 105 |
/* Unchanged on exit. */ |
| 106 |
|
| 107 |
/* B - DOUBLE PRECISION array of DIMENSION ( LDB, kb ), where kb is */ |
| 108 |
/* n when TRANSB = 'N' or 'n', and is k otherwise. */ |
| 109 |
/* Before entry with TRANSB = 'N' or 'n', the leading k by n */ |
| 110 |
/* part of the array B must contain the matrix B, otherwise */ |
| 111 |
/* the leading n by k part of the array B must contain the */ |
| 112 |
/* matrix B. */ |
| 113 |
/* Unchanged on exit. */ |
| 114 |
|
| 115 |
/* LDB - INTEGER. */ |
| 116 |
/* On entry, LDB specifies the first dimension of B as declared */ |
| 117 |
/* in the calling (sub) program. When TRANSB = 'N' or 'n' then */ |
| 118 |
/* LDB must be at least max( 1, k ), otherwise LDB must be at */ |
| 119 |
/* least max( 1, n ). */ |
| 120 |
/* Unchanged on exit. */ |
| 121 |
|
| 122 |
/* BETA - DOUBLE PRECISION. */ |
| 123 |
/* On entry, BETA specifies the scalar beta. When BETA is */ |
| 124 |
/* supplied as zero then C need not be set on input. */ |
| 125 |
/* Unchanged on exit. */ |
| 126 |
|
| 127 |
/* C - DOUBLE PRECISION array of DIMENSION ( LDC, n ). */ |
| 128 |
/* Before entry, the leading m by n part of the array C must */ |
| 129 |
/* contain the matrix C, except when beta is zero, in which */ |
| 130 |
/* case C need not be set on entry. */ |
| 131 |
/* On exit, the array C is overwritten by the m by n matrix */ |
| 132 |
/* ( alpha*op( A )*op( B ) + beta*C ). */ |
| 133 |
|
| 134 |
/* LDC - INTEGER. */ |
| 135 |
/* On entry, LDC specifies the first dimension of C as declared */ |
| 136 |
/* in the calling (sub) program. LDC must be at least */ |
| 137 |
/* max( 1, m ). */ |
| 138 |
/* Unchanged on exit. */ |
| 139 |
|
| 140 |
|
| 141 |
/* Level 3 Blas routine. */ |
| 142 |
|
| 143 |
/* -- Written on 8-February-1989. */ |
| 144 |
/* Jack Dongarra, Argonne National Laboratory. */ |
| 145 |
/* Iain Duff, AERE Harwell. */ |
| 146 |
/* Jeremy Du Croz, Numerical Algorithms Group Ltd. */ |
| 147 |
/* Sven Hammarling, Numerical Algorithms Group Ltd. */ |
| 148 |
|
| 149 |
|
| 150 |
/* .. External Functions .. */ |
| 151 |
/* .. External Subroutines .. */ |
| 152 |
/* .. Intrinsic Functions .. */ |
| 153 |
/* .. Local Scalars .. */ |
| 154 |
/* .. Parameters .. */ |
| 155 |
/* .. */ |
| 156 |
/* .. Executable Statements .. */ |
| 157 |
|
| 158 |
/* Set NOTA and NOTB as true if A and B respectively are not */ |
| 159 |
/* transposed and set NROWA, NCOLA and NROWB as the number of rows */ |
| 160 |
/* and columns of A and the number of rows of B respectively. */ |
| 161 |
|
| 162 |
/* Parameter adjustments */ |
| 163 |
a_dim1 = *lda; |
| 164 |
a_offset = 1 + a_dim1; |
| 165 |
a -= a_offset; |
| 166 |
b_dim1 = *ldb; |
| 167 |
b_offset = 1 + b_dim1; |
| 168 |
b -= b_offset; |
| 169 |
c_dim1 = *ldc; |
| 170 |
c_offset = 1 + c_dim1; |
| 171 |
c__ -= c_offset; |
| 172 |
|
| 173 |
/* Function Body */ |
| 174 |
nota = lsame_(transa, "N", (ftnlen)1, (ftnlen)1); |
| 175 |
notb = lsame_(transb, "N", (ftnlen)1, (ftnlen)1); |
| 176 |
if (nota) { |
| 177 |
nrowa = *m; |
| 178 |
ncola = *k; |
| 179 |
} else { |
| 180 |
nrowa = *k; |
| 181 |
ncola = *m; |
| 182 |
} |
| 183 |
if (notb) { |
| 184 |
nrowb = *k; |
| 185 |
} else { |
| 186 |
nrowb = *n; |
| 187 |
} |
| 188 |
|
| 189 |
/* Test the input parameters. */ |
| 190 |
|
| 191 |
info = 0; |
| 192 |
if (! nota && ! lsame_(transa, "C", (ftnlen)1, (ftnlen)1) && ! lsame_( |
| 193 |
transa, "T", (ftnlen)1, (ftnlen)1)) { |
| 194 |
info = 1; |
| 195 |
} else if (! notb && ! lsame_(transb, "C", (ftnlen)1, (ftnlen)1) && ! |
| 196 |
lsame_(transb, "T", (ftnlen)1, (ftnlen)1)) { |
| 197 |
info = 2; |
| 198 |
} else if (*m < 0) { |
| 199 |
info = 3; |
| 200 |
} else if (*n < 0) { |
| 201 |
info = 4; |
| 202 |
} else if (*k < 0) { |
| 203 |
info = 5; |
| 204 |
} else if (*lda < max(1,nrowa)) { |
| 205 |
info = 8; |
| 206 |
} else if (*ldb < max(1,nrowb)) { |
| 207 |
info = 10; |
| 208 |
} else if (*ldc < max(1,*m)) { |
| 209 |
info = 13; |
| 210 |
} |
| 211 |
if (info != 0) { |
| 212 |
xerbla_("DGEMM ", &info, (ftnlen)6); |
| 213 |
return 0; |
| 214 |
} |
| 215 |
|
| 216 |
/* Quick return if possible. */ |
| 217 |
|
| 218 |
if (*m == 0 || *n == 0 || (*alpha == 0. || *k == 0) && *beta == 1.) { |
| 219 |
return 0; |
| 220 |
} |
| 221 |
|
| 222 |
/* And if alpha.eq.zero. */ |
| 223 |
|
| 224 |
if (*alpha == 0.) { |
| 225 |
if (*beta == 0.) { |
| 226 |
i__1 = *n; |
| 227 |
for (j = 1; j <= i__1; ++j) { |
| 228 |
i__2 = *m; |
| 229 |
for (i__ = 1; i__ <= i__2; ++i__) { |
| 230 |
c__[i__ + j * c_dim1] = 0.; |
| 231 |
/* L10: */ |
| 232 |
} |
| 233 |
/* L20: */ |
| 234 |
} |
| 235 |
} else { |
| 236 |
i__1 = *n; |
| 237 |
for (j = 1; j <= i__1; ++j) { |
| 238 |
i__2 = *m; |
| 239 |
for (i__ = 1; i__ <= i__2; ++i__) { |
| 240 |
c__[i__ + j * c_dim1] = *beta * c__[i__ + j * c_dim1]; |
| 241 |
/* L30: */ |
| 242 |
} |
| 243 |
/* L40: */ |
| 244 |
} |
| 245 |
} |
| 246 |
return 0; |
| 247 |
} |
| 248 |
|
| 249 |
/* Start the operations. */ |
| 250 |
|
| 251 |
if (notb) { |
| 252 |
if (nota) { |
| 253 |
|
| 254 |
/* Form C := alpha*A*B + beta*C. */ |
| 255 |
|
| 256 |
i__1 = *n; |
| 257 |
for (j = 1; j <= i__1; ++j) { |
| 258 |
if (*beta == 0.) { |
| 259 |
i__2 = *m; |
| 260 |
for (i__ = 1; i__ <= i__2; ++i__) { |
| 261 |
c__[i__ + j * c_dim1] = 0.; |
| 262 |
/* L50: */ |
| 263 |
} |
| 264 |
} else if (*beta != 1.) { |
| 265 |
i__2 = *m; |
| 266 |
for (i__ = 1; i__ <= i__2; ++i__) { |
| 267 |
c__[i__ + j * c_dim1] = *beta * c__[i__ + j * c_dim1]; |
| 268 |
/* L60: */ |
| 269 |
} |
| 270 |
} |
| 271 |
i__2 = *k; |
| 272 |
for (l = 1; l <= i__2; ++l) { |
| 273 |
if (b[l + j * b_dim1] != 0.) { |
| 274 |
temp = *alpha * b[l + j * b_dim1]; |
| 275 |
i__3 = *m; |
| 276 |
for (i__ = 1; i__ <= i__3; ++i__) { |
| 277 |
c__[i__ + j * c_dim1] += temp * a[i__ + l * |
| 278 |
a_dim1]; |
| 279 |
/* L70: */ |
| 280 |
} |
| 281 |
} |
| 282 |
/* L80: */ |
| 283 |
} |
| 284 |
/* L90: */ |
| 285 |
} |
| 286 |
} else { |
| 287 |
|
| 288 |
/* Form C := alpha*A'*B + beta*C */ |
| 289 |
|
| 290 |
i__1 = *n; |
| 291 |
for (j = 1; j <= i__1; ++j) { |
| 292 |
i__2 = *m; |
| 293 |
for (i__ = 1; i__ <= i__2; ++i__) { |
| 294 |
temp = 0.; |
| 295 |
i__3 = *k; |
| 296 |
for (l = 1; l <= i__3; ++l) { |
| 297 |
temp += a[l + i__ * a_dim1] * b[l + j * b_dim1]; |
| 298 |
/* L100: */ |
| 299 |
} |
| 300 |
if (*beta == 0.) { |
| 301 |
c__[i__ + j * c_dim1] = *alpha * temp; |
| 302 |
} else { |
| 303 |
c__[i__ + j * c_dim1] = *alpha * temp + *beta * c__[ |
| 304 |
i__ + j * c_dim1]; |
| 305 |
} |
| 306 |
/* L110: */ |
| 307 |
} |
| 308 |
/* L120: */ |
| 309 |
} |
| 310 |
} |
| 311 |
} else { |
| 312 |
if (nota) { |
| 313 |
|
| 314 |
/* Form C := alpha*A*B' + beta*C */ |
| 315 |
|
| 316 |
i__1 = *n; |
| 317 |
for (j = 1; j <= i__1; ++j) { |
| 318 |
if (*beta == 0.) { |
| 319 |
i__2 = *m; |
| 320 |
for (i__ = 1; i__ <= i__2; ++i__) { |
| 321 |
c__[i__ + j * c_dim1] = 0.; |
| 322 |
/* L130: */ |
| 323 |
} |
| 324 |
} else if (*beta != 1.) { |
| 325 |
i__2 = *m; |
| 326 |
for (i__ = 1; i__ <= i__2; ++i__) { |
| 327 |
c__[i__ + j * c_dim1] = *beta * c__[i__ + j * c_dim1]; |
| 328 |
/* L140: */ |
| 329 |
} |
| 330 |
} |
| 331 |
i__2 = *k; |
| 332 |
for (l = 1; l <= i__2; ++l) { |
| 333 |
if (b[j + l * b_dim1] != 0.) { |
| 334 |
temp = *alpha * b[j + l * b_dim1]; |
| 335 |
i__3 = *m; |
| 336 |
for (i__ = 1; i__ <= i__3; ++i__) { |
| 337 |
c__[i__ + j * c_dim1] += temp * a[i__ + l * |
| 338 |
a_dim1]; |
| 339 |
/* L150: */ |
| 340 |
} |
| 341 |
} |
| 342 |
/* L160: */ |
| 343 |
} |
| 344 |
/* L170: */ |
| 345 |
} |
| 346 |
} else { |
| 347 |
|
| 348 |
/* Form C := alpha*A'*B' + beta*C */ |
| 349 |
|
| 350 |
i__1 = *n; |
| 351 |
for (j = 1; j <= i__1; ++j) { |
| 352 |
i__2 = *m; |
| 353 |
for (i__ = 1; i__ <= i__2; ++i__) { |
| 354 |
temp = 0.; |
| 355 |
i__3 = *k; |
| 356 |
for (l = 1; l <= i__3; ++l) { |
| 357 |
temp += a[l + i__ * a_dim1] * b[j + l * b_dim1]; |
| 358 |
/* L180: */ |
| 359 |
} |
| 360 |
if (*beta == 0.) { |
| 361 |
c__[i__ + j * c_dim1] = *alpha * temp; |
| 362 |
} else { |
| 363 |
c__[i__ + j * c_dim1] = *alpha * temp + *beta * c__[ |
| 364 |
i__ + j * c_dim1]; |
| 365 |
} |
| 366 |
/* L190: */ |
| 367 |
} |
| 368 |
/* L200: */ |
| 369 |
} |
| 370 |
} |
| 371 |
} |
| 372 |
|
| 373 |
return 0; |
| 374 |
|
| 375 |
/* End of DGEMM . */ |
| 376 |
|
| 377 |
} /* dgemm_ */ |
| 378 |
|