LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
clasyf_rk.f
Go to the documentation of this file.
1*> \brief \b CLASYF_RK computes a partial factorization of a complex symmetric indefinite matrix using bounded Bunch-Kaufman (rook) diagonal pivoting method.
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8*> Download CLASYF_RK + dependencies
9*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/clasyf_rk.f">
10*> [TGZ]</a>
11*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/clasyf_rk.f">
12*> [ZIP]</a>
13*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/clasyf_rk.f">
14*> [TXT]</a>
15*
16* Definition:
17* ===========
18*
19* SUBROUTINE CLASYF_RK( UPLO, N, NB, KB, A, LDA, E, IPIV, W, LDW,
20* INFO )
21*
22* .. Scalar Arguments ..
23* CHARACTER UPLO
24* INTEGER INFO, KB, LDA, LDW, N, NB
25* ..
26* .. Array Arguments ..
27* INTEGER IPIV( * )
28* COMPLEX A( LDA, * ), E( * ), W( LDW, * )
29* ..
30*
31*
32*> \par Purpose:
33* =============
34*>
35*> \verbatim
36*> CLASYF_RK computes a partial factorization of a complex symmetric
37*> matrix A using the bounded Bunch-Kaufman (rook) diagonal
38*> pivoting method. The partial factorization has the form:
39*>
40*> A = ( I U12 ) ( A11 0 ) ( I 0 ) if UPLO = 'U', or:
41*> ( 0 U22 ) ( 0 D ) ( U12**T U22**T )
42*>
43*> A = ( L11 0 ) ( D 0 ) ( L11**T L21**T ) if UPLO = 'L',
44*> ( L21 I ) ( 0 A22 ) ( 0 I )
45*>
46*> where the order of D is at most NB. The actual order is returned in
47*> the argument KB, and is either NB or NB-1, or N if N <= NB.
48*>
49*> CLASYF_RK is an auxiliary routine called by CSYTRF_RK. It uses
50*> blocked code (calling Level 3 BLAS) to update the submatrix
51*> A11 (if UPLO = 'U') or A22 (if UPLO = 'L').
52*> \endverbatim
53*
54* Arguments:
55* ==========
56*
57*> \param[in] UPLO
58*> \verbatim
59*> UPLO is CHARACTER*1
60*> Specifies whether the upper or lower triangular part of the
61*> symmetric matrix A is stored:
62*> = 'U': Upper triangular
63*> = 'L': Lower triangular
64*> \endverbatim
65*>
66*> \param[in] N
67*> \verbatim
68*> N is INTEGER
69*> The order of the matrix A. N >= 0.
70*> \endverbatim
71*>
72*> \param[in] NB
73*> \verbatim
74*> NB is INTEGER
75*> The maximum number of columns of the matrix A that should be
76*> factored. NB should be at least 2 to allow for 2-by-2 pivot
77*> blocks.
78*> \endverbatim
79*>
80*> \param[out] KB
81*> \verbatim
82*> KB is INTEGER
83*> The number of columns of A that were actually factored.
84*> KB is either NB-1 or NB, or N if N <= NB.
85*> \endverbatim
86*>
87*> \param[in,out] A
88*> \verbatim
89*> A is COMPLEX array, dimension (LDA,N)
90*> On entry, the symmetric matrix A.
91*> If UPLO = 'U': the leading N-by-N upper triangular part
92*> of A contains the upper triangular part of the matrix A,
93*> and the strictly lower triangular part of A is not
94*> referenced.
95*>
96*> If UPLO = 'L': the leading N-by-N lower triangular part
97*> of A contains the lower triangular part of the matrix A,
98*> and the strictly upper triangular part of A is not
99*> referenced.
100*>
101*> On exit, contains:
102*> a) ONLY diagonal elements of the symmetric block diagonal
103*> matrix D on the diagonal of A, i.e. D(k,k) = A(k,k);
104*> (superdiagonal (or subdiagonal) elements of D
105*> are stored on exit in array E), and
106*> b) If UPLO = 'U': factor U in the superdiagonal part of A.
107*> If UPLO = 'L': factor L in the subdiagonal part of A.
108*> \endverbatim
109*>
110*> \param[in] LDA
111*> \verbatim
112*> LDA is INTEGER
113*> The leading dimension of the array A. LDA >= max(1,N).
114*> \endverbatim
115*>
116*> \param[out] E
117*> \verbatim
118*> E is COMPLEX array, dimension (N)
119*> On exit, contains the superdiagonal (or subdiagonal)
120*> elements of the symmetric block diagonal matrix D
121*> with 1-by-1 or 2-by-2 diagonal blocks, where
122*> If UPLO = 'U': E(i) = D(i-1,i), i=2:N, E(1) is set to 0;
123*> If UPLO = 'L': E(i) = D(i+1,i), i=1:N-1, E(N) is set to 0.
124*>
125*> NOTE: For 1-by-1 diagonal block D(k), where
126*> 1 <= k <= N, the element E(k) is set to 0 in both
127*> UPLO = 'U' or UPLO = 'L' cases.
128*> \endverbatim
129*>
130*> \param[out] IPIV
131*> \verbatim
132*> IPIV is INTEGER array, dimension (N)
133*> IPIV describes the permutation matrix P in the factorization
134*> of matrix A as follows. The absolute value of IPIV(k)
135*> represents the index of row and column that were
136*> interchanged with the k-th row and column. The value of UPLO
137*> describes the order in which the interchanges were applied.
138*> Also, the sign of IPIV represents the block structure of
139*> the symmetric block diagonal matrix D with 1-by-1 or 2-by-2
140*> diagonal blocks which correspond to 1 or 2 interchanges
141*> at each factorization step.
142*>
143*> If UPLO = 'U',
144*> ( in factorization order, k decreases from N to 1 ):
145*> a) A single positive entry IPIV(k) > 0 means:
146*> D(k,k) is a 1-by-1 diagonal block.
147*> If IPIV(k) != k, rows and columns k and IPIV(k) were
148*> interchanged in the submatrix A(1:N,N-KB+1:N);
149*> If IPIV(k) = k, no interchange occurred.
150*>
151*>
152*> b) A pair of consecutive negative entries
153*> IPIV(k) < 0 and IPIV(k-1) < 0 means:
154*> D(k-1:k,k-1:k) is a 2-by-2 diagonal block.
155*> (NOTE: negative entries in IPIV appear ONLY in pairs).
156*> 1) If -IPIV(k) != k, rows and columns
157*> k and -IPIV(k) were interchanged
158*> in the matrix A(1:N,N-KB+1:N).
159*> If -IPIV(k) = k, no interchange occurred.
160*> 2) If -IPIV(k-1) != k-1, rows and columns
161*> k-1 and -IPIV(k-1) were interchanged
162*> in the submatrix A(1:N,N-KB+1:N).
163*> If -IPIV(k-1) = k-1, no interchange occurred.
164*>
165*> c) In both cases a) and b) is always ABS( IPIV(k) ) <= k.
166*>
167*> d) NOTE: Any entry IPIV(k) is always NONZERO on output.
168*>
169*> If UPLO = 'L',
170*> ( in factorization order, k increases from 1 to N ):
171*> a) A single positive entry IPIV(k) > 0 means:
172*> D(k,k) is a 1-by-1 diagonal block.
173*> If IPIV(k) != k, rows and columns k and IPIV(k) were
174*> interchanged in the submatrix A(1:N,1:KB).
175*> If IPIV(k) = k, no interchange occurred.
176*>
177*> b) A pair of consecutive negative entries
178*> IPIV(k) < 0 and IPIV(k+1) < 0 means:
179*> D(k:k+1,k:k+1) is a 2-by-2 diagonal block.
180*> (NOTE: negative entries in IPIV appear ONLY in pairs).
181*> 1) If -IPIV(k) != k, rows and columns
182*> k and -IPIV(k) were interchanged
183*> in the submatrix A(1:N,1:KB).
184*> If -IPIV(k) = k, no interchange occurred.
185*> 2) If -IPIV(k+1) != k+1, rows and columns
186*> k-1 and -IPIV(k-1) were interchanged
187*> in the submatrix A(1:N,1:KB).
188*> If -IPIV(k+1) = k+1, no interchange occurred.
189*>
190*> c) In both cases a) and b) is always ABS( IPIV(k) ) >= k.
191*>
192*> d) NOTE: Any entry IPIV(k) is always NONZERO on output.
193*> \endverbatim
194*>
195*> \param[out] W
196*> \verbatim
197*> W is COMPLEX array, dimension (LDW,NB)
198*> \endverbatim
199*>
200*> \param[in] LDW
201*> \verbatim
202*> LDW is INTEGER
203*> The leading dimension of the array W. LDW >= max(1,N).
204*> \endverbatim
205*>
206*> \param[out] INFO
207*> \verbatim
208*> INFO is INTEGER
209*> = 0: successful exit
210*>
211*> < 0: If INFO = -k, the k-th argument had an illegal value
212*>
213*> > 0: If INFO = k, the matrix A is singular, because:
214*> If UPLO = 'U': column k in the upper
215*> triangular part of A contains all zeros.
216*> If UPLO = 'L': column k in the lower
217*> triangular part of A contains all zeros.
218*>
219*> Therefore D(k,k) is exactly zero, and superdiagonal
220*> elements of column k of U (or subdiagonal elements of
221*> column k of L ) are all zeros. The factorization has
222*> been completed, but the block diagonal matrix D is
223*> exactly singular, and division by zero will occur if
224*> it is used to solve a system of equations.
225*>
226*> NOTE: INFO only stores the first occurrence of
227*> a singularity, any subsequent occurrence of singularity
228*> is not stored in INFO even though the factorization
229*> always completes.
230*> \endverbatim
231*
232* Authors:
233* ========
234*
235*> \author Univ. of Tennessee
236*> \author Univ. of California Berkeley
237*> \author Univ. of Colorado Denver
238*> \author NAG Ltd.
239*
240*> \ingroup lahef_rk
241*
242*> \par Contributors:
243* ==================
244*>
245*> \verbatim
246*>
247*> December 2016, Igor Kozachenko,
248*> Computer Science Division,
249*> University of California, Berkeley
250*>
251*> September 2007, Sven Hammarling, Nicholas J. Higham, Craig Lucas,
252*> School of Mathematics,
253*> University of Manchester
254*>
255*> \endverbatim
256*
257* =====================================================================
258 SUBROUTINE clasyf_rk( UPLO, N, NB, KB, A, LDA, E, IPIV, W, LDW,
259 $ INFO )
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*
943 END
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
subroutine clasyf_rk(uplo, n, nb, kb, a, lda, e, ipiv, w, ldw, info)
CLASYF_RK computes a partial factorization of a complex symmetric indefinite matrix using bounded Bun...
Definition clasyf_rk.f:260
subroutine cscal(n, ca, cx, incx)
CSCAL
Definition cscal.f:78
subroutine cswap(n, cx, incx, cy, incy)
CSWAP
Definition cswap.f:81