LAPACK  3.6.1
LAPACK: Linear Algebra PACKage
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.
Date
November 2013
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 197 of file ssytf2.f.

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

Here is the call graph for this function:

Here is the caller graph for this function: