102
103
104
105
106
107
108 INTEGER INFO, K, LDA, N
109
110
111 INTEGER ISEED( 4 )
112 DOUBLE PRECISION D( * )
113 COMPLEX*16 A( LDA, * ), WORK( * )
114
115
116
117
118
119 COMPLEX*16 ZERO, ONE, HALF
120 parameter( zero = ( 0.0d+0, 0.0d+0 ),
121 $ one = ( 1.0d+0, 0.0d+0 ),
122 $ half = ( 0.5d+0, 0.0d+0 ) )
123
124
125 INTEGER I, II, J, JJ
126 DOUBLE PRECISION WN
127 COMPLEX*16 ALPHA, TAU, WA, WB
128
129
132
133
134 DOUBLE PRECISION DZNRM2
135 COMPLEX*16 ZDOTC
137
138
139 INTRINSIC abs, dble, max
140
141
142
143
144
145 info = 0
146 IF( n.LT.0 ) THEN
147 info = -1
148 ELSE IF( k.LT.0 .OR. k.GT.n-1 ) THEN
149 info = -2
150 ELSE IF( lda.LT.max( 1, n ) ) THEN
151 info = -5
152 END IF
153 IF( info.LT.0 ) THEN
154 CALL xerbla(
'ZLAGSY', -info )
155 RETURN
156 END IF
157
158
159
160 DO 20 j = 1, n
161 DO 10 i = j + 1, n
162 a( i, j ) = zero
163 10 CONTINUE
164 20 CONTINUE
165 DO 30 i = 1, n
166 a( i, i ) = d( i )
167 30 CONTINUE
168
169
170
171 DO 60 i = n - 1, 1, -1
172
173
174
175 CALL zlarnv( 3, iseed, n-i+1, work )
176 wn =
dznrm2( n-i+1, work, 1 )
177 wa = ( wn / abs( work( 1 ) ) )*work( 1 )
178 IF( wn.EQ.zero ) THEN
179 tau = zero
180 ELSE
181 wb = work( 1 ) + wa
182 CALL zscal( n-i, one / wb, work( 2 ), 1 )
183 work( 1 ) = one
184 tau = dble( wb / wa )
185 END IF
186
187
188
189
190
191
192 CALL zlacgv( n-i+1, work, 1 )
193 CALL zsymv(
'Lower', n-i+1, tau, a( i, i ), lda, work, 1, zero,
194 $ work( n+1 ), 1 )
195 CALL zlacgv( n-i+1, work, 1 )
196
197
198
199 alpha = -half*tau*
zdotc( n-i+1, work, 1, work( n+1 ), 1 )
200 CALL zaxpy( n-i+1, alpha, work, 1, work( n+1 ), 1 )
201
202
203
204
205
206
207 DO 50 jj = i, n
208 DO 40 ii = jj, n
209 a( ii, jj ) = a( ii, jj ) -
210 $ work( ii-i+1 )*work( n+jj-i+1 ) -
211 $ work( n+ii-i+1 )*work( jj-i+1 )
212 40 CONTINUE
213 50 CONTINUE
214 60 CONTINUE
215
216
217
218 DO 100 i = 1, n - 1 - k
219
220
221
222 wn =
dznrm2( n-k-i+1, a( k+i, i ), 1 )
223 wa = ( wn / abs( a( k+i, i ) ) )*a( k+i, i )
224 IF( wn.EQ.zero ) THEN
225 tau = zero
226 ELSE
227 wb = a( k+i, i ) + wa
228 CALL zscal( n-k-i, one / wb, a( k+i+1, i ), 1 )
229 a( k+i, i ) = one
230 tau = dble( wb / wa )
231 END IF
232
233
234
235 CALL zgemv(
'Conjugate transpose', n-k-i+1, k-1, one,
236 $ a( k+i, i+1 ), lda, a( k+i, i ), 1, zero, work, 1 )
237 CALL zgerc( n-k-i+1, k-1, -tau, a( k+i, i ), 1, work, 1,
238 $ a( k+i, i+1 ), lda )
239
240
241
242
243
244 CALL zlacgv( n-k-i+1, a( k+i, i ), 1 )
245 CALL zsymv(
'Lower', n-k-i+1, tau, a( k+i, k+i ), lda,
246 $ a( k+i, i ), 1, zero, work, 1 )
247 CALL zlacgv( n-k-i+1, a( k+i, i ), 1 )
248
249
250
251 alpha = -half*tau*
zdotc( n-k-i+1, a( k+i, i ), 1, work, 1 )
252 CALL zaxpy( n-k-i+1, alpha, a( k+i, i ), 1, work, 1 )
253
254
255
256
257
258
259 DO 80 jj = k + i, n
260 DO 70 ii = jj, n
261 a( ii, jj ) = a( ii, jj ) - a( ii, i )*work( jj-k-i+1 ) -
262 $ work( ii-k-i+1 )*a( jj, i )
263 70 CONTINUE
264 80 CONTINUE
265
266 a( k+i, i ) = -wa
267 DO 90 j = k + i + 1, n
268 a( j, i ) = zero
269 90 CONTINUE
270 100 CONTINUE
271
272
273
274 DO 120 j = 1, n
275 DO 110 i = j + 1, n
276 a( j, i ) = a( i, j )
277 110 CONTINUE
278 120 CONTINUE
279 RETURN
280
281
282
subroutine xerbla(srname, info)
subroutine zaxpy(n, za, zx, incx, zy, incy)
ZAXPY
complex *16 function zdotc(n, zx, incx, zy, incy)
ZDOTC
subroutine zgemv(trans, m, n, alpha, a, lda, x, incx, beta, y, incy)
ZGEMV
subroutine zgerc(m, n, alpha, x, incx, y, incy, a, lda)
ZGERC
subroutine zsymv(uplo, n, alpha, a, lda, x, incx, beta, y, incy)
ZSYMV computes a matrix-vector product for a complex symmetric matrix.
subroutine zlacgv(n, x, incx)
ZLACGV conjugates a complex vector.
subroutine zlarnv(idist, iseed, n, x)
ZLARNV returns a vector of random numbers from a uniform or normal distribution.
real(wp) function dznrm2(n, x, incx)
DZNRM2
subroutine zscal(n, za, zx, incx)
ZSCAL