LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
cspr.f
Go to the documentation of this file.
1*> \brief \b CSPR performs the symmetrical rank-1 update of a complex symmetric packed matrix.
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8*> Download CSPR + dependencies
9*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cspr.f">
10*> [TGZ]</a>
11*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cspr.f">
12*> [ZIP]</a>
13*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cspr.f">
14*> [TXT]</a>
15*
16* Definition:
17* ===========
18*
19* SUBROUTINE CSPR( UPLO, N, ALPHA, X, INCX, AP )
20*
21* .. Scalar Arguments ..
22* CHARACTER UPLO
23* INTEGER INCX, N
24* COMPLEX ALPHA
25* ..
26* .. Array Arguments ..
27* COMPLEX AP( * ), X( * )
28* ..
29*
30*
31*> \par Purpose:
32* =============
33*>
34*> \verbatim
35*>
36*> CSPR performs the symmetric rank 1 operation
37*>
38*> A := alpha*x*x**H + A,
39*>
40*> where alpha is a complex scalar, x is an n element vector and A is an
41*> n by n symmetric matrix, supplied in packed form.
42*> \endverbatim
43*
44* Arguments:
45* ==========
46*
47*> \param[in] UPLO
48*> \verbatim
49*> UPLO is CHARACTER*1
50*> On entry, UPLO specifies whether the upper or lower
51*> triangular part of the matrix A is supplied in the packed
52*> array AP as follows:
53*>
54*> UPLO = 'U' or 'u' The upper triangular part of A is
55*> supplied in AP.
56*>
57*> UPLO = 'L' or 'l' The lower triangular part of A is
58*> supplied in AP.
59*>
60*> Unchanged on exit.
61*> \endverbatim
62*>
63*> \param[in] N
64*> \verbatim
65*> N is INTEGER
66*> On entry, N specifies the order of the matrix A.
67*> N must be at least zero.
68*> Unchanged on exit.
69*> \endverbatim
70*>
71*> \param[in] ALPHA
72*> \verbatim
73*> ALPHA is COMPLEX
74*> On entry, ALPHA specifies the scalar alpha.
75*> Unchanged on exit.
76*> \endverbatim
77*>
78*> \param[in] X
79*> \verbatim
80*> X is COMPLEX array, dimension at least
81*> ( 1 + ( N - 1 )*abs( INCX ) ).
82*> Before entry, the incremented array X must contain the N-
83*> element vector x.
84*> Unchanged on exit.
85*> \endverbatim
86*>
87*> \param[in] INCX
88*> \verbatim
89*> INCX is INTEGER
90*> On entry, INCX specifies the increment for the elements of
91*> X. INCX must not be zero.
92*> Unchanged on exit.
93*> \endverbatim
94*>
95*> \param[in,out] AP
96*> \verbatim
97*> AP is COMPLEX array, dimension at least
98*> ( ( N*( N + 1 ) )/2 ).
99*> Before entry, with UPLO = 'U' or 'u', the array AP must
100*> contain the upper triangular part of the symmetric matrix
101*> packed sequentially, column by column, so that AP( 1 )
102*> contains a( 1, 1 ), AP( 2 ) and AP( 3 ) contain a( 1, 2 )
103*> and a( 2, 2 ) respectively, and so on. On exit, the array
104*> AP is overwritten by the upper triangular part of the
105*> updated matrix.
106*> Before entry, with UPLO = 'L' or 'l', the array AP must
107*> contain the lower triangular part of the symmetric matrix
108*> packed sequentially, column by column, so that AP( 1 )
109*> contains a( 1, 1 ), AP( 2 ) and AP( 3 ) contain a( 2, 1 )
110*> and a( 3, 1 ) respectively, and so on. On exit, the array
111*> AP is overwritten by the lower triangular part of the
112*> updated matrix.
113*> Note that the imaginary parts of the diagonal elements need
114*> not be set, they are assumed to be zero, and on exit they
115*> are set to zero.
116*> \endverbatim
117*
118* Authors:
119* ========
120*
121*> \author Univ. of Tennessee
122*> \author Univ. of California Berkeley
123*> \author Univ. of Colorado Denver
124*> \author NAG Ltd.
125*
126*> \ingroup hpr
127*
128* =====================================================================
129 SUBROUTINE cspr( UPLO, N, ALPHA, X, INCX, AP )
130*
131* -- LAPACK auxiliary routine --
132* -- LAPACK is a software package provided by Univ. of Tennessee, --
133* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
134*
135* .. Scalar Arguments ..
136 CHARACTER UPLO
137 INTEGER INCX, N
138 COMPLEX ALPHA
139* ..
140* .. Array Arguments ..
141 COMPLEX AP( * ), X( * )
142* ..
143*
144* =====================================================================
145*
146* .. Parameters ..
147 COMPLEX ZERO
148 parameter( zero = ( 0.0e+0, 0.0e+0 ) )
149* ..
150* .. Local Scalars ..
151 INTEGER I, INFO, IX, J, JX, K, KK, KX
152 COMPLEX TEMP
153* ..
154* .. External Functions ..
155 LOGICAL LSAME
156 EXTERNAL lsame
157* ..
158* .. External Subroutines ..
159 EXTERNAL xerbla
160* ..
161* .. Executable Statements ..
162*
163* Test the input parameters.
164*
165 info = 0
166 IF( .NOT.lsame( uplo, 'U' ) .AND.
167 $ .NOT.lsame( uplo, 'L' ) ) THEN
168 info = 1
169 ELSE IF( n.LT.0 ) THEN
170 info = 2
171 ELSE IF( incx.EQ.0 ) THEN
172 info = 5
173 END IF
174 IF( info.NE.0 ) THEN
175 CALL xerbla( 'CSPR ', info )
176 RETURN
177 END IF
178*
179* Quick return if possible.
180*
181 IF( ( n.EQ.0 ) .OR. ( alpha.EQ.zero ) )
182 $ RETURN
183*
184* Set the start point in X if the increment is not unity.
185*
186 IF( incx.LE.0 ) THEN
187 kx = 1 - ( n-1 )*incx
188 ELSE IF( incx.NE.1 ) THEN
189 kx = 1
190 END IF
191*
192* Start the operations. In this version the elements of the array AP
193* are accessed sequentially with one pass through AP.
194*
195 kk = 1
196 IF( lsame( uplo, 'U' ) ) THEN
197*
198* Form A when upper triangle is stored in AP.
199*
200 IF( incx.EQ.1 ) THEN
201 DO 20 j = 1, n
202 IF( x( j ).NE.zero ) THEN
203 temp = alpha*x( j )
204 k = kk
205 DO 10 i = 1, j - 1
206 ap( k ) = ap( k ) + x( i )*temp
207 k = k + 1
208 10 CONTINUE
209 ap( kk+j-1 ) = ap( kk+j-1 ) + x( j )*temp
210 ELSE
211 ap( kk+j-1 ) = ap( kk+j-1 )
212 END IF
213 kk = kk + j
214 20 CONTINUE
215 ELSE
216 jx = kx
217 DO 40 j = 1, n
218 IF( x( jx ).NE.zero ) THEN
219 temp = alpha*x( jx )
220 ix = kx
221 DO 30 k = kk, kk + j - 2
222 ap( k ) = ap( k ) + x( ix )*temp
223 ix = ix + incx
224 30 CONTINUE
225 ap( kk+j-1 ) = ap( kk+j-1 ) + x( jx )*temp
226 ELSE
227 ap( kk+j-1 ) = ap( kk+j-1 )
228 END IF
229 jx = jx + incx
230 kk = kk + j
231 40 CONTINUE
232 END IF
233 ELSE
234*
235* Form A when lower triangle is stored in AP.
236*
237 IF( incx.EQ.1 ) THEN
238 DO 60 j = 1, n
239 IF( x( j ).NE.zero ) THEN
240 temp = alpha*x( j )
241 ap( kk ) = ap( kk ) + temp*x( j )
242 k = kk + 1
243 DO 50 i = j + 1, n
244 ap( k ) = ap( k ) + x( i )*temp
245 k = k + 1
246 50 CONTINUE
247 ELSE
248 ap( kk ) = ap( kk )
249 END IF
250 kk = kk + n - j + 1
251 60 CONTINUE
252 ELSE
253 jx = kx
254 DO 80 j = 1, n
255 IF( x( jx ).NE.zero ) THEN
256 temp = alpha*x( jx )
257 ap( kk ) = ap( kk ) + temp*x( jx )
258 ix = jx
259 DO 70 k = kk + 1, kk + n - j
260 ix = ix + incx
261 ap( k ) = ap( k ) + x( ix )*temp
262 70 CONTINUE
263 ELSE
264 ap( kk ) = ap( kk )
265 END IF
266 jx = jx + incx
267 kk = kk + n - j + 1
268 80 CONTINUE
269 END IF
270 END IF
271*
272 RETURN
273*
274* End of CSPR
275*
276 END
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine cspr(uplo, n, alpha, x, incx, ap)
CSPR performs the symmetrical rank-1 update of a complex symmetric packed matrix.
Definition cspr.f:130