LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches

◆ clasyf_rk()

subroutine clasyf_rk ( character uplo,
integer n,
integer nb,
integer kb,
complex, dimension( lda, * ) a,
integer lda,
complex, dimension( * ) e,
integer, dimension( * ) ipiv,
complex, dimension( ldw, * ) w,
integer ldw,
integer info )

CLASYF_RK computes a partial factorization of a complex symmetric indefinite matrix using bounded Bunch-Kaufman (rook) diagonal pivoting method.

Download CLASYF_RK + dependencies [TGZ] [ZIP] [TXT]

Purpose:
!> CLASYF_RK computes a partial factorization of a complex symmetric
!> matrix A using the bounded Bunch-Kaufman (rook) diagonal
!> pivoting method. The partial factorization has the form:
!>
!> A  =  ( I  U12 ) ( A11  0  ) (  I       0    )  if UPLO = 'U', or:
!>       ( 0  U22 ) (  0   D  ) ( U12**T U22**T )
!>
!> A  =  ( L11  0 ) (  D   0  ) ( L11**T L21**T )  if UPLO = 'L',
!>       ( L21  I ) (  0  A22 ) (  0       I    )
!>
!> where the order of D is at most NB. The actual order is returned in
!> the argument KB, and is either NB or NB-1, or N if N <= NB.
!>
!> CLASYF_RK is an auxiliary routine called by CSYTRF_RK. It uses
!> blocked code (calling Level 3 BLAS) to update the submatrix
!> A11 (if UPLO = 'U') or A22 (if UPLO = 'L').
!> 
Parameters
[in]UPLO
!>          UPLO is CHARACTER*1
!>          Specifies whether the upper or lower triangular part of the
!>          symmetric matrix A is stored:
!>          = 'U':  Upper triangular
!>          = 'L':  Lower triangular
!> 
[in]N
!>          N is INTEGER
!>          The order of the matrix A.  N >= 0.
!> 
[in]NB
!>          NB is INTEGER
!>          The maximum number of columns of the matrix A that should be
!>          factored.  NB should be at least 2 to allow for 2-by-2 pivot
!>          blocks.
!> 
[out]KB
!>          KB is INTEGER
!>          The number of columns of A that were actually factored.
!>          KB is either NB-1 or NB, or N if N <= NB.
!> 
[in,out]A
!>          A is COMPLEX array, dimension (LDA,N)
!>          On entry, the symmetric matrix A.
!>            If UPLO = 'U': the leading N-by-N upper triangular part
!>            of A contains the upper triangular part of the matrix A,
!>            and the strictly lower triangular part of A is not
!>            referenced.
!>
!>            If UPLO = 'L': the leading N-by-N lower triangular part
!>            of A contains the lower triangular part of the matrix A,
!>            and the strictly upper triangular part of A is not
!>            referenced.
!>
!>          On exit, contains:
!>            a) ONLY diagonal elements of the symmetric block diagonal
!>               matrix D on the diagonal of A, i.e. D(k,k) = A(k,k);
!>               (superdiagonal (or subdiagonal) elements of D
!>                are stored on exit in array E), and
!>            b) If UPLO = 'U': factor U in the superdiagonal part of A.
!>               If UPLO = 'L': factor L in the subdiagonal part of A.
!> 
[in]LDA
!>          LDA is INTEGER
!>          The leading dimension of the array A.  LDA >= max(1,N).
!> 
[out]E
!>          E is COMPLEX array, dimension (N)
!>          On exit, contains the superdiagonal (or subdiagonal)
!>          elements of the symmetric block diagonal matrix D
!>          with 1-by-1 or 2-by-2 diagonal blocks, where
!>          If UPLO = 'U': E(i) = D(i-1,i), i=2:N, E(1) is set to 0;
!>          If UPLO = 'L': E(i) = D(i+1,i), i=1:N-1, E(N) is set to 0.
!>
!>          NOTE: For 1-by-1 diagonal block D(k), where
!>          1 <= k <= N, the element E(k) is set to 0 in both
!>          UPLO = 'U' or UPLO = 'L' cases.
!> 
[out]IPIV
!>          IPIV is INTEGER array, dimension (N)
!>          IPIV describes the permutation matrix P in the factorization
!>          of matrix A as follows. The absolute value of IPIV(k)
!>          represents the index of row and column that were
!>          interchanged with the k-th row and column. The value of UPLO
!>          describes the order in which the interchanges were applied.
!>          Also, the sign of IPIV represents the block structure of
!>          the symmetric block diagonal matrix D with 1-by-1 or 2-by-2
!>          diagonal blocks which correspond to 1 or 2 interchanges
!>          at each factorization step.
!>
!>          If UPLO = 'U',
!>          ( in factorization order, k decreases from N to 1 ):
!>            a) A single positive entry IPIV(k) > 0 means:
!>               D(k,k) is a 1-by-1 diagonal block.
!>               If IPIV(k) != k, rows and columns k and IPIV(k) were
!>               interchanged in the submatrix A(1:N,N-KB+1:N);
!>               If IPIV(k) = k, no interchange occurred.
!>
!>
!>            b) A pair of consecutive negative entries
!>               IPIV(k) < 0 and IPIV(k-1) < 0 means:
!>               D(k-1:k,k-1:k) is a 2-by-2 diagonal block.
!>               (NOTE: negative entries in IPIV appear ONLY in pairs).
!>               1) If -IPIV(k) != k, rows and columns
!>                  k and -IPIV(k) were interchanged
!>                  in the matrix A(1:N,N-KB+1:N).
!>                  If -IPIV(k) = k, no interchange occurred.
!>               2) If -IPIV(k-1) != k-1, rows and columns
!>                  k-1 and -IPIV(k-1) were interchanged
!>                  in the submatrix A(1:N,N-KB+1:N).
!>                  If -IPIV(k-1) = k-1, no interchange occurred.
!>
!>            c) In both cases a) and b) is always ABS( IPIV(k) ) <= k.
!>
!>            d) NOTE: Any entry IPIV(k) is always NONZERO on output.
!>
!>          If UPLO = 'L',
!>          ( in factorization order, k increases from 1 to N ):
!>            a) A single positive entry IPIV(k) > 0 means:
!>               D(k,k) is a 1-by-1 diagonal block.
!>               If IPIV(k) != k, rows and columns k and IPIV(k) were
!>               interchanged in the submatrix A(1:N,1:KB).
!>               If IPIV(k) = k, no interchange occurred.
!>
!>            b) A pair of consecutive negative entries
!>               IPIV(k) < 0 and IPIV(k+1) < 0 means:
!>               D(k:k+1,k:k+1) is a 2-by-2 diagonal block.
!>               (NOTE: negative entries in IPIV appear ONLY in pairs).
!>               1) If -IPIV(k) != k, rows and columns
!>                  k and -IPIV(k) were interchanged
!>                  in the submatrix A(1:N,1:KB).
!>                  If -IPIV(k) = k, no interchange occurred.
!>               2) If -IPIV(k+1) != k+1, rows and columns
!>                  k-1 and -IPIV(k-1) were interchanged
!>                  in the submatrix A(1:N,1:KB).
!>                  If -IPIV(k+1) = k+1, no interchange occurred.
!>
!>            c) In both cases a) and b) is always ABS( IPIV(k) ) >= k.
!>
!>            d) NOTE: Any entry IPIV(k) is always NONZERO on output.
!> 
[out]W
!>          W is COMPLEX array, dimension (LDW,NB)
!> 
[in]LDW
!>          LDW is INTEGER
!>          The leading dimension of the array W.  LDW >= max(1,N).
!> 
[out]INFO
!>          INFO is INTEGER
!>          = 0: successful exit
!>
!>          < 0: If INFO = -k, the k-th argument had an illegal value
!>
!>          > 0: If INFO = k, the matrix A is singular, because:
!>                 If UPLO = 'U': column k in the upper
!>                 triangular part of A contains all zeros.
!>                 If UPLO = 'L': column k in the lower
!>                 triangular part of A contains all zeros.
!>
!>               Therefore D(k,k) is exactly zero, and superdiagonal
!>               elements of column k of U (or subdiagonal elements of
!>               column k of L ) are all zeros. The factorization has
!>               been completed, but the block diagonal matrix D is
!>               exactly singular, and division by zero will occur if
!>               it is used to solve a system of equations.
!>
!>               NOTE: INFO only stores the first occurrence of
!>               a singularity, any subsequent occurrence of singularity
!>               is not stored in INFO even though the factorization
!>               always completes.
!> 
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
Contributors:
!>
!>  December 2016,  Igor Kozachenko,
!>                  Computer Science Division,
!>                  University of California, Berkeley
!>
!>  September 2007, Sven Hammarling, Nicholas J. Higham, Craig Lucas,
!>                  School of Mathematics,
!>                  University of Manchester
!>
!> 

Definition at line 258 of file clasyf_rk.f.

260*
261* -- LAPACK computational routine --
262* -- LAPACK is a software package provided by Univ. of Tennessee, --
263* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
264*
265* .. Scalar Arguments ..
266 CHARACTER UPLO
267 INTEGER INFO, KB, LDA, LDW, N, NB
268* ..
269* .. Array Arguments ..
270 INTEGER IPIV( * )
271 COMPLEX A( LDA, * ), E( * ), W( LDW, * )
272* ..
273*
274* =====================================================================
275*
276* .. Parameters ..
277 REAL ZERO, ONE
278 parameter( zero = 0.0e+0, one = 1.0e+0 )
279 REAL EIGHT, SEVTEN
280 parameter( eight = 8.0e+0, sevten = 17.0e+0 )
281 COMPLEX CONE, CZERO
282 parameter( cone = ( 1.0e+0, 0.0e+0 ),
283 $ czero = ( 0.0e+0, 0.0e+0 ) )
284* ..
285* .. Local Scalars ..
286 LOGICAL DONE
287 INTEGER IMAX, ITEMP, J, JB, JJ, JMAX, K, KK, KW, KKW,
288 $ KP, KSTEP, P, II
289 REAL ABSAKK, ALPHA, COLMAX, ROWMAX, SFMIN, STEMP
290 COMPLEX D11, D12, D21, D22, R1, T, Z
291* ..
292* .. External Functions ..
293 LOGICAL LSAME
294 INTEGER ICAMAX
295 REAL SLAMCH
296 EXTERNAL lsame, icamax, slamch
297* ..
298* .. External Subroutines ..
299 EXTERNAL ccopy, cgemmtr, cgemv, cscal, cswap
300* ..
301* .. Intrinsic Functions ..
302 INTRINSIC abs, aimag, max, min, real, sqrt
303* ..
304* .. Statement Functions ..
305 REAL CABS1
306* ..
307* .. Statement Function definitions ..
308 cabs1( z ) = abs( real( z ) ) + abs( aimag( z ) )
309* ..
310* .. Executable Statements ..
311*
312 info = 0
313*
314* Initialize ALPHA for use in choosing pivot block size.
315*
316 alpha = ( one+sqrt( sevten ) ) / eight
317*
318* Compute machine safe minimum
319*
320 sfmin = slamch( 'S' )
321*
322 IF( lsame( uplo, 'U' ) ) THEN
323*
324* Factorize the trailing columns of A using the upper triangle
325* of A and working backwards, and compute the matrix W = U12*D
326* for use in updating A11
327*
328* Initialize the first entry of array E, where superdiagonal
329* elements of D are stored
330*
331 e( 1 ) = czero
332*
333* K is the main loop index, decreasing from N in steps of 1 or 2
334*
335 k = n
336 10 CONTINUE
337*
338* KW is the column of W which corresponds to column K of A
339*
340 kw = nb + k - n
341*
342* Exit from loop
343*
344 IF( ( k.LE.n-nb+1 .AND. nb.LT.n ) .OR. k.LT.1 )
345 $ GO TO 30
346*
347 kstep = 1
348 p = k
349*
350* Copy column K of A to column KW of W and update it
351*
352 CALL ccopy( k, a( 1, k ), 1, w( 1, kw ), 1 )
353 IF( k.LT.n )
354 $ CALL cgemv( 'No transpose', k, n-k, -cone, a( 1, k+1 ),
355 $ lda, w( k, kw+1 ), ldw, cone, w( 1, kw ), 1 )
356*
357* Determine rows and columns to be interchanged and whether
358* a 1-by-1 or 2-by-2 pivot block will be used
359*
360 absakk = cabs1( w( k, kw ) )
361*
362* IMAX is the row-index of the largest off-diagonal element in
363* column K, and COLMAX is its absolute value.
364* Determine both COLMAX and IMAX.
365*
366 IF( k.GT.1 ) THEN
367 imax = icamax( k-1, w( 1, kw ), 1 )
368 colmax = cabs1( w( imax, kw ) )
369 ELSE
370 colmax = zero
371 END IF
372*
373 IF( max( absakk, colmax ).EQ.zero ) THEN
374*
375* Column K is zero or underflow: set INFO and continue
376*
377 IF( info.EQ.0 )
378 $ info = k
379 kp = k
380 CALL ccopy( k, w( 1, kw ), 1, a( 1, k ), 1 )
381*
382* Set E( K ) to zero
383*
384 IF( k.GT.1 )
385 $ e( k ) = czero
386*
387 ELSE
388*
389* ============================================================
390*
391* Test for interchange
392*
393* Equivalent to testing for ABSAKK.GE.ALPHA*COLMAX
394* (used to handle NaN and Inf)
395*
396 IF( .NOT.( absakk.LT.alpha*colmax ) ) THEN
397*
398* no interchange, use 1-by-1 pivot block
399*
400 kp = k
401*
402 ELSE
403*
404 done = .false.
405*
406* Loop until pivot found
407*
408 12 CONTINUE
409*
410* Begin pivot search loop body
411*
412*
413* Copy column IMAX to column KW-1 of W and update it
414*
415 CALL ccopy( imax, a( 1, imax ), 1, w( 1, kw-1 ),
416 $ 1 )
417 CALL ccopy( k-imax, a( imax, imax+1 ), lda,
418 $ w( imax+1, kw-1 ), 1 )
419*
420 IF( k.LT.n )
421 $ CALL cgemv( 'No transpose', k, n-k, -cone,
422 $ a( 1, k+1 ), lda, w( imax, kw+1 ), ldw,
423 $ cone, w( 1, kw-1 ), 1 )
424*
425* JMAX is the column-index of the largest off-diagonal
426* element in row IMAX, and ROWMAX is its absolute value.
427* Determine both ROWMAX and JMAX.
428*
429 IF( imax.NE.k ) THEN
430 jmax = imax + icamax( k-imax, w( imax+1, kw-1 ),
431 $ 1 )
432 rowmax = cabs1( w( jmax, kw-1 ) )
433 ELSE
434 rowmax = zero
435 END IF
436*
437 IF( imax.GT.1 ) THEN
438 itemp = icamax( imax-1, w( 1, kw-1 ), 1 )
439 stemp = cabs1( w( itemp, kw-1 ) )
440 IF( stemp.GT.rowmax ) THEN
441 rowmax = stemp
442 jmax = itemp
443 END IF
444 END IF
445*
446* Equivalent to testing for
447* CABS1( W( IMAX, KW-1 ) ).GE.ALPHA*ROWMAX
448* (used to handle NaN and Inf)
449*
450 IF( .NOT.(cabs1( w( imax, kw-1 ) ).LT.alpha*rowmax ) )
451 $ THEN
452*
453* interchange rows and columns K and IMAX,
454* use 1-by-1 pivot block
455*
456 kp = imax
457*
458* copy column KW-1 of W to column KW of W
459*
460 CALL ccopy( k, w( 1, kw-1 ), 1, w( 1, kw ), 1 )
461*
462 done = .true.
463*
464* Equivalent to testing for ROWMAX.EQ.COLMAX,
465* (used to handle NaN and Inf)
466*
467 ELSE IF( ( p.EQ.jmax ) .OR. ( rowmax.LE.colmax ) )
468 $ THEN
469*
470* interchange rows and columns K-1 and IMAX,
471* use 2-by-2 pivot block
472*
473 kp = imax
474 kstep = 2
475 done = .true.
476 ELSE
477*
478* Pivot not found: set params and repeat
479*
480 p = imax
481 colmax = rowmax
482 imax = jmax
483*
484* Copy updated JMAXth (next IMAXth) column to Kth of W
485*
486 CALL ccopy( k, w( 1, kw-1 ), 1, w( 1, kw ), 1 )
487*
488 END IF
489*
490* End pivot search loop body
491*
492 IF( .NOT. done ) GOTO 12
493*
494 END IF
495*
496* ============================================================
497*
498 kk = k - kstep + 1
499*
500* KKW is the column of W which corresponds to column KK of A
501*
502 kkw = nb + kk - n
503*
504 IF( ( kstep.EQ.2 ) .AND. ( p.NE.k ) ) THEN
505*
506* Copy non-updated column K to column P
507*
508 CALL ccopy( k-p, a( p+1, k ), 1, a( p, p+1 ), lda )
509 CALL ccopy( p, a( 1, k ), 1, a( 1, p ), 1 )
510*
511* Interchange rows K and P in last N-K+1 columns of A
512* and last N-K+2 columns of W
513*
514 CALL cswap( n-k+1, a( k, k ), lda, a( p, k ), lda )
515 CALL cswap( n-kk+1, w( k, kkw ), ldw, w( p, kkw ),
516 $ ldw )
517 END IF
518*
519* Updated column KP is already stored in column KKW of W
520*
521 IF( kp.NE.kk ) THEN
522*
523* Copy non-updated column KK to column KP
524*
525 a( kp, k ) = a( kk, k )
526 CALL ccopy( k-1-kp, a( kp+1, kk ), 1, a( kp, kp+1 ),
527 $ lda )
528 CALL ccopy( kp, a( 1, kk ), 1, a( 1, kp ), 1 )
529*
530* Interchange rows KK and KP in last N-KK+1 columns
531* of A and W
532*
533 CALL cswap( n-kk+1, a( kk, kk ), lda, a( kp, kk ),
534 $ lda )
535 CALL cswap( n-kk+1, w( kk, kkw ), ldw, w( kp, kkw ),
536 $ ldw )
537 END IF
538*
539 IF( kstep.EQ.1 ) THEN
540*
541* 1-by-1 pivot block D(k): column KW of W now holds
542*
543* W(k) = U(k)*D(k)
544*
545* where U(k) is the k-th column of U
546*
547* Store U(k) in column k of A
548*
549 CALL ccopy( k, w( 1, kw ), 1, a( 1, k ), 1 )
550 IF( k.GT.1 ) THEN
551 IF( cabs1( a( k, k ) ).GE.sfmin ) THEN
552 r1 = cone / a( k, k )
553 CALL cscal( k-1, r1, a( 1, k ), 1 )
554 ELSE IF( a( k, k ).NE.czero ) THEN
555 DO 14 ii = 1, k - 1
556 a( ii, k ) = a( ii, k ) / a( k, k )
557 14 CONTINUE
558 END IF
559*
560* Store the superdiagonal element of D in array E
561*
562 e( k ) = czero
563*
564 END IF
565*
566 ELSE
567*
568* 2-by-2 pivot block D(k): columns KW and KW-1 of W now
569* hold
570*
571* ( W(k-1) W(k) ) = ( U(k-1) U(k) )*D(k)
572*
573* where U(k) and U(k-1) are the k-th and (k-1)-th columns
574* of U
575*
576 IF( k.GT.2 ) THEN
577*
578* Store U(k) and U(k-1) in columns k and k-1 of A
579*
580 d12 = w( k-1, kw )
581 d11 = w( k, kw ) / d12
582 d22 = w( k-1, kw-1 ) / d12
583 t = cone / ( d11*d22-cone )
584 DO 20 j = 1, k - 2
585 a( j, k-1 ) = t*( (d11*w( j, kw-1 )-w( j, kw ) ) /
586 $ d12 )
587 a( j, k ) = t*( ( d22*w( j, kw )-w( j, kw-1 ) ) /
588 $ d12 )
589 20 CONTINUE
590 END IF
591*
592* Copy diagonal elements of D(K) to A,
593* copy superdiagonal element of D(K) to E(K) and
594* ZERO out superdiagonal entry of A
595*
596 a( k-1, k-1 ) = w( k-1, kw-1 )
597 a( k-1, k ) = czero
598 a( k, k ) = w( k, kw )
599 e( k ) = w( k-1, kw )
600 e( k-1 ) = czero
601*
602 END IF
603*
604* End column K is nonsingular
605*
606 END IF
607*
608* Store details of the interchanges in IPIV
609*
610 IF( kstep.EQ.1 ) THEN
611 ipiv( k ) = kp
612 ELSE
613 ipiv( k ) = -p
614 ipiv( k-1 ) = -kp
615 END IF
616*
617* Decrease K and return to the start of the main loop
618*
619 k = k - kstep
620 GO TO 10
621*
622 30 CONTINUE
623*
624* Update the upper triangle of A11 (= A(1:k,1:k)) as
625*
626* A11 := A11 - U12*D*U12**T = A11 - U12*W**T
627*
628 CALL cgemmtr( 'Upper', 'No transpose', 'Transpose', k, n-k,
629 $ -cone, a( 1, k+1 ), lda, w( 1, kw+1 ), ldw,
630 $ cone, a( 1, 1 ), lda )
631*
632* Set KB to the number of columns factorized
633*
634 kb = n - k
635*
636 ELSE
637*
638* Factorize the leading columns of A using the lower triangle
639* of A and working forwards, and compute the matrix W = L21*D
640* for use in updating A22
641*
642* Initialize the unused last entry of the subdiagonal array E.
643*
644 e( n ) = czero
645*
646* K is the main loop index, increasing from 1 in steps of 1 or 2
647*
648 k = 1
649 70 CONTINUE
650*
651* Exit from loop
652*
653 IF( ( k.GE.nb .AND. nb.LT.n ) .OR. k.GT.n )
654 $ GO TO 90
655*
656 kstep = 1
657 p = k
658*
659* Copy column K of A to column K of W and update it
660*
661 CALL ccopy( n-k+1, a( k, k ), 1, w( k, k ), 1 )
662 IF( k.GT.1 )
663 $ CALL cgemv( 'No transpose', n-k+1, k-1, -cone, a( k, 1 ),
664 $ lda, w( k, 1 ), ldw, cone, w( k, k ), 1 )
665*
666* Determine rows and columns to be interchanged and whether
667* a 1-by-1 or 2-by-2 pivot block will be used
668*
669 absakk = cabs1( w( k, k ) )
670*
671* IMAX is the row-index of the largest off-diagonal element in
672* column K, and COLMAX is its absolute value.
673* Determine both COLMAX and IMAX.
674*
675 IF( k.LT.n ) THEN
676 imax = k + icamax( n-k, w( k+1, k ), 1 )
677 colmax = cabs1( w( imax, k ) )
678 ELSE
679 colmax = zero
680 END IF
681*
682 IF( max( absakk, colmax ).EQ.zero ) THEN
683*
684* Column K is zero or underflow: set INFO and continue
685*
686 IF( info.EQ.0 )
687 $ info = k
688 kp = k
689 CALL ccopy( n-k+1, w( k, k ), 1, a( k, k ), 1 )
690*
691* Set E( K ) to zero
692*
693 IF( k.LT.n )
694 $ e( k ) = czero
695*
696 ELSE
697*
698* ============================================================
699*
700* Test for interchange
701*
702* Equivalent to testing for ABSAKK.GE.ALPHA*COLMAX
703* (used to handle NaN and Inf)
704*
705 IF( .NOT.( absakk.LT.alpha*colmax ) ) THEN
706*
707* no interchange, use 1-by-1 pivot block
708*
709 kp = k
710*
711 ELSE
712*
713 done = .false.
714*
715* Loop until pivot found
716*
717 72 CONTINUE
718*
719* Begin pivot search loop body
720*
721*
722* Copy column IMAX to column K+1 of W and update it
723*
724 CALL ccopy( imax-k, a( imax, k ), lda, w( k, k+1 ),
725 $ 1)
726 CALL ccopy( n-imax+1, a( imax, imax ), 1,
727 $ w( imax, k+1 ), 1 )
728 IF( k.GT.1 )
729 $ CALL cgemv( 'No transpose', n-k+1, k-1, -cone,
730 $ a( k, 1 ), lda, w( imax, 1 ), ldw,
731 $ cone, w( k, k+1 ), 1 )
732*
733* JMAX is the column-index of the largest off-diagonal
734* element in row IMAX, and ROWMAX is its absolute value.
735* Determine both ROWMAX and JMAX.
736*
737 IF( imax.NE.k ) THEN
738 jmax = k - 1 + icamax( imax-k, w( k, k+1 ), 1 )
739 rowmax = cabs1( w( jmax, k+1 ) )
740 ELSE
741 rowmax = zero
742 END IF
743*
744 IF( imax.LT.n ) THEN
745 itemp = imax + icamax( n-imax, w( imax+1, k+1 ),
746 $ 1)
747 stemp = cabs1( w( itemp, k+1 ) )
748 IF( stemp.GT.rowmax ) THEN
749 rowmax = stemp
750 jmax = itemp
751 END IF
752 END IF
753*
754* Equivalent to testing for
755* CABS1( W( IMAX, K+1 ) ).GE.ALPHA*ROWMAX
756* (used to handle NaN and Inf)
757*
758 IF( .NOT.( cabs1( w( imax, k+1 ) ).LT.alpha*rowmax ) )
759 $ THEN
760*
761* interchange rows and columns K and IMAX,
762* use 1-by-1 pivot block
763*
764 kp = imax
765*
766* copy column K+1 of W to column K of W
767*
768 CALL ccopy( n-k+1, w( k, k+1 ), 1, w( k, k ),
769 $ 1 )
770*
771 done = .true.
772*
773* Equivalent to testing for ROWMAX.EQ.COLMAX,
774* (used to handle NaN and Inf)
775*
776 ELSE IF( ( p.EQ.jmax ) .OR. ( rowmax.LE.colmax ) )
777 $ THEN
778*
779* interchange rows and columns K+1 and IMAX,
780* use 2-by-2 pivot block
781*
782 kp = imax
783 kstep = 2
784 done = .true.
785 ELSE
786*
787* Pivot not found: set params and repeat
788*
789 p = imax
790 colmax = rowmax
791 imax = jmax
792*
793* Copy updated JMAXth (next IMAXth) column to Kth of W
794*
795 CALL ccopy( n-k+1, w( k, k+1 ), 1, w( k, k ),
796 $ 1 )
797*
798 END IF
799*
800* End pivot search loop body
801*
802 IF( .NOT. done ) GOTO 72
803*
804 END IF
805*
806* ============================================================
807*
808 kk = k + kstep - 1
809*
810 IF( ( kstep.EQ.2 ) .AND. ( p.NE.k ) ) THEN
811*
812* Copy non-updated column K to column P
813*
814 CALL ccopy( p-k, a( k, k ), 1, a( p, k ), lda )
815 CALL ccopy( n-p+1, a( p, k ), 1, a( p, p ), 1 )
816*
817* Interchange rows K and P in first K columns of A
818* and first K+1 columns of W
819*
820 CALL cswap( k, a( k, 1 ), lda, a( p, 1 ), lda )
821 CALL cswap( kk, w( k, 1 ), ldw, w( p, 1 ), ldw )
822 END IF
823*
824* Updated column KP is already stored in column KK of W
825*
826 IF( kp.NE.kk ) THEN
827*
828* Copy non-updated column KK to column KP
829*
830 a( kp, k ) = a( kk, k )
831 CALL ccopy( kp-k-1, a( k+1, kk ), 1, a( kp, k+1 ),
832 $ lda )
833 CALL ccopy( n-kp+1, a( kp, kk ), 1, a( kp, kp ), 1 )
834*
835* Interchange rows KK and KP in first KK columns of A and W
836*
837 CALL cswap( kk, a( kk, 1 ), lda, a( kp, 1 ), lda )
838 CALL cswap( kk, w( kk, 1 ), ldw, w( kp, 1 ), ldw )
839 END IF
840*
841 IF( kstep.EQ.1 ) THEN
842*
843* 1-by-1 pivot block D(k): column k of W now holds
844*
845* W(k) = L(k)*D(k)
846*
847* where L(k) is the k-th column of L
848*
849* Store L(k) in column k of A
850*
851 CALL ccopy( n-k+1, w( k, k ), 1, a( k, k ), 1 )
852 IF( k.LT.n ) THEN
853 IF( cabs1( a( k, k ) ).GE.sfmin ) THEN
854 r1 = cone / a( k, k )
855 CALL cscal( n-k, r1, a( k+1, k ), 1 )
856 ELSE IF( a( k, k ).NE.czero ) THEN
857 DO 74 ii = k + 1, n
858 a( ii, k ) = a( ii, k ) / a( k, k )
859 74 CONTINUE
860 END IF
861*
862* Store the subdiagonal element of D in array E
863*
864 e( k ) = czero
865*
866 END IF
867*
868 ELSE
869*
870* 2-by-2 pivot block D(k): columns k and k+1 of W now hold
871*
872* ( W(k) W(k+1) ) = ( L(k) L(k+1) )*D(k)
873*
874* where L(k) and L(k+1) are the k-th and (k+1)-th columns
875* of L
876*
877 IF( k.LT.n-1 ) THEN
878*
879* Store L(k) and L(k+1) in columns k and k+1 of A
880*
881 d21 = w( k+1, k )
882 d11 = w( k+1, k+1 ) / d21
883 d22 = w( k, k ) / d21
884 t = cone / ( d11*d22-cone )
885 DO 80 j = k + 2, n
886 a( j, k ) = t*( ( d11*w( j, k )-w( j, k+1 ) ) /
887 $ d21 )
888 a( j, k+1 ) = t*( ( d22*w( j, k+1 )-w( j, k ) ) /
889 $ d21 )
890 80 CONTINUE
891 END IF
892*
893* Copy diagonal elements of D(K) to A,
894* copy subdiagonal element of D(K) to E(K) and
895* ZERO out subdiagonal entry of A
896*
897 a( k, k ) = w( k, k )
898 a( k+1, k ) = czero
899 a( k+1, k+1 ) = w( k+1, k+1 )
900 e( k ) = w( k+1, k )
901 e( k+1 ) = czero
902*
903 END IF
904*
905* End column K is nonsingular
906*
907 END IF
908*
909* Store details of the interchanges in IPIV
910*
911 IF( kstep.EQ.1 ) THEN
912 ipiv( k ) = kp
913 ELSE
914 ipiv( k ) = -p
915 ipiv( k+1 ) = -kp
916 END IF
917*
918* Increase K and return to the start of the main loop
919*
920 k = k + kstep
921 GO TO 70
922*
923 90 CONTINUE
924*
925* Update the lower triangle of A22 (= A(k:n,k:n)) as
926*
927* A22 := A22 - L21*D*L21**T = A22 - L21*W**T
928*
929 CALL cgemmtr( 'Lower', 'No transpose', 'Transpose', n-k+1,
930 $ k-1, -cone, a( k, 1 ), lda, w( k, 1 ), ldw,
931 $ cone, a( k, k ), lda )
932*
933* Set KB to the number of columns factorized
934*
935 kb = k - 1
936*
937 END IF
938*
939 RETURN
940*
941* End of CLASYF_RK
942*
subroutine ccopy(n, cx, incx, cy, incy)
CCOPY
Definition ccopy.f:81
subroutine cgemmtr(uplo, transa, transb, n, k, alpha, a, lda, b, ldb, beta, c, ldc)
CGEMMTR
Definition cgemmtr.f:191
subroutine cgemv(trans, m, n, alpha, a, lda, x, incx, beta, y, incy)
CGEMV
Definition cgemv.f:160
integer function icamax(n, cx, incx)
ICAMAX
Definition icamax.f:71
real function slamch(cmach)
SLAMCH
Definition slamch.f:68
logical function lsame(ca, cb)
LSAME
Definition lsame.f:48
subroutine cscal(n, ca, cx, incx)
CSCAL
Definition cscal.f:78
subroutine cswap(n, cx, incx, cy, incy)
CSWAP
Definition cswap.f:81
Here is the call graph for this function:
Here is the caller graph for this function: