ScaLAPACK 2.1  2.1
ScaLAPACK: Scalable Linear Algebra PACKage
pbdvecadd.f
Go to the documentation of this file.
1  SUBROUTINE pbdvecadd( ICONTXT, MODE, N, ALPHA, X, INCX, BETA, Y,
2  $ INCY )
3 *
4 * -- PB-BLAS routine (version 2.1) --
5 * University of Tennessee, Knoxville, Oak Ridge National Laboratory.
6 * April 28, 1996
7 *
8 * .. Scalar Arguments ..
9  CHARACTER*1 MODE
10  INTEGER ICONTXT, INCX, INCY, N
11  DOUBLE PRECISION ALPHA, BETA
12 * ..
13 * .. Array Arguments ..
14  DOUBLE PRECISION X( * ), Y( * )
15 *
16 * ..
17 *
18 * Purpose
19 * =======
20 *
21 * PBDVECADD performs a vector X to be added to Y
22 * Y := alpha*op(X) + beta*Y,
23 * where alpha and beta are scalars, and X and Y are n vectors,
24 * and op(X) = X**H if MODE = 'C',
25 *
26 * Arguments
27 * =========
28 *
29 * ICONTXT (input) INTEGER
30 * ICONTXT is the BLACS mechanism for partitioning communication
31 * space. A defining property of a context is that a message in
32 * a context cannot be sent or received in another context. The
33 * BLACS context includes the definition of a grid, and each
34 * process' coordinates in it.
35 *
36 * MODE (input) CHARACTER*1
37 * Specifies the transposed, or conjugate transposed vector X
38 * to be added to the vector Y
39 * = 'C': Conjugate vector X is added for complex data set.
40 * Y = alpha * X**H + beta * Y
41 * ELSE : Vector X is added. Y = alpha*X + beta*Y
42 * if MODE = 'V', BLAS routine may be used.
43 *
44 * N (input) INTEGER
45 * The number of elements of the vectors X and Y to be added.
46 * N >= 0.
47 *
48 * ALPHA (input) DOUBLE PRECISION
49 * ALPHA specifies the scalar alpha.
50 *
51 * X (input) DOUBLE PRECISION array of DIMENSION at least
52 * ( 1 + ( N - 1 )*abs( INCX ) )
53 * The incremented array X must contain the vector X.
54 *
55 * INCX (input) INTEGER
56 * INCX specifies the increment for the elements of X.
57 * INCX <> 0.
58 *
59 * BETA (input) DOUBLE PRECISION
60 * BETA specifies the scalar beta.
61 *
62 * Y (input/output) DOUBLE PRECISION array of DIMENSION at least
63 * ( 1 + ( N - 1 )*abs( INCY ) )
64 * On entry with BETA non-zero, the incremented array Y must
65 * contain the vector Y.
66 * On exit, Y is overwritten by the updated vector Y.
67 *
68 * INCY - (input) INTEGER
69 * INCY specifies the increment for the elements of Y.
70 * INCY <> 0.
71 *
72 * =====================================================================
73 *
74 * ..
75 * .. Parameters ..
76  DOUBLE PRECISION ZERO, ONE
77  parameter( zero = 0.0d+0, one = 1.0d+0)
78 * ..
79 * .. Local Scalars ..
80  INTEGER I, IX, IY
81 * ..
82 * .. External Functions ..
83  LOGICAL LSAME
84  EXTERNAL lsame
85 * ..
86 * .. External Subroutines ..
87  EXTERNAL dscal, dcopy, daxpy
88 * ..
89 * .. Executable Statements ..
90 *
91  IF( n.LE.0 .OR. ( alpha.EQ.zero .AND. beta.EQ.one ) ) RETURN
92 *
93  IF( alpha.EQ.zero ) THEN
94  IF( beta.EQ.zero ) THEN
95  IF( incy.EQ.1 ) THEN
96  DO 10 i = 1, n
97  y( i ) = zero
98  10 CONTINUE
99  ELSE
100  iy = 1
101  DO 20 i = 1, n
102  y( iy ) = zero
103  iy = iy + incy
104  20 CONTINUE
105  END IF
106 *
107  ELSE
108  IF( lsame( mode, 'V' ) ) THEN
109  CALL dscal( n, beta, y, incy )
110  ELSE IF( incy.EQ.1 ) THEN
111  DO 30 i = 1, n
112  y( i ) = beta * y( i )
113  30 CONTINUE
114  ELSE
115  iy = 1
116  DO 40 i = 1, n
117  y( iy ) = beta * y( iy )
118  iy = iy + incy
119  40 CONTINUE
120  END IF
121  END IF
122 *
123  ELSE
124  IF( alpha.EQ.one ) THEN
125  IF( beta.EQ.zero ) THEN
126  IF( lsame( mode, 'V' ) ) THEN
127  CALL dcopy( n, x, incx, y, incy )
128  ELSE IF( incx.EQ.1 .AND. incy.EQ.1 ) THEN
129  DO 50 i = 1, n
130  y( i ) = x( i )
131  50 CONTINUE
132  ELSE
133  ix = 1
134  iy = 1
135  DO 60 i = 1, n
136  y( iy ) = x( ix )
137  ix = ix + incx
138  iy = iy + incy
139  60 CONTINUE
140  END IF
141 *
142  ELSE IF( beta.EQ.one ) THEN
143  IF( incx.EQ.1 .AND. incy.EQ.1 ) THEN
144  DO 70 i = 1, n
145  y( i ) = x( i ) + y( i )
146  70 CONTINUE
147  ELSE
148  ix = 1
149  iy = 1
150  DO 80 i = 1, n
151  y( iy ) = x( ix ) + y( iy )
152  ix = ix + incx
153  iy = iy + incy
154  80 CONTINUE
155  END IF
156 *
157  ELSE
158  IF( incx.EQ.1 .AND. incy.EQ.1 ) THEN
159  DO 90 i = 1, n
160  y( i ) = x( i ) + beta * y( i )
161  90 CONTINUE
162  ELSE
163  ix = 1
164  iy = 1
165  DO 100 i = 1, n
166  y( iy ) = x( ix ) + beta * y( iy )
167  ix = ix + incx
168  iy = iy + incy
169  100 CONTINUE
170  END IF
171  END IF
172 *
173  ELSE
174  IF( beta.EQ.zero ) THEN
175  IF( incx.EQ.1 .AND. incy.EQ.1 ) THEN
176  DO 110 i = 1, n
177  y( i ) = alpha * x( i )
178  110 CONTINUE
179  ELSE
180  ix = 1
181  iy = 1
182  DO 120 i = 1, n
183  y( iy ) = x( ix )
184  ix = ix + incx
185  iy = iy + incy
186  120 CONTINUE
187  END IF
188 *
189  ELSE IF( beta.EQ.one ) THEN
190  IF( lsame( mode, 'V' ) ) THEN
191  CALL daxpy( n, alpha, x, incx, y, incy )
192  ELSE IF( incx.EQ.1 .AND. incy.EQ.1 ) THEN
193  DO 130 i = 1, n
194  y( i ) = alpha * x( i ) + y( i )
195  130 CONTINUE
196  ELSE
197  ix = 1
198  iy = 1
199  DO 140 i = 1, n
200  y( iy ) = alpha * x( ix ) + y( iy )
201  ix = ix + incx
202  iy = iy + incy
203  140 CONTINUE
204  END IF
205 *
206  ELSE
207  IF( incx.EQ.1 .AND. incy.EQ.1 ) THEN
208  DO 150 i = 1, n
209  y( i ) = alpha * x( i ) + beta * y( i )
210  150 CONTINUE
211  ELSE
212  ix = 1
213  iy = 1
214  DO 160 i = 1, n
215  y( iy ) = alpha * x( ix ) + beta * y( iy )
216  ix = ix + incx
217  iy = iy + incy
218  160 CONTINUE
219  END IF
220  END IF
221  END IF
222  END IF
223 *
224  RETURN
225 *
226 * End of PBDVECADD
227 *
228  END
pbdvecadd
subroutine pbdvecadd(ICONTXT, MODE, N, ALPHA, X, INCX, BETA, Y, INCY)
Definition: pbdvecadd.f:3