PLASMA  2.4.5
PLASMA - Parallel Linear Algebra for Scalable Multi-core Architectures
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
csymv.f
Go to the documentation of this file.
1  SUBROUTINE csymv( UPLO, N, ALPHA, A, LDA, X, INCX, BETA, Y, INCY )
2 *
3 * -- LAPACK auxiliary routine (version 3.2) --
4 * -- LAPACK is a software package provided by Univ. of Tennessee, --
5 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
6 * November 2006
7 *
8 * .. Scalar Arguments ..
9  CHARACTER uplo
10  INTEGER incx, incy, lda, n
11  COMPLEX alpha, beta
12 * ..
13 * .. Array Arguments ..
14  COMPLEX a( lda, * ), x( * ), y( * )
15 * ..
16 *
17 * Purpose
18 * =======
19 *
20 * CSYMV performs the matrix-vector operation
21 *
22 * y := alpha*A*x + beta*y,
23 *
24 * where alpha and beta are scalars, x and y are n element vectors and
25 * A is an n by n symmetric matrix.
26 *
27 * Arguments
28 * ==========
29 *
30 * UPLO (input) CHARACTER*1
31 * On entry, UPLO specifies whether the upper or lower
32 * triangular part of the array A is to be referenced as
33 * follows:
34 *
35 * UPLO = 'U' or 'u' Only the upper triangular part of A
36 * is to be referenced.
37 *
38 * UPLO = 'L' or 'l' Only the lower triangular part of A
39 * is to be referenced.
40 *
41 * Unchanged on exit.
42 *
43 * N (input) INTEGER
44 * On entry, N specifies the order of the matrix A.
45 * N must be at least zero.
46 * Unchanged on exit.
47 *
48 * ALPHA (input) COMPLEX
49 * On entry, ALPHA specifies the scalar alpha.
50 * Unchanged on exit.
51 *
52 * A (input) COMPLEX array, dimension ( LDA, N )
53 * Before entry, with UPLO = 'U' or 'u', the leading n by n
54 * upper triangular part of the array A must contain the upper
55 * triangular part of the symmetric matrix and the strictly
56 * lower triangular part of A is not referenced.
57 * Before entry, with UPLO = 'L' or 'l', the leading n by n
58 * lower triangular part of the array A must contain the lower
59 * triangular part of the symmetric matrix and the strictly
60 * upper triangular part of A is not referenced.
61 * Unchanged on exit.
62 *
63 * LDA (input) INTEGER
64 * On entry, LDA specifies the first dimension of A as declared
65 * in the calling (sub) program. LDA must be at least
66 * max( 1, N ).
67 * Unchanged on exit.
68 *
69 * X (input) COMPLEX array, dimension at least
70 * ( 1 + ( N - 1 )*abs( INCX ) ).
71 * Before entry, the incremented array X must contain the N-
72 * element vector x.
73 * Unchanged on exit.
74 *
75 * INCX (input) INTEGER
76 * On entry, INCX specifies the increment for the elements of
77 * X. INCX must not be zero.
78 * Unchanged on exit.
79 *
80 * BETA (input) COMPLEX
81 * On entry, BETA specifies the scalar beta. When BETA is
82 * supplied as zero then Y need not be set on input.
83 * Unchanged on exit.
84 *
85 * Y (input/output) COMPLEX array, dimension at least
86 * ( 1 + ( N - 1 )*abs( INCY ) ).
87 * Before entry, the incremented array Y must contain the n
88 * element vector y. On exit, Y is overwritten by the updated
89 * vector y.
90 *
91 * INCY (input) INTEGER
92 * On entry, INCY specifies the increment for the elements of
93 * Y. INCY must not be zero.
94 * Unchanged on exit.
95 *
96 * =====================================================================
97 *
98 * .. Parameters ..
99  COMPLEX one
100  parameter( one = ( 1.0e+0, 0.0e+0 ) )
101  COMPLEX zero
102  parameter( zero = ( 0.0e+0, 0.0e+0 ) )
103 * ..
104 * .. Local Scalars ..
105  INTEGER i, info, ix, iy, j, jx, jy, kx, ky
106  COMPLEX temp1, temp2
107 * ..
108 * .. External Functions ..
109  LOGICAL lsame
110  EXTERNAL lsame
111 * ..
112 * .. External Subroutines ..
113  EXTERNAL xerbla
114 * ..
115 * .. Intrinsic Functions ..
116  INTRINSIC max
117 * ..
118 * .. Executable Statements ..
119 *
120 * Test the input parameters.
121 *
122  info = 0
123  IF( .NOT.lsame( uplo, 'U' ) .AND. .NOT.lsame( uplo, 'L' ) ) THEN
124  info = 1
125  ELSE IF( n.LT.0 ) THEN
126  info = 2
127  ELSE IF( lda.LT.max( 1, n ) ) THEN
128  info = 5
129  ELSE IF( incx.EQ.0 ) THEN
130  info = 7
131  ELSE IF( incy.EQ.0 ) THEN
132  info = 10
133  END IF
134  IF( info.NE.0 ) THEN
135  CALL xerbla( 'CSYMV ', info )
136  return
137  END IF
138 *
139 * Quick return if possible.
140 *
141  IF( ( n.EQ.0 ) .OR. ( ( alpha.EQ.zero ) .AND. ( beta.EQ.one ) ) )
142  $ return
143 *
144 * Set up the start points in X and Y.
145 *
146  IF( incx.GT.0 ) THEN
147  kx = 1
148  ELSE
149  kx = 1 - ( n-1 )*incx
150  END IF
151  IF( incy.GT.0 ) THEN
152  ky = 1
153  ELSE
154  ky = 1 - ( n-1 )*incy
155  END IF
156 *
157 * Start the operations. In this version the elements of A are
158 * accessed sequentially with one pass through the triangular part
159 * of A.
160 *
161 * First form y := beta*y.
162 *
163  IF( beta.NE.one ) THEN
164  IF( incy.EQ.1 ) THEN
165  IF( beta.EQ.zero ) THEN
166  DO 10 i = 1, n
167  y( i ) = zero
168  10 continue
169  ELSE
170  DO 20 i = 1, n
171  y( i ) = beta*y( i )
172  20 continue
173  END IF
174  ELSE
175  iy = ky
176  IF( beta.EQ.zero ) THEN
177  DO 30 i = 1, n
178  y( iy ) = zero
179  iy = iy + incy
180  30 continue
181  ELSE
182  DO 40 i = 1, n
183  y( iy ) = beta*y( iy )
184  iy = iy + incy
185  40 continue
186  END IF
187  END IF
188  END IF
189  IF( alpha.EQ.zero )
190  $ return
191  IF( lsame( uplo, 'U' ) ) THEN
192 *
193 * Form y when A is stored in upper triangle.
194 *
195  IF( ( incx.EQ.1 ) .AND. ( incy.EQ.1 ) ) THEN
196  DO 60 j = 1, n
197  temp1 = alpha*x( j )
198  temp2 = zero
199  DO 50 i = 1, j - 1
200  y( i ) = y( i ) + temp1*a( i, j )
201  temp2 = temp2 + a( i, j )*x( i )
202  50 continue
203  y( j ) = y( j ) + temp1*a( j, j ) + alpha*temp2
204  60 continue
205  ELSE
206  jx = kx
207  jy = ky
208  DO 80 j = 1, n
209  temp1 = alpha*x( jx )
210  temp2 = zero
211  ix = kx
212  iy = ky
213  DO 70 i = 1, j - 1
214  y( iy ) = y( iy ) + temp1*a( i, j )
215  temp2 = temp2 + a( i, j )*x( ix )
216  ix = ix + incx
217  iy = iy + incy
218  70 continue
219  y( jy ) = y( jy ) + temp1*a( j, j ) + alpha*temp2
220  jx = jx + incx
221  jy = jy + incy
222  80 continue
223  END IF
224  ELSE
225 *
226 * Form y when A is stored in lower triangle.
227 *
228  IF( ( incx.EQ.1 ) .AND. ( incy.EQ.1 ) ) THEN
229  DO 100 j = 1, n
230  temp1 = alpha*x( j )
231  temp2 = zero
232  y( j ) = y( j ) + temp1*a( j, j )
233  DO 90 i = j + 1, n
234  y( i ) = y( i ) + temp1*a( i, j )
235  temp2 = temp2 + a( i, j )*x( i )
236  90 continue
237  y( j ) = y( j ) + alpha*temp2
238  100 continue
239  ELSE
240  jx = kx
241  jy = ky
242  DO 120 j = 1, n
243  temp1 = alpha*x( jx )
244  temp2 = zero
245  y( jy ) = y( jy ) + temp1*a( j, j )
246  ix = jx
247  iy = jy
248  DO 110 i = j + 1, n
249  ix = ix + incx
250  iy = iy + incy
251  y( iy ) = y( iy ) + temp1*a( i, j )
252  temp2 = temp2 + a( i, j )*x( ix )
253  110 continue
254  y( jy ) = y( jy ) + alpha*temp2
255  jx = jx + incx
256  jy = jy + incy
257  120 continue
258  END IF
259  END IF
260 *
261  return
262 *
263 * End of CSYMV
264 *
265  END