ScaLAPACK 2.1  2.1 ScaLAPACK: Scalable Linear Algebra PACKage
Go to the documentation of this file.
1  SUBROUTINE zmatadd( 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  COMPLEX*16 ALPHA, BETA
11 * ..
12 * .. Array Arguments ..
13  COMPLEX*16 A( LDA, * ), C( LDC, * )
14 * ..
15 *
16 * Purpose
17 * =======
18 *
19 * ZMATADD 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) COMPLEX*16
35 * The scalar ALPHA.
36 *
37 * A (local input) COMPLEX*16
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) COMPLEX*16
44 * The scalar BETA.
45 *
46 * C (local input/local output) COMPLEX*16
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  COMPLEX*16 ZERO, ONE
56  parameter( zero = ( 0.0d+0, 0.0d+0 ),
57  \$ one = ( 1.0d+0, 0.0d+0 ) )
58 * ..
59 * .. Local Scalars ..
60  INTEGER I, J
61 * ..
62 * .. Executable Statements ..
63 *
64 * Quick return if possible.
65 *
66  IF( (m.EQ.0).OR.(n.EQ.0).OR.((alpha.EQ.zero).AND.(beta.EQ.one)) )
67  \$ RETURN
68 *
69  IF( n.EQ.1 ) THEN
70  IF( beta.EQ.zero ) THEN
71  IF( alpha.EQ.zero ) THEN
72  DO 10 i = 1, m
73  c( i, 1 ) = zero
74  10 CONTINUE
75  ELSE
76  DO 20 i = 1, m
77  c( i, 1 ) = alpha*a( i, 1 )
78  20 CONTINUE
79  END IF
80  ELSE
81  IF( alpha.EQ.one ) THEN
82  IF( beta.EQ.one ) THEN
83  DO 30 i = 1, m
84  c( i, 1 ) = a( i, 1 ) + c( i, 1 )
85  30 CONTINUE
86  ELSE
87  DO 40 i = 1, m
88  c( i, 1 ) = a( i, 1 ) + beta*c( i, 1 )
89  40 CONTINUE
90  END IF
91  ELSE IF( beta.EQ.one ) THEN
92  DO 50 i = 1, m
93  c( i, 1 ) = alpha*a( i, 1 ) + c( i, 1 )
94  50 CONTINUE
95  ELSE
96  DO 60 i = 1, m
97  c( i, 1 ) = alpha*a( i, 1 ) + beta*c( i, 1 )
98  60 CONTINUE
99  END IF
100  END IF
101  ELSE
102  IF( beta.EQ.zero ) THEN
103  IF( alpha.EQ.zero ) THEN
104  DO 80 j = 1, n
105  DO 70 i = 1, m
106  c( i, j ) = zero
107  70 CONTINUE
108  80 CONTINUE
109  ELSE
110  DO 100 j = 1, n
111  DO 90 i = 1, m
112  c( i, j ) = alpha * a( i, j )
113  90 CONTINUE
114  100 CONTINUE
115  END IF
116  ELSE
117  IF( alpha.EQ.one ) THEN
118  IF( beta.EQ.one ) THEN
119  DO 120 j = 1, n
120  DO 110 i = 1, m
121  c( i, j ) = a( i, j ) + c( i, j )
122  110 CONTINUE
123  120 CONTINUE
124  ELSE
125  DO 140 j = 1, n
126  DO 130 i = 1, m
127  c( i, j ) = a( i, j ) + beta * c( i, j )
128  130 CONTINUE
129  140 CONTINUE
130  END IF
131  ELSE IF( beta.EQ.one ) THEN
132  DO 160 j = 1, n
133  DO 150 i = 1, m
134  c( i, j ) = c( i, j ) + alpha * a( i, j )
135  150 CONTINUE
136  160 CONTINUE
137  ELSE
138  DO 180 j = 1, n
139  DO 170 i = 1, m
140  c( i, j ) = alpha * a( i, j ) + beta * c( i, j )
141  170 CONTINUE
142  180 CONTINUE
143  END IF
144  END IF
145  END IF
146 *
147  RETURN
148 *