Program f01lefe
! F01LEF Example Program Text
! Mark 30.0 Release. NAG Copyright 2024.
! .. Use Statements ..
Use nag_library, Only: f01lef, f04lef, nag_wp
! .. Implicit None Statement ..
Implicit None
! .. Parameters ..
Integer, Parameter :: nin = 5, nout = 6
! .. Local Scalars ..
Real (Kind=nag_wp) :: lambda, tol
Integer :: ifail, job, n
! .. Local Arrays ..
Real (Kind=nag_wp), Allocatable :: a(:), b(:), c(:), d(:), y(:)
Integer, Allocatable :: ipiv(:)
! .. Executable Statements ..
Write (nout,*) 'F01LEF Example Program Results'
Write (nout,*)
! Skip heading in data file
Read (nin,*)
Read (nin,*) n
Allocate (a(n),b(n),c(n),d(n),y(n),ipiv(n))
Read (nin,*) a(1:n)
Read (nin,*) b(2:n)
Read (nin,*) c(2:n)
tol = 0.00005E0_nag_wp
lambda = 0.0E0_nag_wp
! ifail: behaviour on error exit
! =0 for hard exit, =1 for quiet-soft, =-1 for noisy-soft
ifail = 0
Call f01lef(n,a,lambda,b,c,tol,d,ipiv,ifail)
If (ipiv(n)/=0) Then
Write (nout,*) 'Matrix is singular or nearly singular'
Write (nout,99999) 'Diagonal element', ipiv(n), 'is small'
Else
Write (nout,*) 'Details of factorization'
Write (nout,*)
Write (nout,*) ' Main diagonal of U'
Write (nout,99998) a(1:n)
Write (nout,*)
Write (nout,*) ' First superdiagonal of U'
Write (nout,99998) b(2:n)
Write (nout,*)
Write (nout,*) ' Second superdiagonal of U'
Write (nout,99998) d(3:n)
Write (nout,*)
Write (nout,*) ' Multipliers'
Write (nout,99998) c(2:n)
Write (nout,*)
Write (nout,*) ' Vector of interchanges'
Write (nout,99997) ipiv(1:(n-1))
Read (nin,*) y(1:n)
job = 1
ifail = 0
Call f04lef(job,n,a,b,c,d,ipiv,y,tol,ifail)
Write (nout,*)
Write (nout,*) ' Solution vector'
Write (nout,99998) y(1:n)
End If
99999 Format (1X,A,I4,A)
99998 Format (1X,8F9.4)
99997 Format (1X,5I9)
End Program f01lefe