LAPACK 3.11.0
LAPACK: Linear Algebra PACKage
Loading...
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 ).
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
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.

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