Debian Codegraph @

gcc/testsuite/gfortran.dg/blas_gemm_routines.f

raw
1 ! { dg-do compile }
2 ! { dg-options "-std=legacy" }
3 *> \brief \b CGEMM
4 *
5 * =========== DOCUMENTATION ===========
6 *
7 * Online html documentation available at
8 * http://www.netlib.org/lapack/explore-html/
9 *
10 * Definition:
11 * ===========
12 *
13 * SUBROUTINE CGEMM(TRANSA,TRANSB,M,N,K,ALPHA,A,LDA,B,LDB,BETA,C,LDC)
14 *
15 * .. Scalar Arguments ..
16 * COMPLEX ALPHA,BETA
17 * INTEGER K,LDA,LDB,LDC,M,N
18 * CHARACTER TRANSA,TRANSB
19 * ..
20 * .. Array Arguments ..
21 * COMPLEX A(LDA,*),B(LDB,*),C(LDC,*)
22 * ..
23 *
24 *
25 *> \par Purpose:
26 * =============
27 *>
28 *> \verbatim
29 *>
30 *> CGEMM performs one of the matrix-matrix operations
31 *>
32 *> C := alpha*op( A )*op( B ) + beta*C,
33 *>
34 *> where op( X ) is one of
35 *>
36 *> op( X ) = X or op( X ) = X**T or op( X ) = X**H,
37 *>
38 *> alpha and beta are scalars, and A, B and C are matrices, with op( A )
39 *> an m by k matrix, op( B ) a k by n matrix and C an m by n matrix.
40 *> \endverbatim
41 *
42 * Arguments:
43 * ==========
44 *
45 *> \param[in] TRANSA
46 *> \verbatim
47 *> TRANSA is 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**T.
54 *>
55 *> TRANSA = 'C' or 'c', op( A ) = A**H.
56 *> \endverbatim
57 *>
58 *> \param[in] TRANSB
59 *> \verbatim
60 *> TRANSB is CHARACTER*1
61 *> On entry, TRANSB specifies the form of op( B ) to be used in
62 *> the matrix multiplication as follows:
63 *>
64 *> TRANSB = 'N' or 'n', op( B ) = B.
65 *>
66 *> TRANSB = 'T' or 't', op( B ) = B**T.
67 *>
68 *> TRANSB = 'C' or 'c', op( B ) = B**H.
69 *> \endverbatim
70 *>
71 *> \param[in] M
72 *> \verbatim
73 *> M is INTEGER
74 *> On entry, M specifies the number of rows of the matrix
75 *> op( A ) and of the matrix C. M must be at least zero.
76 *> \endverbatim
77 *>
78 *> \param[in] N
79 *> \verbatim
80 *> N is INTEGER
81 *> On entry, N specifies the number of columns of the matrix
82 *> op( B ) and the number of columns of the matrix C. N must be
83 *> at least zero.
84 *> \endverbatim
85 *>
86 *> \param[in] K
87 *> \verbatim
88 *> K is INTEGER
89 *> On entry, K specifies the number of columns of the matrix
90 *> op( A ) and the number of rows of the matrix op( B ). K must
91 *> be at least zero.
92 *> \endverbatim
93 *>
94 *> \param[in] ALPHA
95 *> \verbatim
96 *> ALPHA is COMPLEX
97 *> On entry, ALPHA specifies the scalar alpha.
98 *> \endverbatim
99 *>
100 *> \param[in] A
101 *> \verbatim
102 *> A is COMPLEX array, dimension ( LDA, ka ), where ka is
103 *> k when TRANSA = 'N' or 'n', and is m otherwise.
104 *> Before entry with TRANSA = 'N' or 'n', the leading m by k
105 *> part of the array A must contain the matrix A, otherwise
106 *> the leading k by m part of the array A must contain the
107 *> matrix A.
108 *> \endverbatim
109 *>
110 *> \param[in] LDA
111 *> \verbatim
112 *> LDA is INTEGER
113 *> On entry, LDA specifies the first dimension of A as declared
114 *> in the calling (sub) program. When TRANSA = 'N' or 'n' then
115 *> LDA must be at least max( 1, m ), otherwise LDA must be at
116 *> least max( 1, k ).
117 *> \endverbatim
118 *>
119 *> \param[in] B
120 *> \verbatim
121 *> B is COMPLEX array, dimension ( LDB, kb ), where kb is
122 *> n when TRANSB = 'N' or 'n', and is k otherwise.
123 *> Before entry with TRANSB = 'N' or 'n', the leading k by n
124 *> part of the array B must contain the matrix B, otherwise
125 *> the leading n by k part of the array B must contain the
126 *> matrix B.
127 *> \endverbatim
128 *>
129 *> \param[in] LDB
130 *> \verbatim
131 *> LDB is INTEGER
132 *> On entry, LDB specifies the first dimension of B as declared
133 *> in the calling (sub) program. When TRANSB = 'N' or 'n' then
134 *> LDB must be at least max( 1, k ), otherwise LDB must be at
135 *> least max( 1, n ).
136 *> \endverbatim
137 *>
138 *> \param[in] BETA
139 *> \verbatim
140 *> BETA is COMPLEX
141 *> On entry, BETA specifies the scalar beta. When BETA is
142 *> supplied as zero then C need not be set on input.
143 *> \endverbatim
144 *>
145 *> \param[in,out] C
146 *> \verbatim
147 *> C is COMPLEX array, dimension ( LDC, N )
148 *> Before entry, the leading m by n part of the array C must
149 *> contain the matrix C, except when beta is zero, in which
150 *> case C need not be set on entry.
151 *> On exit, the array C is overwritten by the m by n matrix
152 *> ( alpha*op( A )*op( B ) + beta*C ).
153 *> \endverbatim
154 *>
155 *> \param[in] LDC
156 *> \verbatim
157 *> LDC is INTEGER
158 *> On entry, LDC specifies the first dimension of C as declared
159 *> in the calling (sub) program. LDC must be at least
160 *> max( 1, m ).
161 *> \endverbatim
162 *
163 * Authors:
164 * ========
165 *
166 *> \author Univ. of Tennessee
167 *> \author Univ. of California Berkeley
168 *> \author Univ. of Colorado Denver
169 *> \author NAG Ltd.
170 *
171 *> \date December 2016
172 *
173 *> \ingroup complex_blas_level3
174 *
175 *> \par Further Details:
176 * =====================
177 *>
178 *> \verbatim
179 *>
180 *> Level 3 Blas routine.
181 *>
182 *> -- Written on 8-February-1989.
183 *> Jack Dongarra, Argonne National Laboratory.
184 *> Iain Duff, AERE Harwell.
185 *> Jeremy Du Croz, Numerical Algorithms Group Ltd.
186 *> Sven Hammarling, Numerical Algorithms Group Ltd.
187 *> \endverbatim
188 *>
189 * =====================================================================
190 SUBROUTINE CGEMM(TRANSA,TRANSB,M,N,K,ALPHA,A,LDA,B,LDB,BETA,C,LDC)
191 *
192 * -- Reference BLAS level3 routine (version 3.7.0) --
193 * -- Reference BLAS is a software package provided by Univ. of Tennessee, --
194 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
195 * December 2016
196 *
197 * .. Scalar Arguments ..
198 COMPLEX ALPHA,BETA
199 INTEGER K,LDA,LDB,LDC,M,N
200 CHARACTER TRANSA,TRANSB
201 * ..
202 * .. Array Arguments ..
203 COMPLEX A(LDA,*),B(LDB,*),C(LDC,*)
204 * ..
205 *
206 * =====================================================================
207 *
208 * .. External Functions ..
209 LOGICAL LSAME
210 EXTERNAL LSAME
211 * ..
212 * .. External Subroutines ..
213 EXTERNAL XERBLA
214 * ..
215 * .. Intrinsic Functions ..
216 INTRINSIC CONJG,MAX
217 * ..
218 * .. Local Scalars ..
219 COMPLEX TEMP
220 INTEGER I,INFO,J,L,NCOLA,NROWA,NROWB
221 LOGICAL CONJA,CONJB,NOTA,NOTB
222 * ..
223 * .. Parameters ..
224 COMPLEX ONE
225 PARAMETER (ONE= (1.0E+0,0.0E+0))
226 COMPLEX ZERO
227 PARAMETER (ZERO= (0.0E+0,0.0E+0))
228 * ..
229 *
230 * Set NOTA and NOTB as true if A and B respectively are not
231 * conjugated or transposed, set CONJA and CONJB as true if A and
232 * B respectively are to be transposed but not conjugated and set
233 * NROWA, NCOLA and NROWB as the number of rows and columns of A
234 * and the number of rows of B respectively.
235 *
236 NOTA = LSAME(TRANSA,'N')
237 NOTB = LSAME(TRANSB,'N')
238 CONJA = LSAME(TRANSA,'C')
239 CONJB = LSAME(TRANSB,'C')
240 IF (NOTA) THEN
241 NROWA = M
242 NCOLA = K
243 ELSE
244 NROWA = K
245 NCOLA = M
246 END IF
247 IF (NOTB) THEN
248 NROWB = K
249 ELSE
250 NROWB = N
251 END IF
252 *
253 * Test the input parameters.
254 *
255 INFO = 0
256 IF ((.NOT.NOTA) .AND. (.NOT.CONJA) .AND.
257 + (.NOT.LSAME(TRANSA,'T'))) THEN
258 INFO = 1
259 ELSE IF ((.NOT.NOTB) .AND. (.NOT.CONJB) .AND.
260 + (.NOT.LSAME(TRANSB,'T'))) THEN
261 INFO = 2
262 ELSE IF (M.LT.0) THEN
263 INFO = 3
264 ELSE IF (N.LT.0) THEN
265 INFO = 4
266 ELSE IF (K.LT.0) THEN
267 INFO = 5
268 ELSE IF (LDA.LT.MAX(1,NROWA)) THEN
269 INFO = 8
270 ELSE IF (LDB.LT.MAX(1,NROWB)) THEN
271 INFO = 10
272 ELSE IF (LDC.LT.MAX(1,M)) THEN
273 INFO = 13
274 END IF
275 IF (INFO.NE.0) THEN
276 CALL XERBLA('CGEMM ',INFO)
277 RETURN
278 END IF
279 *
280 * Quick return if possible.
281 *
282 IF ((M.EQ.0) .OR. (N.EQ.0) .OR.
283 + (((ALPHA.EQ.ZERO).OR. (K.EQ.0)).AND. (BETA.EQ.ONE))) RETURN
284 *
285 * And when alpha.eq.zero.
286 *
287 IF (ALPHA.EQ.ZERO) THEN
288 IF (BETA.EQ.ZERO) THEN
289 DO 20 J = 1,N
290 DO 10 I = 1,M
291 C(I,J) = ZERO
292 10 CONTINUE
293 20 CONTINUE
294 ELSE
295 DO 40 J = 1,N
296 DO 30 I = 1,M
297 C(I,J) = BETA*C(I,J)
298 30 CONTINUE
299 40 CONTINUE
300 END IF
301 RETURN
302 END IF
303 *
304 * Start the operations.
305 *
306 IF (NOTB) THEN
307 IF (NOTA) THEN
308 *
309 * Form C := alpha*A*B + beta*C.
310 *
311 DO 90 J = 1,N
312 IF (BETA.EQ.ZERO) THEN
313 DO 50 I = 1,M
314 C(I,J) = ZERO
315 50 CONTINUE
316 ELSE IF (BETA.NE.ONE) THEN
317 DO 60 I = 1,M
318 C(I,J) = BETA*C(I,J)
319 60 CONTINUE
320 END IF
321 DO 80 L = 1,K
322 TEMP = ALPHA*B(L,J)
323 DO 70 I = 1,M
324 C(I,J) = C(I,J) + TEMP*A(I,L)
325 70 CONTINUE
326 80 CONTINUE
327 90 CONTINUE
328 ELSE IF (CONJA) THEN
329 *
330 * Form C := alpha*A**H*B + beta*C.
331 *
332 DO 120 J = 1,N
333 DO 110 I = 1,M
334 TEMP = ZERO
335 DO 100 L = 1,K
336 TEMP = TEMP + CONJG(A(L,I))*B(L,J)
337 100 CONTINUE
338 IF (BETA.EQ.ZERO) THEN
339 C(I,J) = ALPHA*TEMP
340 ELSE
341 C(I,J) = ALPHA*TEMP + BETA*C(I,J)
342 END IF
343 110 CONTINUE
344 120 CONTINUE
345 ELSE
346 *
347 * Form C := alpha*A**T*B + beta*C
348 *
349 DO 150 J = 1,N
350 DO 140 I = 1,M
351 TEMP = ZERO
352 DO 130 L = 1,K
353 TEMP = TEMP + A(L,I)*B(L,J)
354 130 CONTINUE
355 IF (BETA.EQ.ZERO) THEN
356 C(I,J) = ALPHA*TEMP
357 ELSE
358 C(I,J) = ALPHA*TEMP + BETA*C(I,J)
359 END IF
360 140 CONTINUE
361 150 CONTINUE
362 END IF
363 ELSE IF (NOTA) THEN
364 IF (CONJB) THEN
365 *
366 * Form C := alpha*A*B**H + beta*C.
367 *
368 DO 200 J = 1,N
369 IF (BETA.EQ.ZERO) THEN
370 DO 160 I = 1,M
371 C(I,J) = ZERO
372 160 CONTINUE
373 ELSE IF (BETA.NE.ONE) THEN
374 DO 170 I = 1,M
375 C(I,J) = BETA*C(I,J)
376 170 CONTINUE
377 END IF
378 DO 190 L = 1,K
379 TEMP = ALPHA*CONJG(B(J,L))
380 DO 180 I = 1,M
381 C(I,J) = C(I,J) + TEMP*A(I,L)
382 180 CONTINUE
383 190 CONTINUE
384 200 CONTINUE
385 ELSE
386 *
387 * Form C := alpha*A*B**T + beta*C
388 *
389 DO 250 J = 1,N
390 IF (BETA.EQ.ZERO) THEN
391 DO 210 I = 1,M
392 C(I,J) = ZERO
393 210 CONTINUE
394 ELSE IF (BETA.NE.ONE) THEN
395 DO 220 I = 1,M
396 C(I,J) = BETA*C(I,J)
397 220 CONTINUE
398 END IF
399 DO 240 L = 1,K
400 TEMP = ALPHA*B(J,L)
401 DO 230 I = 1,M
402 C(I,J) = C(I,J) + TEMP*A(I,L)
403 230 CONTINUE
404 240 CONTINUE
405 250 CONTINUE
406 END IF
407 ELSE IF (CONJA) THEN
408 IF (CONJB) THEN
409 *
410 * Form C := alpha*A**H*B**H + beta*C.
411 *
412 DO 280 J = 1,N
413 DO 270 I = 1,M
414 TEMP = ZERO
415 DO 260 L = 1,K
416 TEMP = TEMP + CONJG(A(L,I))*CONJG(B(J,L))
417 260 CONTINUE
418 IF (BETA.EQ.ZERO) THEN
419 C(I,J) = ALPHA*TEMP
420 ELSE
421 C(I,J) = ALPHA*TEMP + BETA*C(I,J)
422 END IF
423 270 CONTINUE
424 280 CONTINUE
425 ELSE
426 *
427 * Form C := alpha*A**H*B**T + beta*C
428 *
429 DO 310 J = 1,N
430 DO 300 I = 1,M
431 TEMP = ZERO
432 DO 290 L = 1,K
433 TEMP = TEMP + CONJG(A(L,I))*B(J,L)
434 290 CONTINUE
435 IF (BETA.EQ.ZERO) THEN
436 C(I,J) = ALPHA*TEMP
437 ELSE
438 C(I,J) = ALPHA*TEMP + BETA*C(I,J)
439 END IF
440 300 CONTINUE
441 310 CONTINUE
442 END IF
443 ELSE
444 IF (CONJB) THEN
445 *
446 * Form C := alpha*A**T*B**H + beta*C
447 *
448 DO 340 J = 1,N
449 DO 330 I = 1,M
450 TEMP = ZERO
451 DO 320 L = 1,K
452 TEMP = TEMP + A(L,I)*CONJG(B(J,L))
453 320 CONTINUE
454 IF (BETA.EQ.ZERO) THEN
455 C(I,J) = ALPHA*TEMP
456 ELSE
457 C(I,J) = ALPHA*TEMP + BETA*C(I,J)
458 END IF
459 330 CONTINUE
460 340 CONTINUE
461 ELSE
462 *
463 * Form C := alpha*A**T*B**T + beta*C
464 *
465 DO 370 J = 1,N
466 DO 360 I = 1,M
467 TEMP = ZERO
468 DO 350 L = 1,K
469 TEMP = TEMP + A(L,I)*B(J,L)
470 350 CONTINUE
471 IF (BETA.EQ.ZERO) THEN
472 C(I,J) = ALPHA*TEMP
473 ELSE
474 C(I,J) = ALPHA*TEMP + BETA*C(I,J)
475 END IF
476 360 CONTINUE
477 370 CONTINUE
478 END IF
479 END IF
480 *
481 RETURN
482 *
483 * End of CGEMM .
484 *
485 END
486
487 *> \brief \b LSAME
488 *
489 * =========== DOCUMENTATION ===========
490 *
491 * Online html documentation available at
492 * http://www.netlib.org/lapack/explore-html/
493 *
494 * Definition:
495 * ===========
496 *
497 * LOGICAL FUNCTION LSAME(CA,CB)
498 *
499 * .. Scalar Arguments ..
500 * CHARACTER CA,CB
501 * ..
502 *
503 *
504 *> \par Purpose:
505 * =============
506 *>
507 *> \verbatim
508 *>
509 *> LSAME returns .TRUE. if CA is the same letter as CB regardless of
510 *> case.
511 *> \endverbatim
512 *
513 * Arguments:
514 * ==========
515 *
516 *> \param[in] CA
517 *> \verbatim
518 *> CA is CHARACTER*1
519 *> \endverbatim
520 *>
521 *> \param[in] CB
522 *> \verbatim
523 *> CB is CHARACTER*1
524 *> CA and CB specify the single characters to be compared.
525 *> \endverbatim
526 *
527 * Authors:
528 * ========
529 *
530 *> \author Univ. of Tennessee
531 *> \author Univ. of California Berkeley
532 *> \author Univ. of Colorado Denver
533 *> \author NAG Ltd.
534 *
535 *> \date December 2016
536 *
537 *> \ingroup aux_blas
538 *
539 * =====================================================================
540 LOGICAL FUNCTION LSAME(CA,CB)
541 *
542 * -- Reference BLAS level1 routine (version 3.1) --
543 * -- Reference BLAS is a software package provided by Univ. of Tennessee, --
544 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
545 * December 2016
546 *
547 * .. Scalar Arguments ..
548 CHARACTER CA,CB
549 * ..
550 *
551 * =====================================================================
552 *
553 * .. Intrinsic Functions ..
554 INTRINSIC ICHAR
555 * ..
556 * .. Local Scalars ..
557 INTEGER INTA,INTB,ZCODE
558 * ..
559 *
560 * Test if the characters are equal
561 *
562 LSAME = CA .EQ. CB
563 IF (LSAME) RETURN
564 *
565 * Now test for equivalence if both characters are alphabetic.
566 *
567 ZCODE = ICHAR('Z')
568 *
569 * Use 'Z' rather than 'A' so that ASCII can be detected on Prime
570 * machines, on which ICHAR returns a value with bit 8 set.
571 * ICHAR('A') on Prime machines returns 193 which is the same as
572 * ICHAR('A') on an EBCDIC machine.
573 *
574 INTA = ICHAR(CA)
575 INTB = ICHAR(CB)
576 *
577 IF (ZCODE.EQ.90 .OR. ZCODE.EQ.122) THEN
578 *
579 * ASCII is assumed - ZCODE is the ASCII code of either lower or
580 * upper case 'Z'.
581 *
582 IF (INTA.GE.97 .AND. INTA.LE.122) INTA = INTA - 32
583 IF (INTB.GE.97 .AND. INTB.LE.122) INTB = INTB - 32
584 *
585 ELSE IF (ZCODE.EQ.233 .OR. ZCODE.EQ.169) THEN
586 *
587 * EBCDIC is assumed - ZCODE is the EBCDIC code of either lower or
588 * upper case 'Z'.
589 *
590 IF (INTA.GE.129 .AND. INTA.LE.137 .OR.
591 + INTA.GE.145 .AND. INTA.LE.153 .OR.
592 + INTA.GE.162 .AND. INTA.LE.169) INTA = INTA + 64
593 IF (INTB.GE.129 .AND. INTB.LE.137 .OR.
594 + INTB.GE.145 .AND. INTB.LE.153 .OR.
595 + INTB.GE.162 .AND. INTB.LE.169) INTB = INTB + 64
596 *
597 ELSE IF (ZCODE.EQ.218 .OR. ZCODE.EQ.250) THEN
598 *
599 * ASCII is assumed, on Prime machines - ZCODE is the ASCII code
600 * plus 128 of either lower or upper case 'Z'.
601 *
602 IF (INTA.GE.225 .AND. INTA.LE.250) INTA = INTA - 32
603 IF (INTB.GE.225 .AND. INTB.LE.250) INTB = INTB - 32
604 END IF
605 LSAME = INTA .EQ. INTB
606 *
607 * RETURN
608 *
609 * End of LSAME
610 *
611 END
612
613 *> \brief \b XERBLA
614 *
615 * =========== DOCUMENTATION ===========
616 *
617 * Online html documentation available at
618 * http://www.netlib.org/lapack/explore-html/
619 *
620 * Definition:
621 * ===========
622 *
623 * SUBROUTINE XERBLA( SRNAME, INFO )
624 *
625 * .. Scalar Arguments ..
626 * CHARACTER*(*) SRNAME
627 * INTEGER INFO
628 * ..
629 *
630 *
631 *> \par Purpose:
632 * =============
633 *>
634 *> \verbatim
635 *>
636 *> XERBLA is an error handler for the LAPACK routines.
637 *> It is called by an LAPACK routine if an input parameter has an
638 *> invalid value. A message is printed and execution stops.
639 *>
640 *> Installers may consider modifying the STOP statement in order to
641 *> call system-specific exception-handling facilities.
642 *> \endverbatim
643 *
644 * Arguments:
645 * ==========
646 *
647 *> \param[in] SRNAME
648 *> \verbatim
649 *> SRNAME is CHARACTER*(*)
650 *> The name of the routine which called XERBLA.
651 *> \endverbatim
652 *>
653 *> \param[in] INFO
654 *> \verbatim
655 *> INFO is INTEGER
656 *> The position of the invalid parameter in the parameter list
657 *> of the calling routine.
658 *> \endverbatim
659 *
660 * Authors:
661 * ========
662 *
663 *> \author Univ. of Tennessee
664 *> \author Univ. of California Berkeley
665 *> \author Univ. of Colorado Denver
666 *> \author NAG Ltd.
667 *
668 *> \date December 2016
669 *
670 *> \ingroup aux_blas
671 *
672 * =====================================================================
673 SUBROUTINE XERBLA( SRNAME, INFO )
674 *
675 * -- Reference BLAS level1 routine (version 3.7.0) --
676 * -- Reference BLAS is a software package provided by Univ. of Tennessee, --
677 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
678 * December 2016
679 *
680 * .. Scalar Arguments ..
681 CHARACTER*(*) SRNAME
682 INTEGER INFO
683 * ..
684 *
685 * =====================================================================
686 *
687 * .. Intrinsic Functions ..
688 INTRINSIC LEN_TRIM
689 * ..
690 * .. Executable Statements ..
691 *
692 WRITE( *, FMT = 9999 )SRNAME( 1:LEN_TRIM( SRNAME ) ), INFO
693 *
694 STOP
695 *
696 9999 FORMAT( ' ** On entry to ', A, ' parameter number ', I2, ' had ',
697 $ 'an illegal value' )
698 *
699 * End of XERBLA
700 *
701 END
702
703 *> \brief \b SGEMM
704 *
705 * =========== DOCUMENTATION ===========
706 *
707 * Online html documentation available at
708 * http://www.netlib.org/lapack/explore-html/
709 *
710 * Definition:
711 * ===========
712 *
713 * SUBROUTINE SGEMM(TRANSA,TRANSB,M,N,K,ALPHA,A,LDA,B,LDB,BETA,C,LDC)
714 *
715 * .. Scalar Arguments ..
716 * REAL ALPHA,BETA
717 * INTEGER K,LDA,LDB,LDC,M,N
718 * CHARACTER TRANSA,TRANSB
719 * ..
720 * .. Array Arguments ..
721 * REAL A(LDA,*),B(LDB,*),C(LDC,*)
722 * ..
723 *
724 *
725 *> \par Purpose:
726 * =============
727 *>
728 *> \verbatim
729 *>
730 *> SGEMM performs one of the matrix-matrix operations
731 *>
732 *> C := alpha*op( A )*op( B ) + beta*C,
733 *>
734 *> where op( X ) is one of
735 *>
736 *> op( X ) = X or op( X ) = X**T,
737 *>
738 *> alpha and beta are scalars, and A, B and C are matrices, with op( A )
739 *> an m by k matrix, op( B ) a k by n matrix and C an m by n matrix.
740 *> \endverbatim
741 *
742 * Arguments:
743 * ==========
744 *
745 *> \param[in] TRANSA
746 *> \verbatim
747 *> TRANSA is CHARACTER*1
748 *> On entry, TRANSA specifies the form of op( A ) to be used in
749 *> the matrix multiplication as follows:
750 *>
751 *> TRANSA = 'N' or 'n', op( A ) = A.
752 *>
753 *> TRANSA = 'T' or 't', op( A ) = A**T.
754 *>
755 *> TRANSA = 'C' or 'c', op( A ) = A**T.
756 *> \endverbatim
757 *>
758 *> \param[in] TRANSB
759 *> \verbatim
760 *> TRANSB is CHARACTER*1
761 *> On entry, TRANSB specifies the form of op( B ) to be used in
762 *> the matrix multiplication as follows:
763 *>
764 *> TRANSB = 'N' or 'n', op( B ) = B.
765 *>
766 *> TRANSB = 'T' or 't', op( B ) = B**T.
767 *>
768 *> TRANSB = 'C' or 'c', op( B ) = B**T.
769 *> \endverbatim
770 *>
771 *> \param[in] M
772 *> \verbatim
773 *> M is INTEGER
774 *> On entry, M specifies the number of rows of the matrix
775 *> op( A ) and of the matrix C. M must be at least zero.
776 *> \endverbatim
777 *>
778 *> \param[in] N
779 *> \verbatim
780 *> N is INTEGER
781 *> On entry, N specifies the number of columns of the matrix
782 *> op( B ) and the number of columns of the matrix C. N must be
783 *> at least zero.
784 *> \endverbatim
785 *>
786 *> \param[in] K
787 *> \verbatim
788 *> K is INTEGER
789 *> On entry, K specifies the number of columns of the matrix
790 *> op( A ) and the number of rows of the matrix op( B ). K must
791 *> be at least zero.
792 *> \endverbatim
793 *>
794 *> \param[in] ALPHA
795 *> \verbatim
796 *> ALPHA is REAL
797 *> On entry, ALPHA specifies the scalar alpha.
798 *> \endverbatim
799 *>
800 *> \param[in] A
801 *> \verbatim
802 *> A is REAL array, dimension ( LDA, ka ), where ka is
803 *> k when TRANSA = 'N' or 'n', and is m otherwise.
804 *> Before entry with TRANSA = 'N' or 'n', the leading m by k
805 *> part of the array A must contain the matrix A, otherwise
806 *> the leading k by m part of the array A must contain the
807 *> matrix A.
808 *> \endverbatim
809 *>
810 *> \param[in] LDA
811 *> \verbatim
812 *> LDA is INTEGER
813 *> On entry, LDA specifies the first dimension of A as declared
814 *> in the calling (sub) program. When TRANSA = 'N' or 'n' then
815 *> LDA must be at least max( 1, m ), otherwise LDA must be at
816 *> least max( 1, k ).
817 *> \endverbatim
818 *>
819 *> \param[in] B
820 *> \verbatim
821 *> B is REAL array, dimension ( LDB, kb ), where kb is
822 *> n when TRANSB = 'N' or 'n', and is k otherwise.
823 *> Before entry with TRANSB = 'N' or 'n', the leading k by n
824 *> part of the array B must contain the matrix B, otherwise
825 *> the leading n by k part of the array B must contain the
826 *> matrix B.
827 *> \endverbatim
828 *>
829 *> \param[in] LDB
830 *> \verbatim
831 *> LDB is INTEGER
832 *> On entry, LDB specifies the first dimension of B as declared
833 *> in the calling (sub) program. When TRANSB = 'N' or 'n' then
834 *> LDB must be at least max( 1, k ), otherwise LDB must be at
835 *> least max( 1, n ).
836 *> \endverbatim
837 *>
838 *> \param[in] BETA
839 *> \verbatim
840 *> BETA is REAL
841 *> On entry, BETA specifies the scalar beta. When BETA is
842 *> supplied as zero then C need not be set on input.
843 *> \endverbatim
844 *>
845 *> \param[in,out] C
846 *> \verbatim
847 *> C is REAL array, dimension ( LDC, N )
848 *> Before entry, the leading m by n part of the array C must
849 *> contain the matrix C, except when beta is zero, in which
850 *> case C need not be set on entry.
851 *> On exit, the array C is overwritten by the m by n matrix
852 *> ( alpha*op( A )*op( B ) + beta*C ).
853 *> \endverbatim
854 *>
855 *> \param[in] LDC
856 *> \verbatim
857 *> LDC is INTEGER
858 *> On entry, LDC specifies the first dimension of C as declared
859 *> in the calling (sub) program. LDC must be at least
860 *> max( 1, m ).
861 *> \endverbatim
862 *
863 * Authors:
864 * ========
865 *
866 *> \author Univ. of Tennessee
867 *> \author Univ. of California Berkeley
868 *> \author Univ. of Colorado Denver
869 *> \author NAG Ltd.
870 *
871 *> \date December 2016
872 *
873 *> \ingroup single_blas_level3
874 *
875 *> \par Further Details:
876 * =====================
877 *>
878 *> \verbatim
879 *>
880 *> Level 3 Blas routine.
881 *>
882 *> -- Written on 8-February-1989.
883 *> Jack Dongarra, Argonne National Laboratory.
884 *> Iain Duff, AERE Harwell.
885 *> Jeremy Du Croz, Numerical Algorithms Group Ltd.
886 *> Sven Hammarling, Numerical Algorithms Group Ltd.
887 *> \endverbatim
888 *>
889 * =====================================================================
890 SUBROUTINE SGEMM(TRANSA,TRANSB,M,N,K,ALPHA,A,LDA,B,LDB,BETA,C,LDC)
891 *
892 * -- Reference BLAS level3 routine (version 3.7.0) --
893 * -- Reference BLAS is a software package provided by Univ. of Tennessee, --
894 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
895 * December 2016
896 *
897 * .. Scalar Arguments ..
898 REAL ALPHA,BETA
899 INTEGER K,LDA,LDB,LDC,M,N
900 CHARACTER TRANSA,TRANSB
901 * ..
902 * .. Array Arguments ..
903 REAL A(LDA,*),B(LDB,*),C(LDC,*)
904 * ..
905 *
906 * =====================================================================
907 *
908 * .. External Functions ..
909 LOGICAL LSAME
910 EXTERNAL LSAME
911 * ..
912 * .. External Subroutines ..
913 EXTERNAL XERBLA
914 * ..
915 * .. Intrinsic Functions ..
916 INTRINSIC MAX
917 * ..
918 * .. Local Scalars ..
919 REAL TEMP
920 INTEGER I,INFO,J,L,NCOLA,NROWA,NROWB
921 LOGICAL NOTA,NOTB
922 * ..
923 * .. Parameters ..
924 REAL ONE,ZERO
925 PARAMETER (ONE=1.0E+0,ZERO=0.0E+0)
926 * ..
927 *
928 * Set NOTA and NOTB as true if A and B respectively are not
929 * transposed and set NROWA, NCOLA and NROWB as the number of rows
930 * and columns of A and the number of rows of B respectively.
931 *
932 NOTA = LSAME(TRANSA,'N')
933 NOTB = LSAME(TRANSB,'N')
934 IF (NOTA) THEN
935 NROWA = M
936 NCOLA = K
937 ELSE
938 NROWA = K
939 NCOLA = M
940 END IF
941 IF (NOTB) THEN
942 NROWB = K
943 ELSE
944 NROWB = N
945 END IF
946 *
947 * Test the input parameters.
948 *
949 INFO = 0
950 IF ((.NOT.NOTA) .AND. (.NOT.LSAME(TRANSA,'C')) .AND.
951 + (.NOT.LSAME(TRANSA,'T'))) THEN
952 INFO = 1
953 ELSE IF ((.NOT.NOTB) .AND. (.NOT.LSAME(TRANSB,'C')) .AND.
954 + (.NOT.LSAME(TRANSB,'T'))) THEN
955 INFO = 2
956 ELSE IF (M.LT.0) THEN
957 INFO = 3
958 ELSE IF (N.LT.0) THEN
959 INFO = 4
960 ELSE IF (K.LT.0) THEN
961 INFO = 5
962 ELSE IF (LDA.LT.MAX(1,NROWA)) THEN
963 INFO = 8
964 ELSE IF (LDB.LT.MAX(1,NROWB)) THEN
965 INFO = 10
966 ELSE IF (LDC.LT.MAX(1,M)) THEN
967 INFO = 13
968 END IF
969 IF (INFO.NE.0) THEN
970 CALL XERBLA('SGEMM ',INFO)
971 RETURN
972 END IF
973 *
974 * Quick return if possible.
975 *
976 IF ((M.EQ.0) .OR. (N.EQ.0) .OR.
977 + (((ALPHA.EQ.ZERO).OR. (K.EQ.0)).AND. (BETA.EQ.ONE))) RETURN
978 *
979 * And if alpha.eq.zero.
980 *
981 IF (ALPHA.EQ.ZERO) THEN
982 IF (BETA.EQ.ZERO) THEN
983 DO 20 J = 1,N
984 DO 10 I = 1,M
985 C(I,J) = ZERO
986 10 CONTINUE
987 20 CONTINUE
988 ELSE
989 DO 40 J = 1,N
990 DO 30 I = 1,M
991 C(I,J) = BETA*C(I,J)
992 30 CONTINUE
993 40 CONTINUE
994 END IF
995 RETURN
996 END IF
997 *
998 * Start the operations.
999 *
1000 IF (NOTB) THEN
1001 IF (NOTA) THEN
1002 *
1003 * Form C := alpha*A*B + beta*C.
1004 *
1005 DO 90 J = 1,N
1006 IF (BETA.EQ.ZERO) THEN
1007 DO 50 I = 1,M
1008 C(I,J) = ZERO
1009 50 CONTINUE
1010 ELSE IF (BETA.NE.ONE) THEN
1011 DO 60 I = 1,M
1012 C(I,J) = BETA*C(I,J)
1013 60 CONTINUE
1014 END IF
1015 DO 80 L = 1,K
1016 TEMP = ALPHA*B(L,J)
1017 DO 70 I = 1,M
1018 C(I,J) = C(I,J) + TEMP*A(I,L)
1019 70 CONTINUE
1020 80 CONTINUE
1021 90 CONTINUE
1022 ELSE
1023 *
1024 * Form C := alpha*A**T*B + beta*C
1025 *
1026 DO 120 J = 1,N
1027 DO 110 I = 1,M
1028 TEMP = ZERO
1029 DO 100 L = 1,K
1030 TEMP = TEMP + A(L,I)*B(L,J)
1031 100 CONTINUE
1032 IF (BETA.EQ.ZERO) THEN
1033 C(I,J) = ALPHA*TEMP
1034 ELSE
1035 C(I,J) = ALPHA*TEMP + BETA*C(I,J)
1036 END IF
1037 110 CONTINUE
1038 120 CONTINUE
1039 END IF
1040 ELSE
1041 IF (NOTA) THEN
1042 *
1043 * Form C := alpha*A*B**T + beta*C
1044 *
1045 DO 170 J = 1,N
1046 IF (BETA.EQ.ZERO) THEN
1047 DO 130 I = 1,M
1048 C(I,J) = ZERO
1049 130 CONTINUE
1050 ELSE IF (BETA.NE.ONE) THEN
1051 DO 140 I = 1,M
1052 C(I,J) = BETA*C(I,J)
1053 140 CONTINUE
1054 END IF
1055 DO 160 L = 1,K
1056 TEMP = ALPHA*B(J,L)
1057 DO 150 I = 1,M
1058 C(I,J) = C(I,J) + TEMP*A(I,L)
1059 150 CONTINUE
1060 160 CONTINUE
1061 170 CONTINUE
1062 ELSE
1063 *
1064 * Form C := alpha*A**T*B**T + beta*C
1065 *
1066 DO 200 J = 1,N
1067 DO 190 I = 1,M
1068 TEMP = ZERO
1069 DO 180 L = 1,K
1070 TEMP = TEMP + A(L,I)*B(J,L)
1071 180 CONTINUE
1072 IF (BETA.EQ.ZERO) THEN
1073 C(I,J) = ALPHA*TEMP
1074 ELSE
1075 C(I,J) = ALPHA*TEMP + BETA*C(I,J)
1076 END IF
1077 190 CONTINUE
1078 200 CONTINUE
1079 END IF
1080 END IF
1081 *
1082 RETURN
1083 *
1084 * End of SGEMM .
1085 *
1086 END
1087
1088 *> \brief \b DGEMM
1089 *
1090 * =========== DOCUMENTATION ===========
1091 *
1092 * Online html documentation available at
1093 * http://www.netlib.org/lapack/explore-html/
1094 *
1095 * Definition:
1096 * ===========
1097 *
1098 * SUBROUTINE DGEMM(TRANSA,TRANSB,M,N,K,ALPHA,A,LDA,B,LDB,BETA,C,LDC)
1099 *
1100 * .. Scalar Arguments ..
1101 * DOUBLE PRECISION ALPHA,BETA
1102 * INTEGER K,LDA,LDB,LDC,M,N
1103 * CHARACTER TRANSA,TRANSB
1104 * ..
1105 * .. Array Arguments ..
1106 * DOUBLE PRECISION A(LDA,*),B(LDB,*),C(LDC,*)
1107 * ..
1108 *
1109 *
1110 *> \par Purpose:
1111 * =============
1112 *>
1113 *> \verbatim
1114 *>
1115 *> DGEMM performs one of the matrix-matrix operations
1116 *>
1117 *> C := alpha*op( A )*op( B ) + beta*C,
1118 *>
1119 *> where op( X ) is one of
1120 *>
1121 *> op( X ) = X or op( X ) = X**T,
1122 *>
1123 *> alpha and beta are scalars, and A, B and C are matrices, with op( A )
1124 *> an m by k matrix, op( B ) a k by n matrix and C an m by n matrix.
1125 *> \endverbatim
1126 *
1127 * Arguments:
1128 * ==========
1129 *
1130 *> \param[in] TRANSA
1131 *> \verbatim
1132 *> TRANSA is CHARACTER*1
1133 *> On entry, TRANSA specifies the form of op( A ) to be used in
1134 *> the matrix multiplication as follows:
1135 *>
1136 *> TRANSA = 'N' or 'n', op( A ) = A.
1137 *>
1138 *> TRANSA = 'T' or 't', op( A ) = A**T.
1139 *>
1140 *> TRANSA = 'C' or 'c', op( A ) = A**T.
1141 *> \endverbatim
1142 *>
1143 *> \param[in] TRANSB
1144 *> \verbatim
1145 *> TRANSB is CHARACTER*1
1146 *> On entry, TRANSB specifies the form of op( B ) to be used in
1147 *> the matrix multiplication as follows:
1148 *>
1149 *> TRANSB = 'N' or 'n', op( B ) = B.
1150 *>
1151 *> TRANSB = 'T' or 't', op( B ) = B**T.
1152 *>
1153 *> TRANSB = 'C' or 'c', op( B ) = B**T.
1154 *> \endverbatim
1155 *>
1156 *> \param[in] M
1157 *> \verbatim
1158 *> M is INTEGER
1159 *> On entry, M specifies the number of rows of the matrix
1160 *> op( A ) and of the matrix C. M must be at least zero.
1161 *> \endverbatim
1162 *>
1163 *> \param[in] N
1164 *> \verbatim
1165 *> N is INTEGER
1166 *> On entry, N specifies the number of columns of the matrix
1167 *> op( B ) and the number of columns of the matrix C. N must be
1168 *> at least zero.
1169 *> \endverbatim
1170 *>
1171 *> \param[in] K
1172 *> \verbatim
1173 *> K is INTEGER
1174 *> On entry, K specifies the number of columns of the matrix
1175 *> op( A ) and the number of rows of the matrix op( B ). K must
1176 *> be at least zero.
1177 *> \endverbatim
1178 *>
1179 *> \param[in] ALPHA
1180 *> \verbatim
1181 *> ALPHA is DOUBLE PRECISION.
1182 *> On entry, ALPHA specifies the scalar alpha.
1183 *> \endverbatim
1184 *>
1185 *> \param[in] A
1186 *> \verbatim
1187 *> A is DOUBLE PRECISION array, dimension ( LDA, ka ), where ka is
1188 *> k when TRANSA = 'N' or 'n', and is m otherwise.
1189 *> Before entry with TRANSA = 'N' or 'n', the leading m by k
1190 *> part of the array A must contain the matrix A, otherwise
1191 *> the leading k by m part of the array A must contain the
1192 *> matrix A.
1193 *> \endverbatim
1194 *>
1195 *> \param[in] LDA
1196 *> \verbatim
1197 *> LDA is INTEGER
1198 *> On entry, LDA specifies the first dimension of A as declared
1199 *> in the calling (sub) program. When TRANSA = 'N' or 'n' then
1200 *> LDA must be at least max( 1, m ), otherwise LDA must be at
1201 *> least max( 1, k ).
1202 *> \endverbatim
1203 *>
1204 *> \param[in] B
1205 *> \verbatim
1206 *> B is DOUBLE PRECISION array, dimension ( LDB, kb ), where kb is
1207 *> n when TRANSB = 'N' or 'n', and is k otherwise.
1208 *> Before entry with TRANSB = 'N' or 'n', the leading k by n
1209 *> part of the array B must contain the matrix B, otherwise
1210 *> the leading n by k part of the array B must contain the
1211 *> matrix B.
1212 *> \endverbatim
1213 *>
1214 *> \param[in] LDB
1215 *> \verbatim
1216 *> LDB is INTEGER
1217 *> On entry, LDB specifies the first dimension of B as declared
1218 *> in the calling (sub) program. When TRANSB = 'N' or 'n' then
1219 *> LDB must be at least max( 1, k ), otherwise LDB must be at
1220 *> least max( 1, n ).
1221 *> \endverbatim
1222 *>
1223 *> \param[in] BETA
1224 *> \verbatim
1225 *> BETA is DOUBLE PRECISION.
1226 *> On entry, BETA specifies the scalar beta. When BETA is
1227 *> supplied as zero then C need not be set on input.
1228 *> \endverbatim
1229 *>
1230 *> \param[in,out] C
1231 *> \verbatim
1232 *> C is DOUBLE PRECISION array, dimension ( LDC, N )
1233 *> Before entry, the leading m by n part of the array C must
1234 *> contain the matrix C, except when beta is zero, in which
1235 *> case C need not be set on entry.
1236 *> On exit, the array C is overwritten by the m by n matrix
1237 *> ( alpha*op( A )*op( B ) + beta*C ).
1238 *> \endverbatim
1239 *>
1240 *> \param[in] LDC
1241 *> \verbatim
1242 *> LDC is INTEGER
1243 *> On entry, LDC specifies the first dimension of C as declared
1244 *> in the calling (sub) program. LDC must be at least
1245 *> max( 1, m ).
1246 *> \endverbatim
1247 *
1248 * Authors:
1249 * ========
1250 *
1251 *> \author Univ. of Tennessee
1252 *> \author Univ. of California Berkeley
1253 *> \author Univ. of Colorado Denver
1254 *> \author NAG Ltd.
1255 *
1256 *> \date December 2016
1257 *
1258 *> \ingroup double_blas_level3
1259 *
1260 *> \par Further Details:
1261 * =====================
1262 *>
1263 *> \verbatim
1264 *>
1265 *> Level 3 Blas routine.
1266 *>
1267 *> -- Written on 8-February-1989.
1268 *> Jack Dongarra, Argonne National Laboratory.
1269 *> Iain Duff, AERE Harwell.
1270 *> Jeremy Du Croz, Numerical Algorithms Group Ltd.
1271 *> Sven Hammarling, Numerical Algorithms Group Ltd.
1272 *> \endverbatim
1273 *>
1274 * =====================================================================
1275 SUBROUTINE DGEMM(TRANSA,TRANSB,M,N,K,ALPHA,A,LDA,B,LDB,BETA,C,LDC)
1276 *
1277 * -- Reference BLAS level3 routine (version 3.7.0) --
1278 * -- Reference BLAS is a software package provided by Univ. of Tennessee, --
1279 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
1280 * December 2016
1281 *
1282 * .. Scalar Arguments ..
1283 DOUBLE PRECISION ALPHA,BETA
1284 INTEGER K,LDA,LDB,LDC,M,N
1285 CHARACTER TRANSA,TRANSB
1286 * ..
1287 * .. Array Arguments ..
1288 DOUBLE PRECISION A(LDA,*),B(LDB,*),C(LDC,*)
1289 * ..
1290 *
1291 * =====================================================================
1292 *
1293 * .. External Functions ..
1294 LOGICAL LSAME
1295 EXTERNAL LSAME
1296 * ..
1297 * .. External Subroutines ..
1298 EXTERNAL XERBLA
1299 * ..
1300 * .. Intrinsic Functions ..
1301 INTRINSIC MAX
1302 * ..
1303 * .. Local Scalars ..
1304 DOUBLE PRECISION TEMP
1305 INTEGER I,INFO,J,L,NCOLA,NROWA,NROWB
1306 LOGICAL NOTA,NOTB
1307 * ..
1308 * .. Parameters ..
1309 DOUBLE PRECISION ONE,ZERO
1310 PARAMETER (ONE=1.0D+0,ZERO=0.0D+0)
1311 * ..
1312 *
1313 * Set NOTA and NOTB as true if A and B respectively are not
1314 * transposed and set NROWA, NCOLA and NROWB as the number of rows
1315 * and columns of A and the number of rows of B respectively.
1316 *
1317 NOTA = LSAME(TRANSA,'N')
1318 NOTB = LSAME(TRANSB,'N')
1319 IF (NOTA) THEN
1320 NROWA = M
1321 NCOLA = K
1322 ELSE
1323 NROWA = K
1324 NCOLA = M
1325 END IF
1326 IF (NOTB) THEN
1327 NROWB = K
1328 ELSE
1329 NROWB = N
1330 END IF
1331 *
1332 * Test the input parameters.
1333 *
1334 INFO = 0
1335 IF ((.NOT.NOTA) .AND. (.NOT.LSAME(TRANSA,'C')) .AND.
1336 + (.NOT.LSAME(TRANSA,'T'))) THEN
1337 INFO = 1
1338 ELSE IF ((.NOT.NOTB) .AND. (.NOT.LSAME(TRANSB,'C')) .AND.
1339 + (.NOT.LSAME(TRANSB,'T'))) THEN
1340 INFO = 2
1341 ELSE IF (M.LT.0) THEN
1342 INFO = 3
1343 ELSE IF (N.LT.0) THEN
1344 INFO = 4
1345 ELSE IF (K.LT.0) THEN
1346 INFO = 5
1347 ELSE IF (LDA.LT.MAX(1,NROWA)) THEN
1348 INFO = 8
1349 ELSE IF (LDB.LT.MAX(1,NROWB)) THEN
1350 INFO = 10
1351 ELSE IF (LDC.LT.MAX(1,M)) THEN
1352 INFO = 13
1353 END IF
1354 IF (INFO.NE.0) THEN
1355 CALL XERBLA('DGEMM ',INFO)
1356 RETURN
1357 END IF
1358 *
1359 * Quick return if possible.
1360 *
1361 IF ((M.EQ.0) .OR. (N.EQ.0) .OR.
1362 + (((ALPHA.EQ.ZERO).OR. (K.EQ.0)).AND. (BETA.EQ.ONE))) RETURN
1363 *
1364 * And if alpha.eq.zero.
1365 *
1366 IF (ALPHA.EQ.ZERO) THEN
1367 IF (BETA.EQ.ZERO) THEN
1368 DO 20 J = 1,N
1369 DO 10 I = 1,M
1370 C(I,J) = ZERO
1371 10 CONTINUE
1372 20 CONTINUE
1373 ELSE
1374 DO 40 J = 1,N
1375 DO 30 I = 1,M
1376 C(I,J) = BETA*C(I,J)
1377 30 CONTINUE
1378 40 CONTINUE
1379 END IF
1380 RETURN
1381 END IF
1382 *
1383 * Start the operations.
1384 *
1385 IF (NOTB) THEN
1386 IF (NOTA) THEN
1387 *
1388 * Form C := alpha*A*B + beta*C.
1389 *
1390 DO 90 J = 1,N
1391 IF (BETA.EQ.ZERO) THEN
1392 DO 50 I = 1,M
1393 C(I,J) = ZERO
1394 50 CONTINUE
1395 ELSE IF (BETA.NE.ONE) THEN
1396 DO 60 I = 1,M
1397 C(I,J) = BETA*C(I,J)
1398 60 CONTINUE
1399 END IF
1400 DO 80 L = 1,K
1401 TEMP = ALPHA*B(L,J)
1402 DO 70 I = 1,M
1403 C(I,J) = C(I,J) + TEMP*A(I,L)
1404 70 CONTINUE
1405 80 CONTINUE
1406 90 CONTINUE
1407 ELSE
1408 *
1409 * Form C := alpha*A**T*B + beta*C
1410 *
1411 DO 120 J = 1,N
1412 DO 110 I = 1,M
1413 TEMP = ZERO
1414 DO 100 L = 1,K
1415 TEMP = TEMP + A(L,I)*B(L,J)
1416 100 CONTINUE
1417 IF (BETA.EQ.ZERO) THEN
1418 C(I,J) = ALPHA*TEMP
1419 ELSE
1420 C(I,J) = ALPHA*TEMP + BETA*C(I,J)
1421 END IF
1422 110 CONTINUE
1423 120 CONTINUE
1424 END IF
1425 ELSE
1426 IF (NOTA) THEN
1427 *
1428 * Form C := alpha*A*B**T + beta*C
1429 *
1430 DO 170 J = 1,N
1431 IF (BETA.EQ.ZERO) THEN
1432 DO 130 I = 1,M
1433 C(I,J) = ZERO
1434 130 CONTINUE
1435 ELSE IF (BETA.NE.ONE) THEN
1436 DO 140 I = 1,M
1437 C(I,J) = BETA*C(I,J)
1438 140 CONTINUE
1439 END IF
1440 DO 160 L = 1,K
1441 TEMP = ALPHA*B(J,L)
1442 DO 150 I = 1,M
1443 C(I,J) = C(I,J) + TEMP*A(I,L)
1444 150 CONTINUE
1445 160 CONTINUE
1446 170 CONTINUE
1447 ELSE
1448 *
1449 * Form C := alpha*A**T*B**T + beta*C
1450 *
1451 DO 200 J = 1,N
1452 DO 190 I = 1,M
1453 TEMP = ZERO
1454 DO 180 L = 1,K
1455 TEMP = TEMP + A(L,I)*B(J,L)
1456 180 CONTINUE
1457 IF (BETA.EQ.ZERO) THEN
1458 C(I,J) = ALPHA*TEMP
1459 ELSE
1460 C(I,J) = ALPHA*TEMP + BETA*C(I,J)
1461 END IF
1462 190 CONTINUE
1463 200 CONTINUE
1464 END IF
1465 END IF
1466 *
1467 RETURN
1468 *
1469 * End of DGEMM .
1470 *
1471 END
1472
1473 *> \brief \b ZGEMM
1474 *
1475 * =========== DOCUMENTATION ===========
1476 *
1477 * Online html documentation available at
1478 * http://www.netlib.org/lapack/explore-html/
1479 *
1480 * Definition:
1481 * ===========
1482 *
1483 * SUBROUTINE ZGEMM(TRANSA,TRANSB,M,N,K,ALPHA,A,LDA,B,LDB,BETA,C,LDC)
1484 *
1485 * .. Scalar Arguments ..
1486 * COMPLEX*16 ALPHA,BETA
1487 * INTEGER K,LDA,LDB,LDC,M,N
1488 * CHARACTER TRANSA,TRANSB
1489 * ..
1490 * .. Array Arguments ..
1491 * COMPLEX*16 A(LDA,*),B(LDB,*),C(LDC,*)
1492 * ..
1493 *
1494 *
1495 *> \par Purpose:
1496 * =============
1497 *>
1498 *> \verbatim
1499 *>
1500 *> ZGEMM performs one of the matrix-matrix operations
1501 *>
1502 *> C := alpha*op( A )*op( B ) + beta*C,
1503 *>
1504 *> where op( X ) is one of
1505 *>
1506 *> op( X ) = X or op( X ) = X**T or op( X ) = X**H,
1507 *>
1508 *> alpha and beta are scalars, and A, B and C are matrices, with op( A )
1509 *> an m by k matrix, op( B ) a k by n matrix and C an m by n matrix.
1510 *> \endverbatim
1511 *
1512 * Arguments:
1513 * ==========
1514 *
1515 *> \param[in] TRANSA
1516 *> \verbatim
1517 *> TRANSA is CHARACTER*1
1518 *> On entry, TRANSA specifies the form of op( A ) to be used in
1519 *> the matrix multiplication as follows:
1520 *>
1521 *> TRANSA = 'N' or 'n', op( A ) = A.
1522 *>
1523 *> TRANSA = 'T' or 't', op( A ) = A**T.
1524 *>
1525 *> TRANSA = 'C' or 'c', op( A ) = A**H.
1526 *> \endverbatim
1527 *>
1528 *> \param[in] TRANSB
1529 *> \verbatim
1530 *> TRANSB is CHARACTER*1
1531 *> On entry, TRANSB specifies the form of op( B ) to be used in
1532 *> the matrix multiplication as follows:
1533 *>
1534 *> TRANSB = 'N' or 'n', op( B ) = B.
1535 *>
1536 *> TRANSB = 'T' or 't', op( B ) = B**T.
1537 *>
1538 *> TRANSB = 'C' or 'c', op( B ) = B**H.
1539 *> \endverbatim
1540 *>
1541 *> \param[in] M
1542 *> \verbatim
1543 *> M is INTEGER
1544 *> On entry, M specifies the number of rows of the matrix
1545 *> op( A ) and of the matrix C. M must be at least zero.
1546 *> \endverbatim
1547 *>
1548 *> \param[in] N
1549 *> \verbatim
1550 *> N is INTEGER
1551 *> On entry, N specifies the number of columns of the matrix
1552 *> op( B ) and the number of columns of the matrix C. N must be
1553 *> at least zero.
1554 *> \endverbatim
1555 *>
1556 *> \param[in] K
1557 *> \verbatim
1558 *> K is INTEGER
1559 *> On entry, K specifies the number of columns of the matrix
1560 *> op( A ) and the number of rows of the matrix op( B ). K must
1561 *> be at least zero.
1562 *> \endverbatim
1563 *>
1564 *> \param[in] ALPHA
1565 *> \verbatim
1566 *> ALPHA is COMPLEX*16
1567 *> On entry, ALPHA specifies the scalar alpha.
1568 *> \endverbatim
1569 *>
1570 *> \param[in] A
1571 *> \verbatim
1572 *> A is COMPLEX*16 array, dimension ( LDA, ka ), where ka is
1573 *> k when TRANSA = 'N' or 'n', and is m otherwise.
1574 *> Before entry with TRANSA = 'N' or 'n', the leading m by k
1575 *> part of the array A must contain the matrix A, otherwise
1576 *> the leading k by m part of the array A must contain the
1577 *> matrix A.
1578 *> \endverbatim
1579 *>
1580 *> \param[in] LDA
1581 *> \verbatim
1582 *> LDA is INTEGER
1583 *> On entry, LDA specifies the first dimension of A as declared
1584 *> in the calling (sub) program. When TRANSA = 'N' or 'n' then
1585 *> LDA must be at least max( 1, m ), otherwise LDA must be at
1586 *> least max( 1, k ).
1587 *> \endverbatim
1588 *>
1589 *> \param[in] B
1590 *> \verbatim
1591 *> B is COMPLEX*16 array, dimension ( LDB, kb ), where kb is
1592 *> n when TRANSB = 'N' or 'n', and is k otherwise.
1593 *> Before entry with TRANSB = 'N' or 'n', the leading k by n
1594 *> part of the array B must contain the matrix B, otherwise
1595 *> the leading n by k part of the array B must contain the
1596 *> matrix B.
1597 *> \endverbatim
1598 *>
1599 *> \param[in] LDB
1600 *> \verbatim
1601 *> LDB is INTEGER
1602 *> On entry, LDB specifies the first dimension of B as declared
1603 *> in the calling (sub) program. When TRANSB = 'N' or 'n' then
1604 *> LDB must be at least max( 1, k ), otherwise LDB must be at
1605 *> least max( 1, n ).
1606 *> \endverbatim
1607 *>
1608 *> \param[in] BETA
1609 *> \verbatim
1610 *> BETA is COMPLEX*16
1611 *> On entry, BETA specifies the scalar beta. When BETA is
1612 *> supplied as zero then C need not be set on input.
1613 *> \endverbatim
1614 *>
1615 *> \param[in,out] C
1616 *> \verbatim
1617 *> C is COMPLEX*16 array, dimension ( LDC, N )
1618 *> Before entry, the leading m by n part of the array C must
1619 *> contain the matrix C, except when beta is zero, in which
1620 *> case C need not be set on entry.
1621 *> On exit, the array C is overwritten by the m by n matrix
1622 *> ( alpha*op( A )*op( B ) + beta*C ).
1623 *> \endverbatim
1624 *>
1625 *> \param[in] LDC
1626 *> \verbatim
1627 *> LDC is INTEGER
1628 *> On entry, LDC specifies the first dimension of C as declared
1629 *> in the calling (sub) program. LDC must be at least
1630 *> max( 1, m ).
1631 *> \endverbatim
1632 *
1633 * Authors:
1634 * ========
1635 *
1636 *> \author Univ. of Tennessee
1637 *> \author Univ. of California Berkeley
1638 *> \author Univ. of Colorado Denver
1639 *> \author NAG Ltd.
1640 *
1641 *> \date December 2016
1642 *
1643 *> \ingroup complex16_blas_level3
1644 *
1645 *> \par Further Details:
1646 * =====================
1647 *>
1648 *> \verbatim
1649 *>
1650 *> Level 3 Blas routine.
1651 *>
1652 *> -- Written on 8-February-1989.
1653 *> Jack Dongarra, Argonne National Laboratory.
1654 *> Iain Duff, AERE Harwell.
1655 *> Jeremy Du Croz, Numerical Algorithms Group Ltd.
1656 *> Sven Hammarling, Numerical Algorithms Group Ltd.
1657 *> \endverbatim
1658 *>
1659 * =====================================================================
1660 SUBROUTINE ZGEMM(TRANSA,TRANSB,M,N,K,ALPHA,A,LDA,B,LDB,BETA,C,LDC)
1661 *
1662 * -- Reference BLAS level3 routine (version 3.7.0) --
1663 * -- Reference BLAS is a software package provided by Univ. of Tennessee, --
1664 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
1665 * December 2016
1666 *
1667 * .. Scalar Arguments ..
1668 COMPLEX*16 ALPHA,BETA
1669 INTEGER K,LDA,LDB,LDC,M,N
1670 CHARACTER TRANSA,TRANSB
1671 * ..
1672 * .. Array Arguments ..
1673 COMPLEX*16 A(LDA,*),B(LDB,*),C(LDC,*)
1674 * ..
1675 *
1676 * =====================================================================
1677 *
1678 * .. External Functions ..
1679 LOGICAL LSAME
1680 EXTERNAL LSAME
1681 * ..
1682 * .. External Subroutines ..
1683 EXTERNAL XERBLA
1684 * ..
1685 * .. Intrinsic Functions ..
1686 INTRINSIC DCONJG,MAX
1687 * ..
1688 * .. Local Scalars ..
1689 COMPLEX*16 TEMP
1690 INTEGER I,INFO,J,L,NCOLA,NROWA,NROWB
1691 LOGICAL CONJA,CONJB,NOTA,NOTB
1692 * ..
1693 * .. Parameters ..
1694 COMPLEX*16 ONE
1695 PARAMETER (ONE= (1.0D+0,0.0D+0))
1696 COMPLEX*16 ZERO
1697 PARAMETER (ZERO= (0.0D+0,0.0D+0))
1698 * ..
1699 *
1700 * Set NOTA and NOTB as true if A and B respectively are not
1701 * conjugated or transposed, set CONJA and CONJB as true if A and
1702 * B respectively are to be transposed but not conjugated and set
1703 * NROWA, NCOLA and NROWB as the number of rows and columns of A
1704 * and the number of rows of B respectively.
1705 *
1706 NOTA = LSAME(TRANSA,'N')
1707 NOTB = LSAME(TRANSB,'N')
1708 CONJA = LSAME(TRANSA,'C')
1709 CONJB = LSAME(TRANSB,'C')
1710 IF (NOTA) THEN
1711 NROWA = M
1712 NCOLA = K
1713 ELSE
1714 NROWA = K
1715 NCOLA = M
1716 END IF
1717 IF (NOTB) THEN
1718 NROWB = K
1719 ELSE
1720 NROWB = N
1721 END IF
1722 *
1723 * Test the input parameters.
1724 *
1725 INFO = 0
1726 IF ((.NOT.NOTA) .AND. (.NOT.CONJA) .AND.
1727 + (.NOT.LSAME(TRANSA,'T'))) THEN
1728 INFO = 1
1729 ELSE IF ((.NOT.NOTB) .AND. (.NOT.CONJB) .AND.
1730 + (.NOT.LSAME(TRANSB,'T'))) THEN
1731 INFO = 2
1732 ELSE IF (M.LT.0) THEN
1733 INFO = 3
1734 ELSE IF (N.LT.0) THEN
1735 INFO = 4
1736 ELSE IF (K.LT.0) THEN
1737 INFO = 5
1738 ELSE IF (LDA.LT.MAX(1,NROWA)) THEN
1739 INFO = 8
1740 ELSE IF (LDB.LT.MAX(1,NROWB)) THEN
1741 INFO = 10
1742 ELSE IF (LDC.LT.MAX(1,M)) THEN
1743 INFO = 13
1744 END IF
1745 IF (INFO.NE.0) THEN
1746 CALL XERBLA('ZGEMM ',INFO)
1747 RETURN
1748 END IF
1749 *
1750 * Quick return if possible.
1751 *
1752 IF ((M.EQ.0) .OR. (N.EQ.0) .OR.
1753 + (((ALPHA.EQ.ZERO).OR. (K.EQ.0)).AND. (BETA.EQ.ONE))) RETURN
1754 *
1755 * And when alpha.eq.zero.
1756 *
1757 IF (ALPHA.EQ.ZERO) THEN
1758 IF (BETA.EQ.ZERO) THEN
1759 DO 20 J = 1,N
1760 DO 10 I = 1,M
1761 C(I,J) = ZERO
1762 10 CONTINUE
1763 20 CONTINUE
1764 ELSE
1765 DO 40 J = 1,N
1766 DO 30 I = 1,M
1767 C(I,J) = BETA*C(I,J)
1768 30 CONTINUE
1769 40 CONTINUE
1770 END IF
1771 RETURN
1772 END IF
1773 *
1774 * Start the operations.
1775 *
1776 IF (NOTB) THEN
1777 IF (NOTA) THEN
1778 *
1779 * Form C := alpha*A*B + beta*C.
1780 *
1781 DO 90 J = 1,N
1782 IF (BETA.EQ.ZERO) THEN
1783 DO 50 I = 1,M
1784 C(I,J) = ZERO
1785 50 CONTINUE
1786 ELSE IF (BETA.NE.ONE) THEN
1787 DO 60 I = 1,M
1788 C(I,J) = BETA*C(I,J)
1789 60 CONTINUE
1790 END IF
1791 DO 80 L = 1,K
1792 TEMP = ALPHA*B(L,J)
1793 DO 70 I = 1,M
1794 C(I,J) = C(I,J) + TEMP*A(I,L)
1795 70 CONTINUE
1796 80 CONTINUE
1797 90 CONTINUE
1798 ELSE IF (CONJA) THEN
1799 *
1800 * Form C := alpha*A**H*B + beta*C.
1801 *
1802 DO 120 J = 1,N
1803 DO 110 I = 1,M
1804 TEMP = ZERO
1805 DO 100 L = 1,K
1806 TEMP = TEMP + DCONJG(A(L,I))*B(L,J)
1807 100 CONTINUE
1808 IF (BETA.EQ.ZERO) THEN
1809 C(I,J) = ALPHA*TEMP
1810 ELSE
1811 C(I,J) = ALPHA*TEMP + BETA*C(I,J)
1812 END IF
1813 110 CONTINUE
1814 120 CONTINUE
1815 ELSE
1816 *
1817 * Form C := alpha*A**T*B + beta*C
1818 *
1819 DO 150 J = 1,N
1820 DO 140 I = 1,M
1821 TEMP = ZERO
1822 DO 130 L = 1,K
1823 TEMP = TEMP + A(L,I)*B(L,J)
1824 130 CONTINUE
1825 IF (BETA.EQ.ZERO) THEN
1826 C(I,J) = ALPHA*TEMP
1827 ELSE
1828 C(I,J) = ALPHA*TEMP + BETA*C(I,J)
1829 END IF
1830 140 CONTINUE
1831 150 CONTINUE
1832 END IF
1833 ELSE IF (NOTA) THEN
1834 IF (CONJB) THEN
1835 *
1836 * Form C := alpha*A*B**H + beta*C.
1837 *
1838 DO 200 J = 1,N
1839 IF (BETA.EQ.ZERO) THEN
1840 DO 160 I = 1,M
1841 C(I,J) = ZERO
1842 160 CONTINUE
1843 ELSE IF (BETA.NE.ONE) THEN
1844 DO 170 I = 1,M
1845 C(I,J) = BETA*C(I,J)
1846 170 CONTINUE
1847 END IF
1848 DO 190 L = 1,K
1849 TEMP = ALPHA*DCONJG(B(J,L))
1850 DO 180 I = 1,M
1851 C(I,J) = C(I,J) + TEMP*A(I,L)
1852 180 CONTINUE
1853 190 CONTINUE
1854 200 CONTINUE
1855 ELSE
1856 *
1857 * Form C := alpha*A*B**T + beta*C
1858 *
1859 DO 250 J = 1,N
1860 IF (BETA.EQ.ZERO) THEN
1861 DO 210 I = 1,M
1862 C(I,J) = ZERO
1863 210 CONTINUE
1864 ELSE IF (BETA.NE.ONE) THEN
1865 DO 220 I = 1,M
1866 C(I,J) = BETA*C(I,J)
1867 220 CONTINUE
1868 END IF
1869 DO 240 L = 1,K
1870 TEMP = ALPHA*B(J,L)
1871 DO 230 I = 1,M
1872 C(I,J) = C(I,J) + TEMP*A(I,L)
1873 230 CONTINUE
1874 240 CONTINUE
1875 250 CONTINUE
1876 END IF
1877 ELSE IF (CONJA) THEN
1878 IF (CONJB) THEN
1879 *
1880 * Form C := alpha*A**H*B**H + beta*C.
1881 *
1882 DO 280 J = 1,N
1883 DO 270 I = 1,M
1884 TEMP = ZERO
1885 DO 260 L = 1,K
1886 TEMP = TEMP + DCONJG(A(L,I))*DCONJG(B(J,L))
1887 260 CONTINUE
1888 IF (BETA.EQ.ZERO) THEN
1889 C(I,J) = ALPHA*TEMP
1890 ELSE
1891 C(I,J) = ALPHA*TEMP + BETA*C(I,J)
1892 END IF
1893 270 CONTINUE
1894 280 CONTINUE
1895 ELSE
1896 *
1897 * Form C := alpha*A**H*B**T + beta*C
1898 *
1899 DO 310 J = 1,N
1900 DO 300 I = 1,M
1901 TEMP = ZERO
1902 DO 290 L = 1,K
1903 TEMP = TEMP + DCONJG(A(L,I))*B(J,L)
1904 290 CONTINUE
1905 IF (BETA.EQ.ZERO) THEN
1906 C(I,J) = ALPHA*TEMP
1907 ELSE
1908 C(I,J) = ALPHA*TEMP + BETA*C(I,J)
1909 END IF
1910 300 CONTINUE
1911 310 CONTINUE
1912 END IF
1913 ELSE
1914 IF (CONJB) THEN
1915 *
1916 * Form C := alpha*A**T*B**H + beta*C
1917 *
1918 DO 340 J = 1,N
1919 DO 330 I = 1,M
1920 TEMP = ZERO
1921 DO 320 L = 1,K
1922 TEMP = TEMP + A(L,I)*DCONJG(B(J,L))
1923 320 CONTINUE
1924 IF (BETA.EQ.ZERO) THEN
1925 C(I,J) = ALPHA*TEMP
1926 ELSE
1927 C(I,J) = ALPHA*TEMP + BETA*C(I,J)
1928 END IF
1929 330 CONTINUE
1930 340 CONTINUE
1931 ELSE
1932 *
1933 * Form C := alpha*A**T*B**T + beta*C
1934 *
1935 DO 370 J = 1,N
1936 DO 360 I = 1,M
1937 TEMP = ZERO
1938 DO 350 L = 1,K
1939 TEMP = TEMP + A(L,I)*B(J,L)
1940 350 CONTINUE
1941 IF (BETA.EQ.ZERO) THEN
1942 C(I,J) = ALPHA*TEMP
1943 ELSE
1944 C(I,J) = ALPHA*TEMP + BETA*C(I,J)
1945 END IF
1946 360 CONTINUE
1947 370 CONTINUE
1948 END IF
1949 END IF
1950 *
1951 RETURN
1952 *
1953 * End of ZGEMM .
1954 *
1955 END