    Program f01vkfe

!     F01VKF Example Program Text

!     Mark 24 Release. NAG Copyright 2012.

!     .. Use Statements ..
      Use nag_library, Only: nag_wp, x04dbf, ztpttf
!     .. Implicit None Statement ..
      Implicit None
!     .. Parameters ..
      Integer, Parameter               :: inc1 = 1, indent = 0, ncols = 80,    &
                                          nin = 5, nout = 6
      Character (1), Parameter         :: brac = 'B', diag = 'N', intlabel =   &
                                          'I', matrix = 'G', nolabel = 'N'
      Character (4), Parameter         :: form = 'F5.2'
!     .. Local Scalars ..
      Integer                          :: ifail, info, lenap, lenarf, n
      Character (21)                   :: title
      Character (1)                    :: transr, uplo
!     .. Local Arrays ..
      Complex (Kind=nag_wp), Allocatable :: ap(:), arf(:)
      Character (1)                    :: clabs(1), rlabs(1)
!     .. Executable Statements ..
      Write (nout,*) 'F01VKF Example Program Results'
!     Skip heading in data file
      Read (nin,*)
      Write (nout,*)
      Flush (nout)
      Read (nin,*) n, uplo, transr
      lenap = (n*(n+1))/2
      lenarf = lenap

      Allocate (ap(lenap),arf(lenarf))

!     Read an order n matrix packed into a 1-D array
      Read (nin,*) ap

!     Print the packed vector
      title = 'Packed Array AP:     '
      ifail = 0
      Call x04dbf(matrix,diag,lenap,inc1,ap,lenap,brac,form,title,intlabel, &
        rlabs,nolabel,clabs,ncols,indent,ifail)

      Write (nout,*)
      Flush (nout)

!     Convert to Rectangular Full Packed form
      info = 0
!     The NAG name equivalent of ztpttf is f01vkf
      Call ztpttf(transr,uplo,n,ap,arf,info)

!     Print the Rectangular Full Packed array
      title = 'RFP Packed Array ARF:'
      ifail = 0
      Call x04dbf(matrix,diag,lenarf,inc1,arf,lenarf,brac,form,title,intlabel, &
        rlabs,nolabel,clabs,ncols,indent,ifail)

    End Program f01vkfe
