1 SUBROUTINE pbzmatadd( ICONTXT, MODE, M, N, ALPHA, A, LDA, BETA, B,
10 INTEGER ICONTXT, LDA, LDB, M, N
11 COMPLEX*16 ALPHA, BETA
14 COMPLEX*16 A( LDA, * ), B( LDB, * )
90 parameter( zero = ( 0.0d+0, 0.0d+0 ),
91 $ one = ( 1.0d+0, 0.0d+0 ) )
101 EXTERNAL zscal, zcopy, zaxpy
104 INTRINSIC min, dconjg
108 IF( m.LE.0 .OR. n.LE.0 .OR. ( alpha.EQ.zero.AND.beta.EQ.one ) )
113 IF( lsame( mode,
'U' ) )
THEN
114 IF( alpha.EQ.zero )
THEN
115 IF( beta.EQ.zero )
THEN
117 DO 10 i = 1,
min( j, m )
123 DO 30 i = 1,
min( j, m )
124 b( i, j ) = beta * b( i, j )
129 ELSE IF( alpha.EQ.one )
THEN
130 IF( beta.EQ.zero )
THEN
132 DO 50 i = 1,
min( j, m )
133 b( i, j ) = a( i, j )
136 ELSE IF( beta.EQ.one )
THEN
138 DO 70 i = 1,
min( j, m )
139 b( i, j ) = a( i, j ) + b( i, j )
144 DO 90 i = 1,
min( j, m )
145 b( i, j ) = a( i, j ) + beta * b( i, j )
151 IF( beta.EQ.zero )
THEN
153 DO 110 i = 1,
min( j, m )
154 b( i, j ) = alpha * a( i, j )
157 ELSE IF( beta.EQ.one )
THEN
159 DO 130 i = 1,
min( j, m )
160 b( i, j ) = alpha * a( i, j ) + b( i, j )
165 DO 150 i = 1,
min( j, m )
166 b( i, j ) = alpha * a( i, j ) + beta * b( i, j )
174 ELSE IF( lsame( mode,
'L' ) )
THEN
175 IF( alpha.EQ.zero )
THEN
176 IF( beta.EQ.zero )
THEN
185 b( i, j ) = beta * b( i, j )
190 ELSE IF( alpha.EQ.one )
THEN
191 IF( beta.EQ.zero )
THEN
194 b( i, j ) = a( i, j )
197 ELSE IF( beta.EQ.one )
THEN
200 b( i, j ) = a( i, j ) + b( i, j )
206 b( i, j ) = a( i, j ) + beta * b( i, j )
212 IF( beta.EQ.zero )
THEN
215 b( i, j ) = alpha * a( i, j )
218 ELSE IF( beta.EQ.one )
THEN
221 b( i, j ) = alpha * a( i, j ) + b( i, j )
227 b( i, j ) = alpha * a( i, j ) + beta * b( i, j )
235 ELSE IF( lsame( mode,
'T' ) )
THEN
236 IF( alpha.EQ.zero )
THEN
237 IF( beta.EQ.zero )
THEN
246 b( i, j ) = beta * b( i, j )
251 ELSE IF( alpha.EQ.one )
THEN
252 IF( beta.EQ.zero )
THEN
255 b( i, j ) = a( j, i )
258 ELSE IF( beta.EQ.one )
THEN
261 b( i, j ) = a( j, i ) + b( i, j )
267 b( i, j ) = a( j, i ) + beta * b( i, j )
273 IF( beta.EQ.zero )
THEN
276 b( i, j ) = alpha * a( j, i )
279 ELSE IF( beta.EQ.one )
THEN
282 b( i, j ) = alpha * a( j, i ) + b( i, j )
288 b( i, j ) = alpha * a( j, i ) + beta * b( i, j )
296 ELSE IF( lsame( mode,
'C' ) )
THEN
297 IF( alpha.EQ.zero )
THEN
298 IF( beta.EQ.zero )
THEN
307 b( i, j ) = beta * b( i, j )
312 ELSE IF( alpha.EQ.one )
THEN
313 IF( beta.EQ.zero )
THEN
316 b( i, j ) = dconjg( a( j, i ) )
319 ELSE IF( beta.EQ.one )
THEN
322 b( i, j ) = dconjg( a( j, i ) ) + b( i, j )
328 b( i, j ) = dconjg( a( j, i ) ) + beta * b( i, j )
334 IF( beta.EQ.zero )
THEN
337 b( i, j ) = alpha * dconjg( a( j, i ) )
340 ELSE IF( beta.EQ.one )
THEN
343 b( i, j ) = alpha * dconjg( a( j, i ) ) + b( i, j )
349 b( i, j ) = alpha * dconjg( a( j, i ) )
359 IF( alpha.EQ.zero )
THEN
360 IF( beta.EQ.zero )
THEN
369 CALL zscal( m*n, beta, b( 1, 1 ), 1 )
370 ELSE IF( lsame( mode,
'V' ) )
THEN
372 CALL zscal( m, beta, b( 1, j ), 1 )
377 b( i, j ) = beta * b( i, j )
383 ELSE IF( alpha.EQ.one )
THEN
384 IF( beta.EQ.zero )
THEN
385 IF( m.EQ.lda .AND. m.EQ.ldb )
THEN
386 CALL zcopy( m*n, a( 1, 1 ), 1, b( 1, 1 ), 1 )
387 ELSE IF( lsame( mode,
'V' ) )
THEN
389 CALL zcopy( m, a( 1, j ), 1, b( 1, j ), 1 )
394 b( i, j ) = a( i, j )
399 ELSE IF( beta.EQ.one )
THEN
402 b( i, j ) = a( i, j ) + b( i, j )
409 b( i, j ) = a( i, j ) + beta * b( i, j )
415 IF( beta.EQ.zero )
THEN
418 b( i, j ) = alpha * a( i, j )
422 ELSE IF( beta.EQ.one )
THEN
423 IF( m.EQ.lda .AND. m.EQ.ldb )
THEN
424 CALL zaxpy( m*n, alpha, a( 1, 1 ), 1, b( 1, 1 ), 1 )
425 ELSE IF( lsame( mode,
'V' ) )
THEN
427 CALL zaxpy( m, alpha, a( 1, j ), 1, b( 1, j ), 1 )
432 b( i, j ) = alpha * a( i, j ) + b( i, j )
440 b( i, j ) = alpha * a( i, j ) + beta * b( i, j )