NAG Library Manual, Mark 30.1
Interfaces:  FL   CL   CPP   AD 

NAG FL Interface Introduction
Example description
    Program f01vffe

!     F01VFF Example Program Text

!     Mark 30.1 Release. NAG Copyright 2024.

!     .. Use Statements ..
      Use nag_library, Only: nag_wp, x04dbf, ztrttf
!     .. 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                          :: i, ifail, info, k, lar1, lar2, lda,  &
                                          lenar, n, q
      Character (47)                   :: title
      Character (1)                    :: transr, uplo
!     .. Local Arrays ..
      Complex (Kind=nag_wp), Allocatable :: a(:,:), ar(:)
      Character (1)                    :: clabs(1), rlabs(1)
!     .. Executable Statements ..
      Write (nout,*) 'F01VFF Example Program Results'
      Write (nout,*)
      Flush (nout)
!     Skip heading in data file
      Read (nin,*)
      Read (nin,*) n, uplo, transr
      lda = n
      lenar = n*(n+1)/2
      Allocate (a(lda,n),ar(lenar))

!     Read a triangular matrix of order n into array A
      Do i = 1, n
        Read (nin,*) a(i,i:n)
      End Do

!     Print the unpacked array
      title = 'Unpacked Matrix A:'
      ifail = 0
      Call x04dbf(uplo,diag,n,n,a,lda,brac,form,title,intlabel,rlabs,intlabel, &
        clabs,ncols,indent,ifail)

      Write (nout,*)
      Flush (nout)

!     Convert to Rectangular Full Packed form
!     The NAG name equivalent of ztrttf is f01vff
      Call ztrttf(transr,uplo,n,a,lda,ar,info)

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

      Write (nout,*)
      Flush (nout)

!     Print the Rectangular Full Packed array showing how the elements are
!     arranged.
      title = 'RFP Packed Array AR (graphical representation):'
      k = n/2
      q = n - k
      If (transr=='N' .Or. transr=='n') Then
        lar1 = 2*k + 1
        lar2 = q
      Else
        lar1 = q
        lar2 = 2*k + 1
      End If

      ifail = 0
      Call x04dbf(matrix,diag,lar1,lar2,ar,lar1,brac,form,title,intlabel,      &
        rlabs,intlabel,clabs,ncols,indent,ifail)

    End Program f01vffe