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

## ◆ zgemm()

 subroutine zgemm ( character transa, character transb, integer m, integer n, integer k, complex*16 alpha, complex*16, dimension(lda,*) a, integer lda, complex*16, dimension(ldb,*) b, integer ldb, complex*16 beta, complex*16, dimension(ldc,*) c, integer ldc )

ZGEMM

Purpose:
``` ZGEMM  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   or   op( X ) = X**H,

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**H.``` [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**H.``` [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 COMPLEX*16 On entry, ALPHA specifies the scalar alpha.``` [in] A ``` A is COMPLEX*16 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 COMPLEX*16 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 COMPLEX*16 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 COMPLEX*16 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 zgemm.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 COMPLEX*16 ALPHA,BETA
195 INTEGER K,LDA,LDB,LDC,M,N
196 CHARACTER TRANSA,TRANSB
197* ..
198* .. Array Arguments ..
199 COMPLEX*16 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 dconjg,max
213* ..
214* .. Local Scalars ..
215 COMPLEX*16 TEMP
216 INTEGER I,INFO,J,L,NROWA,NROWB
217 LOGICAL CONJA,CONJB,NOTA,NOTB
218* ..
219* .. Parameters ..
220 COMPLEX*16 ONE
221 parameter(one= (1.0d+0,0.0d+0))
222 COMPLEX*16 ZERO
223 parameter(zero= (0.0d+0,0.0d+0))
224* ..
225*
226* Set NOTA and NOTB as true if A and B respectively are not
227* conjugated or transposed, set CONJA and CONJB as true if A and
228* B respectively are to be transposed but not conjugated and set
229* NROWA and NROWB as the number of rows of A and B respectively.
230*
231 nota = lsame(transa,'N')
232 notb = lsame(transb,'N')
233 conja = lsame(transa,'C')
234 conjb = lsame(transb,'C')
235 IF (nota) THEN
236 nrowa = m
237 ELSE
238 nrowa = k
239 END IF
240 IF (notb) THEN
241 nrowb = k
242 ELSE
243 nrowb = n
244 END IF
245*
246* Test the input parameters.
247*
248 info = 0
249 IF ((.NOT.nota) .AND. (.NOT.conja) .AND.
250 + (.NOT.lsame(transa,'T'))) THEN
251 info = 1
252 ELSE IF ((.NOT.notb) .AND. (.NOT.conjb) .AND.
253 + (.NOT.lsame(transb,'T'))) THEN
254 info = 2
255 ELSE IF (m.LT.0) THEN
256 info = 3
257 ELSE IF (n.LT.0) THEN
258 info = 4
259 ELSE IF (k.LT.0) THEN
260 info = 5
261 ELSE IF (lda.LT.max(1,nrowa)) THEN
262 info = 8
263 ELSE IF (ldb.LT.max(1,nrowb)) THEN
264 info = 10
265 ELSE IF (ldc.LT.max(1,m)) THEN
266 info = 13
267 END IF
268 IF (info.NE.0) THEN
269 CALL xerbla('ZGEMM ',info)
270 RETURN
271 END IF
272*
273* Quick return if possible.
274*
275 IF ((m.EQ.0) .OR. (n.EQ.0) .OR.
276 + (((alpha.EQ.zero).OR. (k.EQ.0)).AND. (beta.EQ.one))) RETURN
277*
278* And when alpha.eq.zero.
279*
280 IF (alpha.EQ.zero) THEN
281 IF (beta.EQ.zero) THEN
282 DO 20 j = 1,n
283 DO 10 i = 1,m
284 c(i,j) = zero
285 10 CONTINUE
286 20 CONTINUE
287 ELSE
288 DO 40 j = 1,n
289 DO 30 i = 1,m
290 c(i,j) = beta*c(i,j)
291 30 CONTINUE
292 40 CONTINUE
293 END IF
294 RETURN
295 END IF
296*
297* Start the operations.
298*
299 IF (notb) THEN
300 IF (nota) THEN
301*
302* Form C := alpha*A*B + beta*C.
303*
304 DO 90 j = 1,n
305 IF (beta.EQ.zero) THEN
306 DO 50 i = 1,m
307 c(i,j) = zero
308 50 CONTINUE
309 ELSE IF (beta.NE.one) THEN
310 DO 60 i = 1,m
311 c(i,j) = beta*c(i,j)
312 60 CONTINUE
313 END IF
314 DO 80 l = 1,k
315 temp = alpha*b(l,j)
316 DO 70 i = 1,m
317 c(i,j) = c(i,j) + temp*a(i,l)
318 70 CONTINUE
319 80 CONTINUE
320 90 CONTINUE
321 ELSE IF (conja) THEN
322*
323* Form C := alpha*A**H*B + beta*C.
324*
325 DO 120 j = 1,n
326 DO 110 i = 1,m
327 temp = zero
328 DO 100 l = 1,k
329 temp = temp + dconjg(a(l,i))*b(l,j)
330 100 CONTINUE
331 IF (beta.EQ.zero) THEN
332 c(i,j) = alpha*temp
333 ELSE
334 c(i,j) = alpha*temp + beta*c(i,j)
335 END IF
336 110 CONTINUE
337 120 CONTINUE
338 ELSE
339*
340* Form C := alpha*A**T*B + beta*C
341*
342 DO 150 j = 1,n
343 DO 140 i = 1,m
344 temp = zero
345 DO 130 l = 1,k
346 temp = temp + a(l,i)*b(l,j)
347 130 CONTINUE
348 IF (beta.EQ.zero) THEN
349 c(i,j) = alpha*temp
350 ELSE
351 c(i,j) = alpha*temp + beta*c(i,j)
352 END IF
353 140 CONTINUE
354 150 CONTINUE
355 END IF
356 ELSE IF (nota) THEN
357 IF (conjb) THEN
358*
359* Form C := alpha*A*B**H + beta*C.
360*
361 DO 200 j = 1,n
362 IF (beta.EQ.zero) THEN
363 DO 160 i = 1,m
364 c(i,j) = zero
365 160 CONTINUE
366 ELSE IF (beta.NE.one) THEN
367 DO 170 i = 1,m
368 c(i,j) = beta*c(i,j)
369 170 CONTINUE
370 END IF
371 DO 190 l = 1,k
372 temp = alpha*dconjg(b(j,l))
373 DO 180 i = 1,m
374 c(i,j) = c(i,j) + temp*a(i,l)
375 180 CONTINUE
376 190 CONTINUE
377 200 CONTINUE
378 ELSE
379*
380* Form C := alpha*A*B**T + beta*C
381*
382 DO 250 j = 1,n
383 IF (beta.EQ.zero) THEN
384 DO 210 i = 1,m
385 c(i,j) = zero
386 210 CONTINUE
387 ELSE IF (beta.NE.one) THEN
388 DO 220 i = 1,m
389 c(i,j) = beta*c(i,j)
390 220 CONTINUE
391 END IF
392 DO 240 l = 1,k
393 temp = alpha*b(j,l)
394 DO 230 i = 1,m
395 c(i,j) = c(i,j) + temp*a(i,l)
396 230 CONTINUE
397 240 CONTINUE
398 250 CONTINUE
399 END IF
400 ELSE IF (conja) THEN
401 IF (conjb) THEN
402*
403* Form C := alpha*A**H*B**H + beta*C.
404*
405 DO 280 j = 1,n
406 DO 270 i = 1,m
407 temp = zero
408 DO 260 l = 1,k
409 temp = temp + dconjg(a(l,i))*dconjg(b(j,l))
410 260 CONTINUE
411 IF (beta.EQ.zero) THEN
412 c(i,j) = alpha*temp
413 ELSE
414 c(i,j) = alpha*temp + beta*c(i,j)
415 END IF
416 270 CONTINUE
417 280 CONTINUE
418 ELSE
419*
420* Form C := alpha*A**H*B**T + beta*C
421*
422 DO 310 j = 1,n
423 DO 300 i = 1,m
424 temp = zero
425 DO 290 l = 1,k
426 temp = temp + dconjg(a(l,i))*b(j,l)
427 290 CONTINUE
428 IF (beta.EQ.zero) THEN
429 c(i,j) = alpha*temp
430 ELSE
431 c(i,j) = alpha*temp + beta*c(i,j)
432 END IF
433 300 CONTINUE
434 310 CONTINUE
435 END IF
436 ELSE
437 IF (conjb) THEN
438*
439* Form C := alpha*A**T*B**H + beta*C
440*
441 DO 340 j = 1,n
442 DO 330 i = 1,m
443 temp = zero
444 DO 320 l = 1,k
445 temp = temp + a(l,i)*dconjg(b(j,l))
446 320 CONTINUE
447 IF (beta.EQ.zero) THEN
448 c(i,j) = alpha*temp
449 ELSE
450 c(i,j) = alpha*temp + beta*c(i,j)
451 END IF
452 330 CONTINUE
453 340 CONTINUE
454 ELSE
455*
456* Form C := alpha*A**T*B**T + beta*C
457*
458 DO 370 j = 1,n
459 DO 360 i = 1,m
460 temp = zero
461 DO 350 l = 1,k
462 temp = temp + a(l,i)*b(j,l)
463 350 CONTINUE
464 IF (beta.EQ.zero) THEN
465 c(i,j) = alpha*temp
466 ELSE
467 c(i,j) = alpha*temp + beta*c(i,j)
468 END IF
469 360 CONTINUE
470 370 CONTINUE
471 END IF
472 END IF
473*
474 RETURN
475*
476* End of ZGEMM
477*
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: