142
143
144
145
146
147 IMPLICIT NONE
148
149
150 CHARACTER UPLO
151 INTEGER M, NB, J1, LDA, LDH
152
153
154 INTEGER IPIV( * )
155 COMPLEX A( LDA, * ), H( LDH, * ), WORK( * )
156
157
158
159
160 COMPLEX ZERO, ONE
161 parameter( zero = (0.0e+0, 0.0e+0), one = (1.0e+0, 0.0e+0) )
162
163
164 INTEGER J, K, K1, I1, I2, MJ
165 COMPLEX PIV, ALPHA
166
167
168 LOGICAL LSAME
169 INTEGER ICAMAX, ILAENV
171
172
175
176
177 INTRINSIC real, conjg, max
178
179
180
181 j = 1
182
183
184
185
186 k1 = (2-j1)+1
187
188 IF(
lsame( uplo,
'U' ) )
THEN
189
190
191
192
193
194 10 CONTINUE
195 IF ( j.GT.min(m, nb) )
196 $ GO TO 20
197
198
199
200
201
202
203 k = j1+j-1
204 IF( j.EQ.m ) THEN
205
206
207
208 mj = 1
209 ELSE
210 mj = m-j+1
211 END IF
212
213
214
215
216 IF( k.GT.2 ) THEN
217
218
219
220
221
222
223
224 CALL clacgv( j-k1, a( 1, j ), 1 )
225 CALL cgemv(
'No transpose', mj, j-k1,
226 $ -one, h( j, k1 ), ldh,
227 $ a( 1, j ), 1,
228 $ one, h( j, j ), 1 )
229 CALL clacgv( j-k1, a( 1, j ), 1 )
230 END IF
231
232
233
234 CALL ccopy( mj, h( j, j ), 1, work( 1 ), 1 )
235
236 IF( j.GT.k1 ) THEN
237
238
239
240
241 alpha = -conjg( a( k-1, j ) )
242 CALL caxpy( mj, alpha, a( k-2, j ), lda, work( 1 ), 1 )
243 END IF
244
245
246
247 a( k, j ) = real( work( 1 ) )
248
249 IF( j.LT.m ) THEN
250
251
252
253
254 IF( k.GT.1 ) THEN
255 alpha = -a( k, j )
256 CALL caxpy( m-j, alpha, a( k-1, j+1 ), lda,
257 $ work( 2 ), 1 )
258 ENDIF
259
260
261
262 i2 =
icamax( m-j, work( 2 ), 1 ) + 1
263 piv = work( i2 )
264
265
266
267 IF( (i2.NE.2) .AND. (piv.NE.0) ) THEN
268
269
270
271 i1 = 2
272 work( i2 ) = work( i1 )
273 work( i1 ) = piv
274
275
276
277 i1 = i1+j-1
278 i2 = i2+j-1
279 CALL cswap( i2-i1-1, a( j1+i1-1, i1+1 ), lda,
280 $ a( j1+i1, i2 ), 1 )
281 CALL clacgv( i2-i1, a( j1+i1-1, i1+1 ), lda )
282 CALL clacgv( i2-i1-1, a( j1+i1, i2 ), 1 )
283
284
285
286 IF( i2.LT.m )
287 $
CALL cswap( m-i2, a( j1+i1-1, i2+1 ), lda,
288 $ a( j1+i2-1, i2+1 ), lda )
289
290
291
292 piv = a( i1+j1-1, i1 )
293 a( j1+i1-1, i1 ) = a( j1+i2-1, i2 )
294 a( j1+i2-1, i2 ) = piv
295
296
297
298 CALL cswap( i1-1, h( i1, 1 ), ldh, h( i2, 1 ), ldh )
299 ipiv( i1 ) = i2
300
301 IF( i1.GT.(k1-1) ) THEN
302
303
304
305
306 CALL cswap( i1-k1+1, a( 1, i1 ), 1,
307 $ a( 1, i2 ), 1 )
308 END IF
309 ELSE
310 ipiv( j+1 ) = j+1
311 ENDIF
312
313
314
315 a( k, j+1 ) = work( 2 )
316
317 IF( j.LT.nb ) THEN
318
319
320
321 CALL ccopy( m-j, a( k+1, j+1 ), lda,
322 $ h( j+1, j+1 ), 1 )
323 END IF
324
325
326
327
328 IF( j.LT.(m-1) ) THEN
329 IF( a( k, j+1 ).NE.zero ) THEN
330 alpha = one / a( k, j+1 )
331 CALL ccopy( m-j-1, work( 3 ), 1, a( k, j+2 ), lda )
332 CALL cscal( m-j-1, alpha, a( k, j+2 ), lda )
333 ELSE
334 CALL claset(
'Full', 1, m-j-1, zero, zero,
335 $ a( k, j+2 ), lda)
336 END IF
337 END IF
338 END IF
339 j = j + 1
340 GO TO 10
341 20 CONTINUE
342
343 ELSE
344
345
346
347
348
349 30 CONTINUE
350 IF( j.GT.min( m, nb ) )
351 $ GO TO 40
352
353
354
355
356
357
358 k = j1+j-1
359 IF( j.EQ.m ) THEN
360
361
362
363 mj = 1
364 ELSE
365 mj = m-j+1
366 END IF
367
368
369
370
371 IF( k.GT.2 ) THEN
372
373
374
375
376
377
378
379 CALL clacgv( j-k1, a( j, 1 ), lda )
380 CALL cgemv(
'No transpose', mj, j-k1,
381 $ -one, h( j, k1 ), ldh,
382 $ a( j, 1 ), lda,
383 $ one, h( j, j ), 1 )
384 CALL clacgv( j-k1, a( j, 1 ), lda )
385 END IF
386
387
388
389 CALL ccopy( mj, h( j, j ), 1, work( 1 ), 1 )
390
391 IF( j.GT.k1 ) THEN
392
393
394
395
396 alpha = -conjg( a( j, k-1 ) )
397 CALL caxpy( mj, alpha, a( j, k-2 ), 1, work( 1 ), 1 )
398 END IF
399
400
401
402 a( j, k ) = real( work( 1 ) )
403
404 IF( j.LT.m ) THEN
405
406
407
408
409 IF( k.GT.1 ) THEN
410 alpha = -a( j, k )
411 CALL caxpy( m-j, alpha, a( j+1, k-1 ), 1,
412 $ work( 2 ), 1 )
413 ENDIF
414
415
416
417 i2 =
icamax( m-j, work( 2 ), 1 ) + 1
418 piv = work( i2 )
419
420
421
422 IF( (i2.NE.2) .AND. (piv.NE.0) ) THEN
423
424
425
426 i1 = 2
427 work( i2 ) = work( i1 )
428 work( i1 ) = piv
429
430
431
432 i1 = i1+j-1
433 i2 = i2+j-1
434 CALL cswap( i2-i1-1, a( i1+1, j1+i1-1 ), 1,
435 $ a( i2, j1+i1 ), lda )
436 CALL clacgv( i2-i1, a( i1+1, j1+i1-1 ), 1 )
437 CALL clacgv( i2-i1-1, a( i2, j1+i1 ), lda )
438
439
440
441 IF( i2.LT.m )
442 $
CALL cswap( m-i2, a( i2+1, j1+i1-1 ), 1,
443 $ a( i2+1, j1+i2-1 ), 1 )
444
445
446
447 piv = a( i1, j1+i1-1 )
448 a( i1, j1+i1-1 ) = a( i2, j1+i2-1 )
449 a( i2, j1+i2-1 ) = piv
450
451
452
453 CALL cswap( i1-1, h( i1, 1 ), ldh, h( i2, 1 ), ldh )
454 ipiv( i1 ) = i2
455
456 IF( i1.GT.(k1-1) ) THEN
457
458
459
460
461 CALL cswap( i1-k1+1, a( i1, 1 ), lda,
462 $ a( i2, 1 ), lda )
463 END IF
464 ELSE
465 ipiv( j+1 ) = j+1
466 ENDIF
467
468
469
470 a( j+1, k ) = work( 2 )
471
472 IF( j.LT.nb ) THEN
473
474
475
476 CALL ccopy( m-j, a( j+1, k+1 ), 1,
477 $ h( j+1, j+1 ), 1 )
478 END IF
479
480
481
482
483 IF( j.LT.(m-1) ) THEN
484 IF( a( j+1, k ).NE.zero ) THEN
485 alpha = one / a( j+1, k )
486 CALL ccopy( m-j-1, work( 3 ), 1, a( j+2, k ), 1 )
487 CALL cscal( m-j-1, alpha, a( j+2, k ), 1 )
488 ELSE
489 CALL claset(
'Full', m-j-1, 1, zero, zero,
490 $ a( j+2, k ), lda )
491 END IF
492 END IF
493 END IF
494 j = j + 1
495 GO TO 30
496 40 CONTINUE
497 END IF
498 RETURN
499
500
501
subroutine xerbla(srname, info)
subroutine caxpy(n, ca, cx, incx, cy, incy)
CAXPY
subroutine ccopy(n, cx, incx, cy, incy)
CCOPY
subroutine cgemv(trans, m, n, alpha, a, lda, x, incx, beta, y, incy)
CGEMV
integer function icamax(n, cx, incx)
ICAMAX
integer function ilaenv(ispec, name, opts, n1, n2, n3, n4)
ILAENV
subroutine clacgv(n, x, incx)
CLACGV conjugates a complex vector.
subroutine claset(uplo, m, n, alpha, beta, a, lda)
CLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values.
logical function lsame(ca, cb)
LSAME
subroutine cscal(n, ca, cx, incx)
CSCAL
subroutine cswap(n, cx, incx, cy, incy)
CSWAP