144
145
146
147
148
149 IMPLICIT NONE
150
151
152 CHARACTER UPLO
153 INTEGER M, NB, J1, LDA, LDH
154
155
156 INTEGER IPIV( * )
157 COMPLEX A( LDA, * ), H( LDH, * ), WORK( * )
158
159
160
161
162 COMPLEX ZERO, ONE
163 parameter( zero = 0.0e+0, one = 1.0e+0 )
164
165
166 INTEGER J, K, K1, I1, I2, MJ
167 COMPLEX PIV, ALPHA
168
169
170 LOGICAL LSAME
171 INTEGER ICAMAX, ILAENV
173
174
177
178
179 INTRINSIC max
180
181
182
183 j = 1
184
185
186
187
188 k1 = (2-j1)+1
189
190 IF(
lsame( uplo,
'U' ) )
THEN
191
192
193
194
195
196 10 CONTINUE
197 IF ( j.GT.min(m, nb) )
198 $ GO TO 20
199
200
201
202
203
204
205 k = j1+j-1
206 IF( j.EQ.m ) THEN
207
208
209
210 mj = 1
211 ELSE
212 mj = m-j+1
213 END IF
214
215
216
217
218 IF( k.GT.2 ) THEN
219
220
221
222
223
224
225
226 CALL cgemv(
'No transpose', mj, j-k1,
227 $ -one, h( j, k1 ), ldh,
228 $ a( 1, j ), 1,
229 $ one, h( j, 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 = -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 ) = 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
282
283
284 IF( i2.LT.m )
285 $
CALL cswap( m-i2, a( j1+i1-1, i2+1 ), lda,
286 $ a( j1+i2-1, i2+1 ), lda )
287
288
289
290 piv = a( i1+j1-1, i1 )
291 a( j1+i1-1, i1 ) = a( j1+i2-1, i2 )
292 a( j1+i2-1, i2 ) = piv
293
294
295
296 CALL cswap( i1-1, h( i1, 1 ), ldh, h( i2, 1 ), ldh )
297 ipiv( i1 ) = i2
298
299 IF( i1.GT.(k1-1) ) THEN
300
301
302
303
304 CALL cswap( i1-k1+1, a( 1, i1 ), 1,
305 $ a( 1, i2 ), 1 )
306 END IF
307 ELSE
308 ipiv( j+1 ) = j+1
309 ENDIF
310
311
312
313 a( k, j+1 ) = work( 2 )
314
315 IF( j.LT.nb ) THEN
316
317
318
319 CALL ccopy( m-j, a( k+1, j+1 ), lda,
320 $ h( j+1, j+1 ), 1 )
321 END IF
322
323
324
325
326 IF( j.LT.(m-1) ) THEN
327 IF( a( k, j+1 ).NE.zero ) THEN
328 alpha = one / a( k, j+1 )
329 CALL ccopy( m-j-1, work( 3 ), 1, a( k, j+2 ), lda )
330 CALL cscal( m-j-1, alpha, a( k, j+2 ), lda )
331 ELSE
332 CALL claset(
'Full', 1, m-j-1, zero, zero,
333 $ a( k, j+2 ), lda)
334 END IF
335 END IF
336 END IF
337 j = j + 1
338 GO TO 10
339 20 CONTINUE
340
341 ELSE
342
343
344
345
346
347 30 CONTINUE
348 IF( j.GT.min( m, nb ) )
349 $ GO TO 40
350
351
352
353
354
355
356 k = j1+j-1
357 IF( j.EQ.m ) THEN
358
359
360
361 mj = 1
362 ELSE
363 mj = m-j+1
364 END IF
365
366
367
368
369 IF( k.GT.2 ) THEN
370
371
372
373
374
375
376
377 CALL cgemv(
'No transpose', mj, j-k1,
378 $ -one, h( j, k1 ), ldh,
379 $ a( j, 1 ), lda,
380 $ one, h( j, j ), 1 )
381 END IF
382
383
384
385 CALL ccopy( mj, h( j, j ), 1, work( 1 ), 1 )
386
387 IF( j.GT.k1 ) THEN
388
389
390
391
392 alpha = -a( j, k-1 )
393 CALL caxpy( mj, alpha, a( j, k-2 ), 1, work( 1 ), 1 )
394 END IF
395
396
397
398 a( j, k ) = work( 1 )
399
400 IF( j.LT.m ) THEN
401
402
403
404
405 IF( k.GT.1 ) THEN
406 alpha = -a( j, k )
407 CALL caxpy( m-j, alpha, a( j+1, k-1 ), 1,
408 $ work( 2 ), 1 )
409 ENDIF
410
411
412
413 i2 =
icamax( m-j, work( 2 ), 1 ) + 1
414 piv = work( i2 )
415
416
417
418 IF( (i2.NE.2) .AND. (piv.NE.0) ) THEN
419
420
421
422 i1 = 2
423 work( i2 ) = work( i1 )
424 work( i1 ) = piv
425
426
427
428 i1 = i1+j-1
429 i2 = i2+j-1
430 CALL cswap( i2-i1-1, a( i1+1, j1+i1-1 ), 1,
431 $ a( i2, j1+i1 ), lda )
432
433
434
435 IF( i2.LT.m )
436 $
CALL cswap( m-i2, a( i2+1, j1+i1-1 ), 1,
437 $ a( i2+1, j1+i2-1 ), 1 )
438
439
440
441 piv = a( i1, j1+i1-1 )
442 a( i1, j1+i1-1 ) = a( i2, j1+i2-1 )
443 a( i2, j1+i2-1 ) = piv
444
445
446
447 CALL cswap( i1-1, h( i1, 1 ), ldh, h( i2, 1 ), ldh )
448 ipiv( i1 ) = i2
449
450 IF( i1.GT.(k1-1) ) THEN
451
452
453
454
455 CALL cswap( i1-k1+1, a( i1, 1 ), lda,
456 $ a( i2, 1 ), lda )
457 END IF
458 ELSE
459 ipiv( j+1 ) = j+1
460 ENDIF
461
462
463
464 a( j+1, k ) = work( 2 )
465
466 IF( j.LT.nb ) THEN
467
468
469
470 CALL ccopy( m-j, a( j+1, k+1 ), 1,
471 $ h( j+1, j+1 ), 1 )
472 END IF
473
474
475
476
477 IF( j.LT.(m-1) ) THEN
478 IF( a( j+1, k ).NE.zero ) THEN
479 alpha = one / a( j+1, k )
480 CALL ccopy( m-j-1, work( 3 ), 1, a( j+2, k ), 1 )
481 CALL cscal( m-j-1, alpha, a( j+2, k ), 1 )
482 ELSE
483 CALL claset(
'Full', m-j-1, 1, zero, zero,
484 $ a( j+2, k ), lda )
485 END IF
486 END IF
487 END IF
488 j = j + 1
489 GO TO 30
490 40 CONTINUE
491 END IF
492 RETURN
493
494
495
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 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