ScaLAPACK 2.1  2.1 ScaLAPACK: Scalable Linear Algebra PACKage
Go to the documentation of this file.
1  SUBROUTINE zmmtadd( 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 * ZMMTADD performs the following operation:
20 *
21 * B := 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) COMPLEX*16 array
43 * On entry, A is an array of dimension ( LDA, N ).
44 *
45 * LDA (local input) INTEGER
46 * On entry, LDA specifies the leading dimension of the array A.
47 * LDA must be at least max( 1, M ).
48 *
49 * BETA (local input) COMPLEX*16
50 * On entry, BETA specifies the scalar beta. When BETA is sup-
51 * plied as zero then the local entries of the array B need not
52 * be set on input.
53 *
54 * B (local input/local output) COMPLEX*16 array
55 * On entry, B is an array of dimension ( LDB, M ). On exit, the
56 * leading m by n part of A has been added to the leading n by m
57 * part of B.
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( alpha.EQ.one ) THEN
83  IF( beta.EQ.zero ) THEN
84  DO 20 j = 1, n
85  CALL zcopy( m, a( 1, j ), 1, b( j, 1 ), ldb )
86 * DO 10 I = 1, M
87 * B( J, I ) = A( I, J )
88 * 10 CONTINUE
89  20 CONTINUE
90  ELSE IF( beta.NE.one ) THEN
91  DO 40 j = 1, n
92  DO 30 i = 1, m
93  b( j, i ) = a( i, j ) + beta * b( j, i )
94  30 CONTINUE
95  40 CONTINUE
96  ELSE
97  DO 60 j = 1, n
98  CALL zaxpy( m, one, a( 1, j ), 1, b( j, 1 ), ldb )
99 * DO 50 I = 1, M
100 * B( J, I ) = A( I, J ) + B( J, I )
101 * 50 CONTINUE
102  60 CONTINUE
103  END IF
104  ELSE IF( alpha.NE.zero ) THEN
105  IF( beta.EQ.zero ) THEN
106  DO 80 j = 1, n
107  DO 70 i = 1, m
108  b( j, i ) = alpha * a( i, j )
109  70 CONTINUE
110  80 CONTINUE
111  ELSE IF( beta.NE.one ) THEN
112  DO 100 j = 1, n
113  DO 90 i = 1, m
114  b( j, i ) = alpha * a( i, j ) + beta * b( j, i )
115  90 CONTINUE
116  100 CONTINUE
117  ELSE
118  DO 120 j = 1, n
119  CALL zaxpy( m, alpha, a( 1, j ), 1, b( j, 1 ), ldb )
120 * DO 110 I = 1, M
121 * B( J, I ) = ALPHA * A( I, J ) + B( J, I )
122 * 110 CONTINUE
123  120 CONTINUE
124  END IF
125  ELSE
126  IF( beta.EQ.zero ) THEN
127  DO 140 j = 1, m
128  DO 130 i = 1, n
129  b( i, j ) = zero
130  130 CONTINUE
131  140 CONTINUE
132  ELSE IF( beta.NE.one ) THEN
133  DO 160 j = 1, m
134  CALL zscal( n, beta, b( 1, j ), 1 )
135 * DO 150 I = 1, N
136 * B( I, J ) = BETA * B( I, J )
137 * 150 CONTINUE
138  160 CONTINUE
139  END IF
140  END IF
141  ELSE
142  IF( alpha.EQ.one ) THEN
143  IF( beta.EQ.zero ) THEN
144  DO 180 j = 1, m
145  CALL zcopy( n, a( j, 1 ), lda, b( 1, j ), 1 )
146 * DO 170 I = 1, N
147 * B( I, J ) = A( J, I )
148 * 170 CONTINUE
149  180 CONTINUE
150  ELSE IF( beta.NE.one ) THEN
151  DO 200 j = 1, m
152  DO 190 i = 1, n
153  b( i, j ) = a( j, i ) + beta * b( i, j )
154  190 CONTINUE
155  200 CONTINUE
156  ELSE
157  DO 220 j = 1, m
158  CALL zaxpy( n, one, a( j, 1 ), lda, b( 1, j ), 1 )
159 * DO 210 I = 1, N
160 * B( I, J ) = A( J, I ) + B( I, J )
161 * 210 CONTINUE
162  220 CONTINUE
163  END IF
164  ELSE IF( alpha.NE.zero ) THEN
165  IF( beta.EQ.zero ) THEN
166  DO 240 j = 1, m
167  DO 230 i = 1, n
168  b( i, j ) = alpha * a( j, i )
169  230 CONTINUE
170  240 CONTINUE
171  ELSE IF( beta.NE.one ) THEN
172  DO 260 j = 1, m
173  DO 250 i = 1, n
174  b( i, j ) = alpha * a( j, i ) + beta * b( i, j )
175  250 CONTINUE
176  260 CONTINUE
177  ELSE
178  DO 280 j = 1, m
179  CALL zaxpy( n, alpha, a( j, 1 ), lda, b( 1, j ), 1 )
180 * DO 270 I = 1, N
181 * B( I, J ) = ALPHA * A( J, I ) + B( I, J )
182 * 270 CONTINUE
183  280 CONTINUE
184  END IF
185  ELSE
186  IF( beta.EQ.zero ) THEN
187  DO 300 j = 1, m
188  DO 290 i = 1, n
189  b( i, j ) = zero
190  290 CONTINUE
191  300 CONTINUE
192  ELSE IF( beta.NE.one ) THEN
193  DO 320 j = 1, m
194  CALL zscal( n, beta, b( 1, j ), 1 )
195 * DO 310 I = 1, N
196 * B( I, J ) = BETA * B( I, J )
197 * 310 CONTINUE
198  320 CONTINUE
199  END IF
200  END IF
201  END IF
202 *
203  RETURN
204 *