PROGRAM f07jsfe ! F07JSF Example Program Text ! Mark 23 Release. NAG Copyright 2011. ! .. Use Statements .. USE nag_library, ONLY : nag_wp, x04dbf, zpttrf, zpttrs ! .. Implicit None Statement .. IMPLICIT NONE ! .. Parameters .. INTEGER, PARAMETER :: nin = 5, nout = 6 CHARACTER (1), PARAMETER :: uplo = 'U' ! .. Local Scalars .. INTEGER :: i, ifail, info, ldb, n, nrhs ! .. Local Arrays .. COMPLEX (KIND=nag_wp), ALLOCATABLE :: b(:,:), e(:) REAL (KIND=nag_wp), ALLOCATABLE :: d(:) CHARACTER (1) :: clabs(1), rlabs(1) ! .. Executable Statements .. WRITE (nout,*) 'F07JSF Example Program Results' WRITE (nout,*) FLUSH (nout) ! Skip heading in data file READ (nin,*) READ (nin,*) n, nrhs ldb = n ALLOCATE (b(ldb,nrhs),e(n-1),d(n)) ! Read the upper bidiagonal part of the tridiagonal matrix A from ! data file READ (nin,*) e(1:n-1) READ (nin,*) d(1:n) ! Read the right hand matrix B READ (nin,*) (b(i,1:nrhs),i=1,n) ! Factorize the tridiagonal matrix A ! The NAG name equivalent of zpttrf is f07jrf CALL zpttrf(n,d,e,info) IF (info==0) THEN ! Solve the equations AX = B ! The NAG name equivalent of zpttrs is f07jsf CALL zpttrs(uplo,n,nrhs,d,e,b,ldb,info) ! Print the solution ! ifail: behaviour on error exit ! =0 for hard exit, =1 for quiet-soft, =-1 for noisy-soft ifail = 0 CALL x04dbf('General',' ',n,nrhs,b,ldb,'Bracketed',' ', & 'Solution(s)','Integer',rlabs,'Integer',clabs,80,0,ifail) ELSE WRITE (nout,99999) 'The leading minor of order ', info, & ' is not positive definite' END IF 99999 FORMAT (1X,A,I3,A) END PROGRAM f07jsfe