LAPACK 3.12.0 LAPACK: Linear Algebra PACKage
Searching...
No Matches

## ◆ dgemm()

 subroutine dgemm ( character transa, character transb, integer m, integer n, integer k, double precision alpha, double precision, dimension(lda,*) a, integer lda, double precision, dimension(ldb,*) b, integer ldb, double precision beta, double precision, dimension(ldc,*) c, integer ldc )

DGEMM

Purpose:
``` DGEMM  performs one of the matrix-matrix operations

C := alpha*op( A )*op( B ) + beta*C,

where  op( X ) is one of

op( X ) = X   or   op( X ) = X**T,

alpha and beta are scalars, and A, B and C are matrices, with op( A )
an m by k matrix,  op( B )  a  k by n matrix and  C an m by n matrix.```
Parameters
 [in] TRANSA ``` TRANSA is CHARACTER*1 On entry, TRANSA specifies the form of op( A ) to be used in the matrix multiplication as follows: TRANSA = 'N' or 'n', op( A ) = A. TRANSA = 'T' or 't', op( A ) = A**T. TRANSA = 'C' or 'c', op( A ) = A**T.``` [in] TRANSB ``` TRANSB is CHARACTER*1 On entry, TRANSB specifies the form of op( B ) to be used in the matrix multiplication as follows: TRANSB = 'N' or 'n', op( B ) = B. TRANSB = 'T' or 't', op( B ) = B**T. TRANSB = 'C' or 'c', op( B ) = B**T.``` [in] M ``` M is INTEGER On entry, M specifies the number of rows of the matrix op( A ) and of the matrix C. M must be at least zero.``` [in] N ``` N is INTEGER On entry, N specifies the number of columns of the matrix op( B ) and the number of columns of the matrix C. N must be at least zero.``` [in] K ``` K is INTEGER On entry, K specifies the number of columns of the matrix op( A ) and the number of rows of the matrix op( B ). K must be at least zero.``` [in] ALPHA ``` ALPHA is DOUBLE PRECISION. On entry, ALPHA specifies the scalar alpha.``` [in] A ``` A is DOUBLE PRECISION array, dimension ( LDA, ka ), where ka is k when TRANSA = 'N' or 'n', and is m otherwise. Before entry with TRANSA = 'N' or 'n', the leading m by k part of the array A must contain the matrix A, otherwise the leading k by m part of the array A must contain the matrix A.``` [in] LDA ``` LDA is INTEGER On entry, LDA specifies the first dimension of A as declared in the calling (sub) program. When TRANSA = 'N' or 'n' then LDA must be at least max( 1, m ), otherwise LDA must be at least max( 1, k ).``` [in] B ``` B is DOUBLE PRECISION array, dimension ( LDB, kb ), where kb is n when TRANSB = 'N' or 'n', and is k otherwise. Before entry with TRANSB = 'N' or 'n', the leading k by n part of the array B must contain the matrix B, otherwise the leading n by k part of the array B must contain the matrix B.``` [in] LDB ``` LDB is INTEGER On entry, LDB specifies the first dimension of B as declared in the calling (sub) program. When TRANSB = 'N' or 'n' then LDB must be at least max( 1, k ), otherwise LDB must be at least max( 1, n ).``` [in] BETA ``` BETA is DOUBLE PRECISION. On entry, BETA specifies the scalar beta. When BETA is supplied as zero then C need not be set on input.``` [in,out] C ``` C is DOUBLE PRECISION array, dimension ( LDC, N ) Before entry, the leading m by n part of the array C must contain the matrix C, except when beta is zero, in which case C need not be set on entry. On exit, the array C is overwritten by the m by n matrix ( alpha*op( A )*op( B ) + beta*C ).``` [in] LDC ``` LDC is INTEGER On entry, LDC specifies the first dimension of C as declared in the calling (sub) program. LDC must be at least max( 1, m ).```
Further Details:
```  Level 3 Blas routine.

-- Written on 8-February-1989.
Jack Dongarra, Argonne National Laboratory.
Iain Duff, AERE Harwell.
Jeremy Du Croz, Numerical Algorithms Group Ltd.
Sven Hammarling, Numerical Algorithms Group Ltd.```

Definition at line 186 of file dgemm.f.

188*
189* -- Reference BLAS level3 routine --
190* -- Reference BLAS is a software package provided by Univ. of Tennessee, --
191* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
192*
193* .. Scalar Arguments ..
194 DOUBLE PRECISION ALPHA,BETA
195 INTEGER K,LDA,LDB,LDC,M,N
196 CHARACTER TRANSA,TRANSB
197* ..
198* .. Array Arguments ..
199 DOUBLE PRECISION A(LDA,*),B(LDB,*),C(LDC,*)
200* ..
201*
202* =====================================================================
203*
204* .. External Functions ..
205 LOGICAL LSAME
206 EXTERNAL lsame
207* ..
208* .. External Subroutines ..
209 EXTERNAL xerbla
210* ..
211* .. Intrinsic Functions ..
212 INTRINSIC max
213* ..
214* .. Local Scalars ..
215 DOUBLE PRECISION TEMP
216 INTEGER I,INFO,J,L,NROWA,NROWB
217 LOGICAL NOTA,NOTB
218* ..
219* .. Parameters ..
220 DOUBLE PRECISION ONE,ZERO
221 parameter(one=1.0d+0,zero=0.0d+0)
222* ..
223*
224* Set NOTA and NOTB as true if A and B respectively are not
225* transposed and set NROWA and NROWB as the number of rows of A
226* and B respectively.
227*
228 nota = lsame(transa,'N')
229 notb = lsame(transb,'N')
230 IF (nota) THEN
231 nrowa = m
232 ELSE
233 nrowa = k
234 END IF
235 IF (notb) THEN
236 nrowb = k
237 ELSE
238 nrowb = n
239 END IF
240*
241* Test the input parameters.
242*
243 info = 0
244 IF ((.NOT.nota) .AND. (.NOT.lsame(transa,'C')) .AND.
245 + (.NOT.lsame(transa,'T'))) THEN
246 info = 1
247 ELSE IF ((.NOT.notb) .AND. (.NOT.lsame(transb,'C')) .AND.
248 + (.NOT.lsame(transb,'T'))) THEN
249 info = 2
250 ELSE IF (m.LT.0) THEN
251 info = 3
252 ELSE IF (n.LT.0) THEN
253 info = 4
254 ELSE IF (k.LT.0) THEN
255 info = 5
256 ELSE IF (lda.LT.max(1,nrowa)) THEN
257 info = 8
258 ELSE IF (ldb.LT.max(1,nrowb)) THEN
259 info = 10
260 ELSE IF (ldc.LT.max(1,m)) THEN
261 info = 13
262 END IF
263 IF (info.NE.0) THEN
264 CALL xerbla('DGEMM ',info)
265 RETURN
266 END IF
267*
268* Quick return if possible.
269*
270 IF ((m.EQ.0) .OR. (n.EQ.0) .OR.
271 + (((alpha.EQ.zero).OR. (k.EQ.0)).AND. (beta.EQ.one))) RETURN
272*
273* And if alpha.eq.zero.
274*
275 IF (alpha.EQ.zero) THEN
276 IF (beta.EQ.zero) THEN
277 DO 20 j = 1,n
278 DO 10 i = 1,m
279 c(i,j) = zero
280 10 CONTINUE
281 20 CONTINUE
282 ELSE
283 DO 40 j = 1,n
284 DO 30 i = 1,m
285 c(i,j) = beta*c(i,j)
286 30 CONTINUE
287 40 CONTINUE
288 END IF
289 RETURN
290 END IF
291*
292* Start the operations.
293*
294 IF (notb) THEN
295 IF (nota) THEN
296*
297* Form C := alpha*A*B + beta*C.
298*
299 DO 90 j = 1,n
300 IF (beta.EQ.zero) THEN
301 DO 50 i = 1,m
302 c(i,j) = zero
303 50 CONTINUE
304 ELSE IF (beta.NE.one) THEN
305 DO 60 i = 1,m
306 c(i,j) = beta*c(i,j)
307 60 CONTINUE
308 END IF
309 DO 80 l = 1,k
310 temp = alpha*b(l,j)
311 DO 70 i = 1,m
312 c(i,j) = c(i,j) + temp*a(i,l)
313 70 CONTINUE
314 80 CONTINUE
315 90 CONTINUE
316 ELSE
317*
318* Form C := alpha*A**T*B + beta*C
319*
320 DO 120 j = 1,n
321 DO 110 i = 1,m
322 temp = zero
323 DO 100 l = 1,k
324 temp = temp + a(l,i)*b(l,j)
325 100 CONTINUE
326 IF (beta.EQ.zero) THEN
327 c(i,j) = alpha*temp
328 ELSE
329 c(i,j) = alpha*temp + beta*c(i,j)
330 END IF
331 110 CONTINUE
332 120 CONTINUE
333 END IF
334 ELSE
335 IF (nota) THEN
336*
337* Form C := alpha*A*B**T + beta*C
338*
339 DO 170 j = 1,n
340 IF (beta.EQ.zero) THEN
341 DO 130 i = 1,m
342 c(i,j) = zero
343 130 CONTINUE
344 ELSE IF (beta.NE.one) THEN
345 DO 140 i = 1,m
346 c(i,j) = beta*c(i,j)
347 140 CONTINUE
348 END IF
349 DO 160 l = 1,k
350 temp = alpha*b(j,l)
351 DO 150 i = 1,m
352 c(i,j) = c(i,j) + temp*a(i,l)
353 150 CONTINUE
354 160 CONTINUE
355 170 CONTINUE
356 ELSE
357*
358* Form C := alpha*A**T*B**T + beta*C
359*
360 DO 200 j = 1,n
361 DO 190 i = 1,m
362 temp = zero
363 DO 180 l = 1,k
364 temp = temp + a(l,i)*b(j,l)
365 180 CONTINUE
366 IF (beta.EQ.zero) THEN
367 c(i,j) = alpha*temp
368 ELSE
369 c(i,j) = alpha*temp + beta*c(i,j)
370 END IF
371 190 CONTINUE
372 200 CONTINUE
373 END IF
374 END IF
375*
376 RETURN
377*
378* End of DGEMM
379*
subroutine xerbla(srname, info)
Definition cblat2.f:3285
logical function lsame(ca, cb)
LSAME
Definition lsame.f:48
Here is the call graph for this function: