1      SUBROUTINE ZMMDDAT( M, N, ALPHA, A, LDA, BETA, B, LDB )
2*
3*  -- PBLAS auxiliary routine (version 2.0) --
4*     University of Tennessee, Knoxville, Oak Ridge National Laboratory,
5*     and University of California, Berkeley.
6*     April 1, 1998
7*
8*     .. Scalar Arguments ..
9      INTEGER            LDA, LDB, M, N
10      COMPLEX*16         ALPHA, BETA
11*     ..
12*     .. Array Arguments ..
13      COMPLEX*16         A( LDA, * ), B( LDB, * )
14*     ..
15*
16*  Purpose
17*  =======
18*
19*  ZMMDDAT performs the following operation:
20*
21*     A := alpha * A + beta * B',
22*
23*  where alpha, beta are scalars; A is an m by n matrix and B is an n by
24*  m matrix.
25*
26*  Arguments
27*  =========
28*
29*  M       (local input) INTEGER
30*          On entry, M  specifies the number of rows of A and the number
31*          of columns of B. M must be at least zero.
32*
33*  N       (local input) INTEGER
34*          On entry, N  specifies the number of rows of B and the number
35*          of columns of A. N must be at least zero.
36*
37*  ALPHA   (local input) COMPLEX*16
38*          On entry,  ALPHA  specifies the scalar alpha. When  ALPHA  is
39*          supplied as zero then the local entries of the array  A  need
40*          not be set on input.
41*
42*  A       (local input/local output) COMPLEX*16 array
43*          On entry, A is an array of dimension ( LDA, N ). On exit, the
44*          leading n by m part of B has been added to the leading m by n
45*          part of A.
46*
47*  LDA     (local input) INTEGER
48*          On entry, LDA specifies the leading dimension of the array A.
49*          LDA must be at least max( 1, M ).
50*
51*  BETA    (local input) COMPLEX*16
52*          On entry,  BETA  specifies the scalar beta. When BETA is sup-
53*          plied as zero then the local entries of the array B need  not
54*          be set on input.
55*
56*  B       (local input) COMPLEX*16 array
57*          On entry, B is an array of dimension ( LDB, M ).
58*
59*  LDB     (local input) INTEGER
60*          On entry, LDB specifies the leading dimension of the array B.
61*          LDB must be at least max( 1, N ).
62*
63*  -- Written on April 1, 1998 by
64*     Antoine Petitet, University  of  Tennessee, Knoxville 37996, USA.
65*
66*  =====================================================================
67*
68*     .. Parameters ..
69      COMPLEX*16         ONE, ZERO
70      PARAMETER          ( ONE  = ( 1.0D+0, 0.0D+0 ),
71     $                     ZERO = ( 0.0D+0, 0.0D+0 ) )
72*     ..
73*     .. Local Scalars ..
74      INTEGER            I, J
75*     ..
76*     .. External Subroutines ..
77      EXTERNAL           ZAXPY, ZCOPY, ZSCAL
78*     ..
79*     .. Executable Statements ..
80*
81      IF( M.GE.N ) THEN
82         IF( BETA.EQ.ONE ) THEN
83            IF( ALPHA.EQ.ZERO ) THEN
84               DO 20 J = 1, N
85                  CALL ZCOPY( M, B( J, 1 ), LDB, A( 1, J ), 1 )
86*                 DO 10 I = 1, M
87*                    A( I, J ) = B( J, I )
88*  10             CONTINUE
89   20          CONTINUE
90            ELSE IF( ALPHA.NE.ONE ) THEN
91               DO 40 J = 1, N
92                  DO 30 I = 1, M
93                     A( I, J ) = B( J, I ) + ALPHA * A( I, J )
94   30             CONTINUE
95   40          CONTINUE
96            ELSE
97               DO 60 J = 1, N
98                  CALL ZAXPY( M, ONE, B( J, 1 ), LDB, A( 1, J ), 1 )
99*                 DO 50 I = 1, M
100*                    A( I, J ) = B( J, I ) + A( I, J )
101*  50             CONTINUE
102   60          CONTINUE
103            END IF
104         ELSE IF( BETA.NE.ZERO ) THEN
105            IF( ALPHA.EQ.ZERO ) THEN
106               DO 80 J = 1, N
107                  DO 70 I = 1, M
108                     A( I, J ) = BETA * B( J, I )
109   70             CONTINUE
110   80          CONTINUE
111            ELSE IF( ALPHA.NE.ONE ) THEN
112               DO 100 J = 1, N
113                  DO 90 I = 1, M
114                     A( I, J ) = BETA * B( J, I ) + ALPHA * A( I, J )
115   90             CONTINUE
116  100          CONTINUE
117            ELSE
118               DO 120 J = 1, N
119                  CALL ZAXPY( M, BETA, B( J, 1 ), LDB, A( 1, J ), 1 )
120*                 DO 110 I = 1, M
121*                    A( I, J ) = BETA * B( J, I ) + A( I, J )
122* 110             CONTINUE
123  120          CONTINUE
124            END IF
125         ELSE
126            IF( ALPHA.EQ.ZERO ) THEN
127               DO 140 J = 1, N
128                  DO 130 I = 1, M
129                     A( I, J ) = ZERO
130  130             CONTINUE
131  140          CONTINUE
132            ELSE IF( ALPHA.NE.ONE ) THEN
133               DO 160 J = 1, N
134                  CALL ZSCAL( M, ALPHA, A( 1, J ), 1 )
135*                 DO 150 I = 1, M
136*                    A( I, J ) = ALPHA * A( I, J )
137* 150             CONTINUE
138  160          CONTINUE
139            END IF
140         END IF
141      ELSE
142         IF( BETA.EQ.ONE ) THEN
143            IF( ALPHA.EQ.ZERO ) THEN
144               DO 180 J = 1, M
145                  CALL ZCOPY( N, B( 1, J ), 1, A( J, 1 ), LDA )
146*                 DO 170 I = 1, N
147*                    A( J, I ) = B( I, J )
148* 170             CONTINUE
149  180          CONTINUE
150            ELSE IF( ALPHA.NE.ONE ) THEN
151               DO 200 J = 1, M
152                  DO 190 I = 1, N
153                     A( J, I ) = B( I, J ) + ALPHA * A( J, I )
154  190             CONTINUE
155  200          CONTINUE
156            ELSE
157               DO 220 J = 1, M
158                  CALL ZAXPY( N, ONE, B( 1, J ), 1, A( J, 1 ), LDA )
159*                 DO 210 I = 1, N
160*                    A( J, I ) = B( I, J ) + A( J, I )
161* 210             CONTINUE
162  220          CONTINUE
163            END IF
164         ELSE IF( BETA.NE.ZERO ) THEN
165            IF( ALPHA.EQ.ZERO ) THEN
166               DO 240 J = 1, M
167                  DO 230 I = 1, N
168                     A( J, I ) = BETA * B( I, J )
169  230             CONTINUE
170  240          CONTINUE
171            ELSE IF( ALPHA.NE.ONE ) THEN
172               DO 260 J = 1, M
173                  DO 250 I = 1, N
174                     A( J, I ) = BETA * B( I, J ) + ALPHA * A( J, I )
175  250             CONTINUE
176  260          CONTINUE
177            ELSE
178               DO 280 J = 1, M
179                  CALL ZAXPY( N, BETA, B( 1, J ), 1, A( J, 1 ), LDA )
180*                 DO 270 I = 1, N
181*                    A( J, I ) = BETA * B( I, J ) + A( J, I )
182* 270             CONTINUE
183  280          CONTINUE
184            END IF
185         ELSE
186            IF( ALPHA.EQ.ZERO ) THEN
187               DO 300 J = 1, N
188                  DO 290 I = 1, M
189                     A( I, J ) = ZERO
190  290             CONTINUE
191  300          CONTINUE
192            ELSE IF( ALPHA.NE.ONE ) THEN
193               DO 320 J = 1, N
194                  CALL ZSCAL( M, ALPHA, A( 1, J ), 1 )
195*                 DO 310 I = 1, M
196*                    A( I, J ) = ALPHA * A( I, J )
197* 310             CONTINUE
198  320          CONTINUE
199            END IF
200         END IF
201      END IF
202*
203      RETURN
204*
205*     End of ZMMDDAT
206*
207      END
208