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

NAG FL Interface Introduction
Example description
    Program x04dcfe

!     X04DCF Example Program Text

!     Mark 28.5 Release. NAG Copyright 2022.

!     .. Use Statements ..
      Use nag_library, Only: nag_wp, x04dcf, ztrttp
!     .. Implicit None Statement ..
      Implicit None
!     .. Parameters ..
      Integer, Parameter               :: n = 4, nout = 6
!     .. Local Scalars ..
      Real (Kind=nag_wp)               :: aa
      Integer                          :: i, ifail, info, j, lda
      Character (1)                    :: uplo
!     .. Local Arrays ..
      Complex (Kind=nag_wp), Allocatable :: a(:,:), ap(:)
!     .. Intrinsic Procedures ..
      Intrinsic                        :: cmplx, real
!     .. Executable Statements ..
      Write (nout,*) 'X04DCF Example Program Results'

      Write (nout,*)
      Flush (nout)

!     Generate a full-format symmetric array of data

      lda = n
      Allocate (a(lda,n))

      Do j = 1, n

        Do i = 1, j
          aa = real(10*i+j,kind=nag_wp)
          a(i,j) = cmplx(aa,-aa,kind=nag_wp)
          a(j,i) = a(i,j)
        End Do

      End Do

!     Print order (n-1) lower triangular matrix

!     Convert a to packed storage.

      Allocate (ap(n*(n+1)/2))

!     The lower triangle.

      uplo = 'L'

!     The NAG name equivalent of ztrttp is f01vbf
      Call ztrttp(uplo,n-1,a,lda,ap,info)

      If (info/=0) Then
        Write (nout,99999) 'Failure in ZTRTTP. INFO =', info
        Go To 100
      End If

      ifail = 0
      Call x04dcf('Lower','Unit',n-1,ap,'Example 1:',ifail)

      Write (nout,*)
      Flush (nout)

!     Print order n upper triangular matrix

!     Convert the upper triangle of a to packed storage.

      uplo = 'U'

!     The NAG name equivalent of ztrttp is f01vbf
      Call ztrttp(uplo,n,a,lda,ap,info)

      If (info/=0) Then
        Write (nout,99999) 'Failure in ZTRTTP. INFO =', info
        Go To 100
      End If

      ifail = 0
      Call x04dcf('Upper','Non-unit',n,ap,'Example 2:',ifail)

100   Continue

99999 Format (1X,A,I4)
    End Program x04dcfe