ScaLAPACK 2.1  2.1
ScaLAPACK: Scalable Linear Algebra PACKage
dmatadd.f
Go to the documentation of this file.
1  SUBROUTINE dmatadd( M, N, ALPHA, A, LDA, BETA, C, LDC )
2 *
3 * -- ScaLAPACK tools routine (version 1.7) --
4 * University of Tennessee, Knoxville, Oak Ridge National Laboratory,
5 * and University of California, Berkeley.
6 * May 1, 1997
7 *
8 * .. Scalar Arguments ..
9  INTEGER LDA, LDC, M, N
10  DOUBLE PRECISION ALPHA, BETA
11 * ..
12 * .. Array Arguments ..
13  DOUBLE PRECISION A( LDA, * ), C( LDC, * )
14 * ..
15 *
16 * Purpose
17 * =======
18 *
19 * DMATADD performs the following local matrix-matrix operation
20 *
21 * C := alpha * A + beta * C,
22 *
23 * where alpha and beta are scalars, and A and C are m by n arrays.
24 *
25 * Arguments
26 * =========
27 *
28 * M (local input) INTEGER
29 * The number of rows of the array A. M >= 0.
30 *
31 * N (local input) INTEGER
32 * The number of columns of the array A. N >= 0.
33 *
34 * ALPHA (local input) DOUBLE PRECISION
35 * The scalar ALPHA.
36 *
37 * A (local input) DOUBLE PRECISION
38 * Array, dimension (LDA,*), the array A.
39 *
40 * LDA (local input) INTEGER
41 * The leading dimension of the array A, LDA >= MAX(1, M)
42 *
43 * BETA (local input) DOUBLE PRECISION
44 * The scalar BETA.
45 *
46 * C (local input/local output) DOUBLE PRECISION
47 * Array, dimension (LDC,*), the array C.
48 *
49 * LDC (local input) INTEGER
50 * The leading dimension of the array C, LDC >= MAX(1, M)
51 *
52 * =====================================================================
53 *
54 * .. Parameters ..
55  DOUBLE PRECISION ZERO, ONE
56  parameter( zero = 0.0d+0, one = 1.0d+0 )
57 * ..
58 * .. Local Scalars ..
59  INTEGER I, J
60 * ..
61 * .. Executable Statements ..
62 *
63 * Quick return if possible.
64 *
65  IF( (m.EQ.0).OR.(n.EQ.0).OR.((alpha.EQ.zero).AND.(beta.EQ.one)) )
66  $ RETURN
67 *
68  IF( n.EQ.1 ) THEN
69  IF( beta.EQ.zero ) THEN
70  IF( alpha.EQ.zero ) THEN
71  DO 10 i = 1, m
72  c( i, 1 ) = zero
73  10 CONTINUE
74  ELSE
75  DO 20 i = 1, m
76  c( i, 1 ) = alpha*a( i, 1 )
77  20 CONTINUE
78  END IF
79  ELSE
80  IF( alpha.EQ.one ) THEN
81  IF( beta.EQ.one ) THEN
82  DO 30 i = 1, m
83  c( i, 1 ) = a( i, 1 ) + c( i, 1 )
84  30 CONTINUE
85  ELSE
86  DO 40 i = 1, m
87  c( i, 1 ) = a( i, 1 ) + beta*c( i, 1 )
88  40 CONTINUE
89  END IF
90  ELSE IF( beta.EQ.one ) THEN
91  DO 50 i = 1, m
92  c( i, 1 ) = alpha*a( i, 1 ) + c( i, 1 )
93  50 CONTINUE
94  ELSE
95  DO 60 i = 1, m
96  c( i, 1 ) = alpha*a( i, 1 ) + beta*c( i, 1 )
97  60 CONTINUE
98  END IF
99  END IF
100  ELSE
101  IF( beta.EQ.zero ) THEN
102  IF( alpha.EQ.zero ) THEN
103  DO 80 j = 1, n
104  DO 70 i = 1, m
105  c( i, j ) = zero
106  70 CONTINUE
107  80 CONTINUE
108  ELSE
109  DO 100 j = 1, n
110  DO 90 i = 1, m
111  c( i, j ) = alpha * a( i, j )
112  90 CONTINUE
113  100 CONTINUE
114  END IF
115  ELSE
116  IF( alpha.EQ.one ) THEN
117  IF( beta.EQ.one ) THEN
118  DO 120 j = 1, n
119  DO 110 i = 1, m
120  c( i, j ) = a( i, j ) + c( i, j )
121  110 CONTINUE
122  120 CONTINUE
123  ELSE
124  DO 140 j = 1, n
125  DO 130 i = 1, m
126  c( i, j ) = a( i, j ) + beta * c( i, j )
127  130 CONTINUE
128  140 CONTINUE
129  END IF
130  ELSE IF( beta.EQ.one ) THEN
131  DO 160 j = 1, n
132  DO 150 i = 1, m
133  c( i, j ) = c( i, j ) + alpha * a( i, j )
134  150 CONTINUE
135  160 CONTINUE
136  ELSE
137  DO 180 j = 1, n
138  DO 170 i = 1, m
139  c( i, j ) = alpha * a( i, j ) + beta * c( i, j )
140  170 CONTINUE
141  180 CONTINUE
142  END IF
143  END IF
144  END IF
145 *
146  RETURN
147 *
148 * End of DMATADD
149 *
150  END
dmatadd
subroutine dmatadd(M, N, ALPHA, A, LDA, BETA, C, LDC)
Definition: dmatadd.f:2