Program f07cdfe
! F07CDF Example Program Text
! Mark 27.3 Release. NAG Copyright 2021.
! .. Use Statements ..
Use nag_library, Only: dgttrf, nag_wp
! .. Implicit None Statement ..
Implicit None
! .. Parameters ..
Integer, Parameter :: nin = 5, nout = 6
! .. Local Scalars ..
Integer :: info, n
! .. Local Arrays ..
Real (Kind=nag_wp), Allocatable :: d(:), dl(:), du(:), du2(:)
Integer, Allocatable :: ipiv(:)
! .. Executable Statements ..
Write (nout,*) 'F07CDF Example Program Results'
Write (nout,*)
! Skip heading in data file
Read (nin,*)
Read (nin,*) n
Allocate (d(n),dl(n-1),du(n-1),du2(n-2),ipiv(n))
! Read the tridiagonal matrix A from data file
Read (nin,*) du(1:n-1)
Read (nin,*) d(1:n)
Read (nin,*) dl(1:n-1)
! Factorize the tridiagonal matrix A
! The NAG name equivalent of dgttrf is f06cdf
Call dgttrf(n,dl,d,du,du2,ipiv,info)
If (info>0) Then
Write (nout,99999) 'The (', info, ',', info, ')', &
' element of the factor U is zero'
End If
! Print details of the factorization
Write (nout,*) 'Details of factorization'
Write (nout,*)
Write (nout,*) ' Second superdiagonal of U'
Write (nout,99998) du2(1:n-2)
Write (nout,*)
Write (nout,*) ' First superdiagonal of U'
Write (nout,99998) du(1:n-1)
Write (nout,*)
Write (nout,*) ' Main diagonal of U'
Write (nout,99998) d(1:n)
Write (nout,*)
Write (nout,*) ' Multipliers'
Write (nout,99998) dl(1:n-1)
Write (nout,*)
Write (nout,*) ' Vector of interchanges'
Write (nout,99997) ipiv(1:n)
99999 Format (1X,A,I3,A,I3,A,A)
99998 Format (1X,8F9.4)
99997 Format (1X,5I9)
End Program f07cdfe