Program g02cffe
! G02CFF Example Program Text
! Mark 30.1 Release. NAG Copyright 2024.
! .. Use Statements ..
Use nag_library, Only: g02cff, nag_wp, x04caf
! .. Implicit None Statement ..
Implicit None
! .. Parameters ..
Integer, Parameter :: nin = 5, nout = 6
! .. Local Scalars ..
Integer :: i, ifail, ldr, ldssp, n
Character (80) :: fmt
! .. Local Arrays ..
Real (Kind=nag_wp), Allocatable :: r(:,:), ssp(:,:), std(:), xbar(:)
Integer, Allocatable :: korder(:), kwork(:)
! .. Executable Statements ..
Write (nout,*) 'G02CFF Example Program Results'
Write (nout,*)
! Skip heading in data file
Read (nin,*)
! Read in the problem size
Read (nin,*) n
ldr = n
ldssp = n
Allocate (r(ldr,n),ssp(ldssp,n),std(n),xbar(n),korder(n),kwork(n))
! Read in data
Read (nin,*) xbar(1:n)
Read (nin,*) std(1:n)
Read (nin,*)(ssp(i,1:n),i=1,n)
Read (nin,*)(r(i,1:n),i=1,n)
! Read in the reordering vector
Read (nin,*) korder(1:n)
! Format for displaying vectors
Write (fmt,99999) '(1x,A,', n, '(1X,F10.4))'
! Display data
Write (nout,fmt) 'Original vector XBAR : ', xbar(1:n)
Write (nout,*)
Write (nout,fmt) 'Original vector STD : ', std(1:n)
Write (nout,*)
Flush (nout)
ifail = 0
Call x04caf('General',' ',n,n,ssp,ldssp,'Original matrix SSP :',ifail)
Write (nout,*)
Flush (nout)
ifail = 0
Call x04caf('General',' ',n,n,r,ldr,'Original matrix R :',ifail)
Write (nout,*)
! Reorder the results
ifail = 0
Call g02cff(n,korder,xbar,std,ssp,ldssp,r,ldr,kwork,ifail)
! Display results
Write (nout,fmt) 'New vector XBAR : ', xbar(1:n)
Write (nout,*)
Write (nout,fmt) 'New vector STD : ', std(1:n)
Write (nout,*)
Flush (nout)
ifail = 0
Call x04caf('General',' ',n,n,ssp,ldssp,'New matrix SSP :',ifail)
Write (nout,*)
Flush (nout)
ifail = 0
Call x04caf('General',' ',n,n,r,ldr,'New matrix R :',ifail)
99999 Format (A,I0,A)
End Program g02cffe