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

NAG FL Interface Introduction
Example description
    Program f08ksfe

!     F08KSF Example Program Text

!     Mark 29.0 Release. NAG Copyright 2023.

!     .. Use Statements ..
      Use nag_library, Only: nag_wp, zgebrd
!     .. Implicit None Statement ..
      Implicit None
!     .. Parameters ..
      Integer, Parameter               :: nin = 5, nout = 6
!     .. Local Scalars ..
      Integer                          :: i, info, lda, lwork, m, n
!     .. Local Arrays ..
      Complex (Kind=nag_wp), Allocatable :: a(:,:), taup(:), tauq(:), work(:)
      Real (Kind=nag_wp), Allocatable  :: d(:), e(:)
!     .. Intrinsic Procedures ..
      Intrinsic                        :: min
!     .. Executable Statements ..
      Write (nout,*) 'F08KSF Example Program Results'
!     Skip heading in data file
      Read (nin,*)
      Read (nin,*) m, n
      lda = m
      lwork = 64*(m+n)
      Allocate (a(lda,n),taup(n),tauq(n),work(lwork),d(n),e(n-1))

!     Read A from data file

      Read (nin,*)(a(i,1:n),i=1,m)

!     Reduce A to bidiagonal form

!     The NAG name equivalent of zgebrd is f08ksf
      Call zgebrd(m,n,a,lda,d,e,tauq,taup,work,lwork,info)

!     Print bidiagonal form

      Write (nout,*)
      Write (nout,*) 'Diagonal'
      Write (nout,99999) d(1:min(m,n))
      If (m>=n) Then
        Write (nout,*) 'Superdiagonal'
      Else
        Write (nout,*) 'Subdiagonal'
      End If
      Write (nout,99999) e(1:min(m,n)-1)

99999 Format (1X,8F9.4)
    End Program f08ksfe