Program f08ah_t1w_fe
! F08AH_T1W_F Example Program Text
! Mark 30.2 Release. NAG Copyright 2024.
! .. Use Statements ..
Use iso_c_binding, Only: c_ptr
Use nagad_library, Only: f08ah_t1w_f, nagad_t1w_get, nagad_t1w_set, &
nagad_t1w_w_rtype, x10aa_t1w_f, x10ab_t1w_f
Use nag_library, Only: nag_wp, x04caf
! .. Implicit None Statement ..
Implicit None
! .. Parameters ..
Integer, Parameter :: nin = 5, nout = 6
! .. Local Scalars ..
Type (c_ptr) :: ad_handle
Integer :: i, ifail, info, j, lda, lwork, m, n
! .. Local Arrays ..
Type (nagad_t1w_w_rtype), Allocatable :: a(:,:), a_in(:,:), tau(:), &
work(:)
Real (Kind=nag_wp), Allocatable :: dlda(:,:), l(:,:)
! .. Executable Statements ..
Write (nout,*) 'F08AH_T1W_F Example Program Results'
! Skip heading in data file
Read (nin,*)
Read (nin,*) m, n
lda = m
lwork = 64*n
Allocate (a(lda,n),a_in(lda,n),l(m,m),dlda(m,n),tau(n),work(lwork))
ifail = 0
Call x10aa_t1w_f(ad_handle,ifail)
! Read A from data file
Read (nin,*)(a_in(i,1:n)%value,i=1,m)
Do i = 1, m
Do j = 1, n
Call nagad_t1w_set(a_in(i,j),0.0_nag_wp,1)
End Do
End Do
a = a_in
Do i = 1, n
Call nagad_t1w_set(a(1,i),1.0_nag_wp,1)
! Compute the LQ factorization of A
! The NAG name equivalent of dgelqf_t1w is f08ah_t1w_f
Call f08ah_t1w_f(ad_handle,m,n,a,lda,tau,work,lwork,info)
Do j = 1, m
Call nagad_t1w_get(a(j,j),dlda(j,i),1)
End Do
If (i==1) Then
l(1:m,1:m) = a(1:m,1:m)%value
! Print L
! ifail: behaviour on error exit
! =0 for hard exit, =1 for quiet-soft, =-1 for noisy-soft
ifail = 0
Call x04caf('Lower','Non',m,m,l,m,'L from LQ factorization of A', &
ifail)
End If
a = a_in
End Do
Write (nout,*)
Write (nout,*) 'Derivatives of diagonal of L w.r.t. first row of A'
ifail = 0
Call x04caf('General',' ',m,n,dlda,m,'dL_ii/dA_1j',ifail)
! Remove computational data object
Call x10ab_t1w_f(ad_handle,ifail)
End Program f08ah_t1w_fe