PROGRAM f08uefe ! F08UEF Example Program Text ! Mark 23 Release. NAG Copyright 2011. ! .. Use Statements .. USE nag_library, ONLY : dpbstf, dsbgst, dsbtrd, dsterf, nag_wp ! .. Implicit None Statement .. IMPLICIT NONE ! .. Parameters .. INTEGER, PARAMETER :: nin = 5, nout = 6 ! .. Local Scalars .. INTEGER :: i, info, j, ka, kb, ldab, ldbb, ldx, n CHARACTER (1) :: uplo ! .. Local Arrays .. REAL (KIND=nag_wp), ALLOCATABLE :: ab(:,:), bb(:,:), d(:), e(:), & work(:), x(:,:) ! .. Intrinsic Functions .. INTRINSIC max, min ! .. Executable Statements .. WRITE (nout,*) 'F08UEF Example Program Results' ! Skip heading in data file READ (nin,*) READ (nin,*) n, ka, kb ldab = ka + 1 ldbb = kb + 1 ldx = n ALLOCATE (ab(ldab,n),bb(ldbb,n),d(n),e(n-1),work(2*n),x(ldx,n)) ! Read A and B from data file READ (nin,*) uplo IF (uplo=='U') THEN DO i = 1, n READ (nin,*) (ab(ka+1+i-j,j),j=i,min(n,i+ka)) END DO DO i = 1, n READ (nin,*) (bb(kb+1+i-j,j),j=i,min(n,i+kb)) END DO ELSE IF (uplo=='L') THEN DO i = 1, n READ (nin,*) (ab(1+i-j,j),j=max(1,i-ka),i) END DO DO i = 1, n READ (nin,*) (bb(1+i-j,j),j=max(1,i-kb),i) END DO END IF ! Compute the split Cholesky factorization of B ! The NAG name equivalent of dpbstf is f08uff CALL dpbstf(uplo,n,kb,bb,ldbb,info) WRITE (nout,*) IF (info>0) THEN WRITE (nout,*) 'B is not positive definite.' ELSE ! Reduce the problem to standard form C*y = lambda*y, storing ! the result in A ! The NAG name equivalent of dsbgst is f08uef CALL dsbgst('N',uplo,n,ka,kb,ab,ldab,bb,ldbb,x,ldx,work,info) ! Reduce C to tridiagonal form T = (Q**T)*C*Q ! The NAG name equivalent of dsbtrd is f08hef CALL dsbtrd('N',uplo,n,ka,ab,ldab,d,e,x,ldx,work,info) ! Calclate the eigenvalues of T (same as C) ! The NAG name equivalent of dsterf is f08jff CALL dsterf(n,d,e,info) IF (info>0) THEN WRITE (nout,*) 'Failure to converge.' ELSE ! Print eigenvalues WRITE (nout,*) 'Eigenvalues' WRITE (nout,99999) d(1:n) END IF END IF 99999 FORMAT (3X,(8F8.4)) END PROGRAM f08uefe