LAPACK  3.10.0
LAPACK: Linear Algebra PACKage

◆ ssytf2()

subroutine ssytf2 ( character  UPLO,
integer  N,
real, dimension( lda, * )  A,
integer  LDA,
integer, dimension( * )  IPIV,
integer  INFO 
)

SSYTF2 computes the factorization of a real symmetric indefinite matrix, using the diagonal pivoting method (unblocked algorithm).

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

Purpose:
 SSYTF2 computes the factorization of a real symmetric matrix A using
 the Bunch-Kaufman diagonal pivoting method:

    A = U*D*U**T  or  A = L*D*L**T

 where U (or L) is a product of permutation and unit upper (lower)
 triangular matrices, U**T is the transpose of U, and D is symmetric and
 block diagonal with 1-by-1 and 2-by-2 diagonal blocks.

 This is the unblocked version of the algorithm, calling Level 2 BLAS.
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,out]A
          A is REAL 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, the block diagonal matrix D and the multipliers used
          to obtain the factor U or L (see below for further details).
[in]LDA
          LDA is INTEGER
          The leading dimension of the array A.  LDA >= max(1,N).
[out]IPIV
          IPIV is INTEGER array, dimension (N)
          Details of the interchanges and the block structure of D.

          If UPLO = 'U':
             If IPIV(k) > 0, then rows and columns k and IPIV(k) were
             interchanged and D(k,k) is a 1-by-1 diagonal block.

             If IPIV(k) = IPIV(k-1) < 0, then rows and columns
             k-1 and -IPIV(k) were interchanged and D(k-1:k,k-1:k)
             is a 2-by-2 diagonal block.

          If UPLO = 'L':
             If IPIV(k) > 0, then rows and columns k and IPIV(k) were
             interchanged and D(k,k) is a 1-by-1 diagonal block.

             If IPIV(k) = IPIV(k+1) < 0, then rows and columns
             k+1 and -IPIV(k) were interchanged and D(k:k+1,k:k+1)
             is a 2-by-2 diagonal block.
[out]INFO
          INFO is INTEGER
          = 0: successful exit
          < 0: if INFO = -k, the k-th argument had an illegal value
          > 0: if INFO = k, D(k,k) is exactly zero.  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.
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
Further Details:
  If UPLO = 'U', then A = U*D*U**T, where
     U = P(n)*U(n)* ... *P(k)U(k)* ...,
  i.e., U is a product of terms P(k)*U(k), where k decreases from n to
  1 in steps of 1 or 2, and D is a block diagonal matrix with 1-by-1
  and 2-by-2 diagonal blocks D(k).  P(k) is a permutation matrix as
  defined by IPIV(k), and U(k) is a unit upper triangular matrix, such
  that if the diagonal block D(k) is of order s (s = 1 or 2), then

             (   I    v    0   )   k-s
     U(k) =  (   0    I    0   )   s
             (   0    0    I   )   n-k
                k-s   s   n-k

  If s = 1, D(k) overwrites A(k,k), and v overwrites A(1:k-1,k).
  If s = 2, the upper triangle of D(k) overwrites A(k-1,k-1), A(k-1,k),
  and A(k,k), and v overwrites A(1:k-2,k-1:k).

  If UPLO = 'L', then A = L*D*L**T, where
     L = P(1)*L(1)* ... *P(k)*L(k)* ...,
  i.e., L is a product of terms P(k)*L(k), where k increases from 1 to
  n in steps of 1 or 2, and D is a block diagonal matrix with 1-by-1
  and 2-by-2 diagonal blocks D(k).  P(k) is a permutation matrix as
  defined by IPIV(k), and L(k) is a unit lower triangular matrix, such
  that if the diagonal block D(k) is of order s (s = 1 or 2), then

             (   I    0     0   )  k-1
     L(k) =  (   0    I     0   )  s
             (   0    v     I   )  n-k-s+1
                k-1   s  n-k-s+1

  If s = 1, D(k) overwrites A(k,k), and v overwrites A(k+1:n,k).
  If s = 2, the lower triangle of D(k) overwrites A(k,k), A(k+1,k),
  and A(k+1,k+1), and v overwrites A(k+2:n,k:k+1).
Contributors:
  09-29-06 - patch from
    Bobby Cheng, MathWorks

    Replace l.204 and l.372
         IF( MAX( ABSAKK, COLMAX ).EQ.ZERO ) THEN
    by
         IF( (MAX( ABSAKK, COLMAX ).EQ.ZERO) .OR. SISNAN(ABSAKK) ) THEN

  01-01-96 - Based on modifications by
    J. Lewis, Boeing Computer Services Company
    A. Petitet, Computer Science Dept., Univ. of Tenn., Knoxville, USA
  1-96 - Based on modifications by J. Lewis, Boeing Computer Services
         Company

Definition at line 194 of file ssytf2.f.

195 *
196 * -- LAPACK computational routine --
197 * -- LAPACK is a software package provided by Univ. of Tennessee, --
198 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
199 *
200 * .. Scalar Arguments ..
201  CHARACTER UPLO
202  INTEGER INFO, LDA, N
203 * ..
204 * .. Array Arguments ..
205  INTEGER IPIV( * )
206  REAL A( LDA, * )
207 * ..
208 *
209 * =====================================================================
210 *
211 * .. Parameters ..
212  REAL ZERO, ONE
213  parameter( zero = 0.0e+0, one = 1.0e+0 )
214  REAL EIGHT, SEVTEN
215  parameter( eight = 8.0e+0, sevten = 17.0e+0 )
216 * ..
217 * .. Local Scalars ..
218  LOGICAL UPPER
219  INTEGER I, IMAX, J, JMAX, K, KK, KP, KSTEP
220  REAL ABSAKK, ALPHA, COLMAX, D11, D12, D21, D22, R1,
221  $ ROWMAX, T, WK, WKM1, WKP1
222 * ..
223 * .. External Functions ..
224  LOGICAL LSAME, SISNAN
225  INTEGER ISAMAX
226  EXTERNAL lsame, isamax, sisnan
227 * ..
228 * .. External Subroutines ..
229  EXTERNAL sscal, sswap, ssyr, xerbla
230 * ..
231 * .. Intrinsic Functions ..
232  INTRINSIC abs, max, sqrt
233 * ..
234 * .. Executable Statements ..
235 *
236 * Test the input parameters.
237 *
238  info = 0
239  upper = lsame( uplo, 'U' )
240  IF( .NOT.upper .AND. .NOT.lsame( uplo, 'L' ) ) THEN
241  info = -1
242  ELSE IF( n.LT.0 ) THEN
243  info = -2
244  ELSE IF( lda.LT.max( 1, n ) ) THEN
245  info = -4
246  END IF
247  IF( info.NE.0 ) THEN
248  CALL xerbla( 'SSYTF2', -info )
249  RETURN
250  END IF
251 *
252 * Initialize ALPHA for use in choosing pivot block size.
253 *
254  alpha = ( one+sqrt( sevten ) ) / eight
255 *
256  IF( upper ) THEN
257 *
258 * Factorize A as U*D*U**T using the upper triangle of A
259 *
260 * K is the main loop index, decreasing from N to 1 in steps of
261 * 1 or 2
262 *
263  k = n
264  10 CONTINUE
265 *
266 * If K < 1, exit from loop
267 *
268  IF( k.LT.1 )
269  $ GO TO 70
270  kstep = 1
271 *
272 * Determine rows and columns to be interchanged and whether
273 * a 1-by-1 or 2-by-2 pivot block will be used
274 *
275  absakk = abs( a( k, k ) )
276 *
277 * IMAX is the row-index of the largest off-diagonal element in
278 * column K, and COLMAX is its absolute value.
279 * Determine both COLMAX and IMAX.
280 *
281  IF( k.GT.1 ) THEN
282  imax = isamax( k-1, a( 1, k ), 1 )
283  colmax = abs( a( imax, k ) )
284  ELSE
285  colmax = zero
286  END IF
287 *
288  IF( (max( absakk, colmax ).EQ.zero) .OR. sisnan(absakk) ) THEN
289 *
290 * Column K is zero or underflow, or contains a NaN:
291 * set INFO and continue
292 *
293  IF( info.EQ.0 )
294  $ info = k
295  kp = k
296  ELSE
297  IF( absakk.GE.alpha*colmax ) THEN
298 *
299 * no interchange, use 1-by-1 pivot block
300 *
301  kp = k
302  ELSE
303 *
304 * JMAX is the column-index of the largest off-diagonal
305 * element in row IMAX, and ROWMAX is its absolute value
306 *
307  jmax = imax + isamax( k-imax, a( imax, imax+1 ), lda )
308  rowmax = abs( a( imax, jmax ) )
309  IF( imax.GT.1 ) THEN
310  jmax = isamax( imax-1, a( 1, imax ), 1 )
311  rowmax = max( rowmax, abs( a( jmax, imax ) ) )
312  END IF
313 *
314  IF( absakk.GE.alpha*colmax*( colmax / rowmax ) ) THEN
315 *
316 * no interchange, use 1-by-1 pivot block
317 *
318  kp = k
319  ELSE IF( abs( a( imax, imax ) ).GE.alpha*rowmax ) THEN
320 *
321 * interchange rows and columns K and IMAX, use 1-by-1
322 * pivot block
323 *
324  kp = imax
325  ELSE
326 *
327 * interchange rows and columns K-1 and IMAX, use 2-by-2
328 * pivot block
329 *
330  kp = imax
331  kstep = 2
332  END IF
333  END IF
334 *
335  kk = k - kstep + 1
336  IF( kp.NE.kk ) THEN
337 *
338 * Interchange rows and columns KK and KP in the leading
339 * submatrix A(1:k,1:k)
340 *
341  CALL sswap( kp-1, a( 1, kk ), 1, a( 1, kp ), 1 )
342  CALL sswap( kk-kp-1, a( kp+1, kk ), 1, a( kp, kp+1 ),
343  $ lda )
344  t = a( kk, kk )
345  a( kk, kk ) = a( kp, kp )
346  a( kp, kp ) = t
347  IF( kstep.EQ.2 ) THEN
348  t = a( k-1, k )
349  a( k-1, k ) = a( kp, k )
350  a( kp, k ) = t
351  END IF
352  END IF
353 *
354 * Update the leading submatrix
355 *
356  IF( kstep.EQ.1 ) THEN
357 *
358 * 1-by-1 pivot block D(k): column k now holds
359 *
360 * W(k) = U(k)*D(k)
361 *
362 * where U(k) is the k-th column of U
363 *
364 * Perform a rank-1 update of A(1:k-1,1:k-1) as
365 *
366 * A := A - U(k)*D(k)*U(k)**T = A - W(k)*1/D(k)*W(k)**T
367 *
368  r1 = one / a( k, k )
369  CALL ssyr( uplo, k-1, -r1, a( 1, k ), 1, a, lda )
370 *
371 * Store U(k) in column k
372 *
373  CALL sscal( k-1, r1, a( 1, k ), 1 )
374  ELSE
375 *
376 * 2-by-2 pivot block D(k): columns k and k-1 now hold
377 *
378 * ( W(k-1) W(k) ) = ( U(k-1) U(k) )*D(k)
379 *
380 * where U(k) and U(k-1) are the k-th and (k-1)-th columns
381 * of U
382 *
383 * Perform a rank-2 update of A(1:k-2,1:k-2) as
384 *
385 * A := A - ( U(k-1) U(k) )*D(k)*( U(k-1) U(k) )**T
386 * = A - ( W(k-1) W(k) )*inv(D(k))*( W(k-1) W(k) )**T
387 *
388  IF( k.GT.2 ) THEN
389 *
390  d12 = a( k-1, k )
391  d22 = a( k-1, k-1 ) / d12
392  d11 = a( k, k ) / d12
393  t = one / ( d11*d22-one )
394  d12 = t / d12
395 *
396  DO 30 j = k - 2, 1, -1
397  wkm1 = d12*( d11*a( j, k-1 )-a( j, k ) )
398  wk = d12*( d22*a( j, k )-a( j, k-1 ) )
399  DO 20 i = j, 1, -1
400  a( i, j ) = a( i, j ) - a( i, k )*wk -
401  $ a( i, k-1 )*wkm1
402  20 CONTINUE
403  a( j, k ) = wk
404  a( j, k-1 ) = wkm1
405  30 CONTINUE
406 *
407  END IF
408 *
409  END IF
410  END IF
411 *
412 * Store details of the interchanges in IPIV
413 *
414  IF( kstep.EQ.1 ) THEN
415  ipiv( k ) = kp
416  ELSE
417  ipiv( k ) = -kp
418  ipiv( k-1 ) = -kp
419  END IF
420 *
421 * Decrease K and return to the start of the main loop
422 *
423  k = k - kstep
424  GO TO 10
425 *
426  ELSE
427 *
428 * Factorize A as L*D*L**T using the lower triangle of A
429 *
430 * K is the main loop index, increasing from 1 to N in steps of
431 * 1 or 2
432 *
433  k = 1
434  40 CONTINUE
435 *
436 * If K > N, exit from loop
437 *
438  IF( k.GT.n )
439  $ GO TO 70
440  kstep = 1
441 *
442 * Determine rows and columns to be interchanged and whether
443 * a 1-by-1 or 2-by-2 pivot block will be used
444 *
445  absakk = abs( a( k, k ) )
446 *
447 * IMAX is the row-index of the largest off-diagonal element in
448 * column K, and COLMAX is its absolute value.
449 * Determine both COLMAX and IMAX.
450 *
451  IF( k.LT.n ) THEN
452  imax = k + isamax( n-k, a( k+1, k ), 1 )
453  colmax = abs( a( imax, k ) )
454  ELSE
455  colmax = zero
456  END IF
457 *
458  IF( (max( absakk, colmax ).EQ.zero) .OR. sisnan(absakk) ) THEN
459 *
460 * Column K is zero or underflow, or contains a NaN:
461 * set INFO and continue
462 *
463  IF( info.EQ.0 )
464  $ info = k
465  kp = k
466  ELSE
467  IF( absakk.GE.alpha*colmax ) THEN
468 *
469 * no interchange, use 1-by-1 pivot block
470 *
471  kp = k
472  ELSE
473 *
474 * JMAX is the column-index of the largest off-diagonal
475 * element in row IMAX, and ROWMAX is its absolute value
476 *
477  jmax = k - 1 + isamax( imax-k, a( imax, k ), lda )
478  rowmax = abs( a( imax, jmax ) )
479  IF( imax.LT.n ) THEN
480  jmax = imax + isamax( n-imax, a( imax+1, imax ), 1 )
481  rowmax = max( rowmax, abs( a( jmax, imax ) ) )
482  END IF
483 *
484  IF( absakk.GE.alpha*colmax*( colmax / rowmax ) ) THEN
485 *
486 * no interchange, use 1-by-1 pivot block
487 *
488  kp = k
489  ELSE IF( abs( a( imax, imax ) ).GE.alpha*rowmax ) THEN
490 *
491 * interchange rows and columns K and IMAX, use 1-by-1
492 * pivot block
493 *
494  kp = imax
495  ELSE
496 *
497 * interchange rows and columns K+1 and IMAX, use 2-by-2
498 * pivot block
499 *
500  kp = imax
501  kstep = 2
502  END IF
503  END IF
504 *
505  kk = k + kstep - 1
506  IF( kp.NE.kk ) THEN
507 *
508 * Interchange rows and columns KK and KP in the trailing
509 * submatrix A(k:n,k:n)
510 *
511  IF( kp.LT.n )
512  $ CALL sswap( n-kp, a( kp+1, kk ), 1, a( kp+1, kp ), 1 )
513  CALL sswap( kp-kk-1, a( kk+1, kk ), 1, a( kp, kk+1 ),
514  $ lda )
515  t = a( kk, kk )
516  a( kk, kk ) = a( kp, kp )
517  a( kp, kp ) = t
518  IF( kstep.EQ.2 ) THEN
519  t = a( k+1, k )
520  a( k+1, k ) = a( kp, k )
521  a( kp, k ) = t
522  END IF
523  END IF
524 *
525 * Update the trailing submatrix
526 *
527  IF( kstep.EQ.1 ) THEN
528 *
529 * 1-by-1 pivot block D(k): column k now holds
530 *
531 * W(k) = L(k)*D(k)
532 *
533 * where L(k) is the k-th column of L
534 *
535  IF( k.LT.n ) THEN
536 *
537 * Perform a rank-1 update of A(k+1:n,k+1:n) as
538 *
539 * A := A - L(k)*D(k)*L(k)**T = A - W(k)*(1/D(k))*W(k)**T
540 *
541  d11 = one / a( k, k )
542  CALL ssyr( uplo, n-k, -d11, a( k+1, k ), 1,
543  $ a( k+1, k+1 ), lda )
544 *
545 * Store L(k) in column K
546 *
547  CALL sscal( n-k, d11, a( k+1, k ), 1 )
548  END IF
549  ELSE
550 *
551 * 2-by-2 pivot block D(k)
552 *
553  IF( k.LT.n-1 ) THEN
554 *
555 * Perform a rank-2 update of A(k+2:n,k+2:n) as
556 *
557 * A := A - ( (A(k) A(k+1))*D(k)**(-1) ) * (A(k) A(k+1))**T
558 *
559 * where L(k) and L(k+1) are the k-th and (k+1)-th
560 * columns of L
561 *
562  d21 = a( k+1, k )
563  d11 = a( k+1, k+1 ) / d21
564  d22 = a( k, k ) / d21
565  t = one / ( d11*d22-one )
566  d21 = t / d21
567 *
568  DO 60 j = k + 2, n
569 *
570  wk = d21*( d11*a( j, k )-a( j, k+1 ) )
571  wkp1 = d21*( d22*a( j, k+1 )-a( j, k ) )
572 *
573  DO 50 i = j, n
574  a( i, j ) = a( i, j ) - a( i, k )*wk -
575  $ a( i, k+1 )*wkp1
576  50 CONTINUE
577 *
578  a( j, k ) = wk
579  a( j, k+1 ) = wkp1
580 *
581  60 CONTINUE
582  END IF
583  END IF
584  END IF
585 *
586 * Store details of the interchanges in IPIV
587 *
588  IF( kstep.EQ.1 ) THEN
589  ipiv( k ) = kp
590  ELSE
591  ipiv( k ) = -kp
592  ipiv( k+1 ) = -kp
593  END IF
594 *
595 * Increase K and return to the start of the main loop
596 *
597  k = k + kstep
598  GO TO 40
599 *
600  END IF
601 *
602  70 CONTINUE
603 *
604  RETURN
605 *
606 * End of SSYTF2
607 *
logical function sisnan(SIN)
SISNAN tests input for NaN.
Definition: sisnan.f:59
integer function isamax(N, SX, INCX)
ISAMAX
Definition: isamax.f:71
subroutine xerbla(SRNAME, INFO)
XERBLA
Definition: xerbla.f:60
logical function lsame(CA, CB)
LSAME
Definition: lsame.f:53
subroutine sswap(N, SX, INCX, SY, INCY)
SSWAP
Definition: sswap.f:82
subroutine sscal(N, SA, SX, INCX)
SSCAL
Definition: sscal.f:79
subroutine ssyr(UPLO, N, ALPHA, X, INCX, A, LDA)
SSYR
Definition: ssyr.f:132
Here is the call graph for this function:
Here is the caller graph for this function: