LAPACK  3.6.1
LAPACK: Linear Algebra PACKage
subroutine dsytf2 ( character  UPLO,
integer  N,
double precision, dimension( lda, * )  A,
integer  LDA,
integer, dimension( * )  IPIV,
integer  INFO 
)

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

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

Purpose:
 DSYTF2 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 DOUBLE PRECISION 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. DISNAN(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 196 of file dsytf2.f.

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