Program f07ca_p0w_fe
! F07CA_P0W_F Example Program Text
! Mark 28.5 Release. NAG Copyright 2022.
! .. Use Statements ..
Use iso_c_binding, Only: c_ptr
Use nagad_library, Only: f07ca_p0w_f
Use nag_library, Only: nag_wp
! .. Implicit None Statement ..
Implicit None
! .. Parameters ..
Integer, Parameter :: nin = 5, nout = 6, nrhs = 1
! .. Local Scalars ..
Type (c_ptr) :: ad_handle
Integer :: ifail, n
! .. Local Arrays ..
Real (Kind=nag_wp), Allocatable :: d(:), dl(:), du(:), x(:)
! .. Executable Statements ..
Write (nout,*) 'F07CA_P0W_F Example Program Results'
Write (nout,*)
! Skip heading in data file
Read (nin,*)
Read (nin,*) n
Allocate (x(n),d(n),dl(n-1),du(n-1))
! Read the tridiagonal matrix A and the right hand side B from
! data file and initialize AD arrays
Read (nin,*) du(1:n-1)
Read (nin,*) d(1:n)
Read (nin,*) dl(1:n-1)
Read (nin,*) x(1:n)
! Solve the equations Ax = b for x
! The NAG name equivalent of dgtsv is f07ca_p0w_f
ifail = 0
Call f07ca_p0w_f(ad_handle,n,nrhs,dl,d,du,x,n,ifail)
If (ifail==0) Then
! Print primal solution
Write (nout,*) 'Solution'
Write (nout,99999) x(1:n)
Else
Write (nout,99998) 'Element U(', ifail, ',', ifail, ') is zero'
Go To 100
End If
99999 Format ((1X,7F11.4))
99998 Format (1X,A,I0,A,I0,A)
100 Continue
End Program f07ca_p0w_fe