1 SUBROUTINE pbdmatadd( ICONTXT, MODE, M, N, ALPHA, A, LDA, BETA, B,
10 INTEGER ICONTXT, LDA, LDB, M, N
11 DOUBLE PRECISION ALPHA, BETA
14 DOUBLE PRECISION A( LDA, * ), B( LDB, * )
89 DOUBLE PRECISION ZERO, ONE
90 parameter( zero = 0.0d+0, one = 1.0d+0)
100 EXTERNAL dscal, dcopy, daxpy
107 IF( m.LE.0 .OR. n.LE.0 .OR. ( alpha.EQ.zero.AND.beta.EQ.one ) )
112 IF( lsame( mode,
'U' ) )
THEN
113 IF( alpha.EQ.zero )
THEN
114 IF( beta.EQ.zero )
THEN
116 DO 10 i = 1,
min( j, m )
122 DO 30 i = 1,
min( j, m )
123 b( i, j ) = beta * b( i, j )
128 ELSE IF( alpha.EQ.one )
THEN
129 IF( beta.EQ.zero )
THEN
131 DO 50 i = 1,
min( j, m )
132 b( i, j ) = a( i, j )
135 ELSE IF( beta.EQ.one )
THEN
137 DO 70 i = 1,
min( j, m )
138 b( i, j ) = a( i, j ) + b( i, j )
143 DO 90 i = 1,
min( j, m )
144 b( i, j ) = a( i, j ) + beta * b( i, j )
150 IF( beta.EQ.zero )
THEN
152 DO 110 i = 1,
min( j, m )
153 b( i, j ) = alpha * a( i, j )
156 ELSE IF( beta.EQ.one )
THEN
158 DO 130 i = 1,
min( j, m )
159 b( i, j ) = alpha * a( i, j ) + b( i, j )
164 DO 150 i = 1,
min( j, m )
165 b( i, j ) = alpha * a( i, j ) + beta * b( i, j )
173 ELSE IF( lsame( mode,
'L' ) )
THEN
174 IF( alpha.EQ.zero )
THEN
175 IF( beta.EQ.zero )
THEN
184 b( i, j ) = beta * b( i, j )
189 ELSE IF( alpha.EQ.one )
THEN
190 IF( beta.EQ.zero )
THEN
193 b( i, j ) = a( i, j )
196 ELSE IF( beta.EQ.one )
THEN
199 b( i, j ) = a( i, j ) + b( i, j )
205 b( i, j ) = a( i, j ) + beta * b( i, j )
211 IF( beta.EQ.zero )
THEN
214 b( i, j ) = alpha * a( i, j )
217 ELSE IF( beta.EQ.one )
THEN
220 b( i, j ) = alpha * a( i, j ) + b( i, j )
226 b( i, j ) = alpha * a( i, j ) + beta * b( i, j )
234 ELSE IF( lsame( mode,
'T' ) .OR. lsame( mode,
'C' ) )
THEN
235 IF( alpha.EQ.zero )
THEN
236 IF( beta.EQ.zero )
THEN
245 b( i, j ) = beta * b( i, j )
250 ELSE IF( alpha.EQ.one )
THEN
251 IF( beta.EQ.zero )
THEN
254 b( i, j ) = a( j, i )
257 ELSE IF( beta.EQ.one )
THEN
260 b( i, j ) = a( j, i ) + b( i, j )
266 b( i, j ) = a( j, i ) + beta * b( i, j )
272 IF( beta.EQ.zero )
THEN
275 b( i, j ) = alpha * a( j, i )
278 ELSE IF( beta.EQ.one )
THEN
281 b( i, j ) = alpha * a( j, i ) + b( i, j )
287 b( i, j ) = alpha * a( j, i ) + beta * b( i, j )
296 IF( alpha.EQ.zero )
THEN
297 IF( beta.EQ.zero )
THEN
306 CALL dscal( m*n, beta, b( 1, 1 ), 1 )
307 ELSE IF( lsame( mode,
'V' ) )
THEN
309 CALL dscal( m, beta, b( 1, j ), 1 )
314 b( i, j ) = beta * b( i, j )
320 ELSE IF( alpha.EQ.one )
THEN
321 IF( beta.EQ.zero )
THEN
322 IF( m.EQ.lda .AND. m.EQ.ldb )
THEN
323 CALL dcopy( m*n, a( 1, 1 ), 1, b( 1, 1 ), 1 )
324 ELSE IF( lsame( mode,
'V' ) )
THEN
326 CALL dcopy( m, a( 1, j ), 1, b( 1, j ), 1 )
331 b( i, j ) = a( i, j )
336 ELSE IF( beta.EQ.one )
THEN
339 b( i, j ) = a( i, j ) + b( i, j )
346 b( i, j ) = a( i, j ) + beta * b( i, j )
352 IF( beta.EQ.zero )
THEN
355 b( i, j ) = alpha * a( i, j )
359 ELSE IF( beta.EQ.one )
THEN
360 IF( m.EQ.lda .AND. m.EQ.ldb )
THEN
361 CALL daxpy( m*n, alpha, a( 1, 1 ), 1, b( 1, 1 ), 1 )
362 ELSE IF( lsame( mode,
'V' ) )
THEN
364 CALL daxpy( m, alpha, a( 1, j ), 1, b( 1, j ), 1 )
369 b( i, j ) = alpha * a( i, j ) + b( i, j )
377 b( i, j ) = alpha * a( i, j ) + beta * b( i, j )