ScaLAPACK 2.1  2.1
ScaLAPACK: Scalable Linear Algebra PACKage
smmcadd.f
Go to the documentation of this file.
1  SUBROUTINE smmcadd( 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  REAL ALPHA, BETA
11 * ..
12 * .. Array Arguments ..
13  REAL A( LDA, * ), B( LDB, * )
14 * ..
15 *
16 * Purpose
17 * =======
18 *
19 * SMMCADD performs the following operation:
20 *
21 * B := alpha * A + beta * B,
22 *
23 * where alpha, beta are scalars and A and B are m by n matrices.
24 *
25 * Arguments
26 * =========
27 *
28 * M (local input) INTEGER
29 * On entry, M specifies the number of rows of A and B. M must
30 * be at least zero.
31 *
32 * N (local input) INTEGER
33 * On entry, N specifies the number of columns of A and B.
34 * N must be at least zero.
35 *
36 * ALPHA (local input) REAL
37 * On entry, ALPHA specifies the scalar alpha. When ALPHA is
38 * supplied as zero then the local entries of the array A need
39 * not be set on input.
40 *
41 * A (local input) REAL array
42 * On entry, A is an array of dimension ( LDA, N ).
43 *
44 * LDA (local input) INTEGER
45 * On entry, LDA specifies the leading dimension of the array A.
46 * LDA must be at least max( 1, M ).
47 *
48 * BETA (local input) REAL
49 * On entry, BETA specifies the scalar beta. When BETA is sup-
50 * plied as zero then the local entries of the array B need not
51 * be set on input.
52 *
53 * B (local input/local output) REAL array
54 * On entry, B is an array of dimension ( LDB, N ). On exit, the
55 * leading m by n part of A has been added to the leading m by n
56 * part of B.
57 *
58 * LDB (local input) INTEGER
59 * On entry, LDB specifies the leading dimension of the array B.
60 * LDB must be at least max( 1, M ).
61 *
62 * -- Written on April 1, 1998 by
63 * Antoine Petitet, University of Tennessee, Knoxville 37996, USA.
64 *
65 * =====================================================================
66 *
67 * .. Parameters ..
68  REAL ONE, ZERO
69  parameter( one = 1.0e+0, zero = 0.0e+0 )
70 * ..
71 * .. Local Scalars ..
72  INTEGER I, J
73 * ..
74 * .. External Subroutines ..
75  EXTERNAL saxpy, scopy, sscal
76 * ..
77 * .. Executable Statements ..
78 *
79  IF( alpha.EQ.one ) THEN
80  IF( beta.EQ.zero ) THEN
81  DO 20 j = 1, n
82  CALL scopy( m, a( 1, j ), 1, b( 1, j ), 1 )
83 * DO 10 I = 1, M
84 * B( I, J ) = A( I, J )
85 * 10 CONTINUE
86  20 CONTINUE
87  ELSE IF( beta.NE.one ) THEN
88  DO 40 j = 1, n
89  DO 30 i = 1, m
90  b( i, j ) = a( i, j ) + beta * b( i, j )
91  30 CONTINUE
92  40 CONTINUE
93  ELSE
94  DO 60 j = 1, n
95  CALL saxpy( m, one, a( 1, j ), 1, b( 1, j ), 1 )
96 * DO 50 I = 1, M
97 * B( I, J ) = A( I, J ) + B( I, J )
98 * 50 CONTINUE
99  60 CONTINUE
100  END IF
101  ELSE IF( alpha.NE.zero ) THEN
102  IF( beta.EQ.zero ) THEN
103  DO 80 j = 1, n
104  DO 70 i = 1, m
105  b( i, j ) = alpha * a( i, j )
106  70 CONTINUE
107  80 CONTINUE
108  ELSE IF( beta.NE.one ) THEN
109  DO 100 j = 1, n
110  DO 90 i = 1, m
111  b( i, j ) = alpha * a( i, j ) + beta * b( i, j )
112  90 CONTINUE
113  100 CONTINUE
114  ELSE
115  DO 120 j = 1, n
116  CALL saxpy( m, alpha, a( 1, j ), 1, b( 1, j ), 1 )
117 * DO 110 I = 1, M
118 * B( I, J ) = ALPHA * A( I, J ) + B( I, J )
119 * 110 CONTINUE
120  120 CONTINUE
121  END IF
122  ELSE
123  IF( beta.EQ.zero ) THEN
124  DO 140 j = 1, n
125  DO 130 i = 1, m
126  b( i, j ) = zero
127  130 CONTINUE
128  140 CONTINUE
129  ELSE IF( beta.NE.one ) THEN
130  DO 160 j = 1, n
131  CALL sscal( m, beta, b( 1, j ), 1 )
132 * DO 150 I = 1, M
133 * B( I, J ) = BETA * B( I, J )
134 * 150 CONTINUE
135  160 CONTINUE
136  END IF
137  END IF
138 *
139  RETURN
140 *
141 * End of SMMCADD
142 *
143  END
smmcadd
subroutine smmcadd(M, N, ALPHA, A, LDA, BETA, B, LDB)
Definition: smmcadd.f:2