Program f08nnfe
! F08NNF Example Program Text
! Mark 26.2 Release. NAG Copyright 2017.
! .. Use Statements ..
Use nag_library, Only: nag_wp, x04daf, zgeev
! .. Implicit None Statement ..
Implicit None
! .. Parameters ..
Integer, Parameter :: nb = 64, nin = 5, nout = 6
! .. Local Scalars ..
Integer :: i, ifail, info, lda, ldvr, lwork, n
! .. Local Arrays ..
Complex (Kind=nag_wp), Allocatable :: a(:,:), vr(:,:), w(:), work(:)
Complex (Kind=nag_wp) :: dummy(1,1)
Real (Kind=nag_wp), Allocatable :: rwork(:)
! .. Intrinsic Procedures ..
Intrinsic :: max, nint, real
! .. Executable Statements ..
Write (nout,*) 'F08NNF Example Program Results'
Write (nout,*)
! Skip heading in data file
Read (nin,*)
Read (nin,*) n
lda = n
ldvr = n
Allocate (a(lda,n),vr(ldvr,n),w(n),rwork(2*n))
! Use routine workspace query to get optimal workspace.
lwork = -1
! The NAG name equivalent of zgeev is f08nnf
Call zgeev('No left vectors','Vectors (right)',n,a,lda,w,dummy,1,vr, &
ldvr,dummy,lwork,rwork,info)
! Make sure that there is enough workspace for block size nb.
lwork = max((nb+1)*n,nint(real(dummy(1,1))))
Allocate (work(lwork))
! Read the matrix A from data file
Read (nin,*)(a(i,1:n),i=1,n)
! Compute the eigenvalues and right eigenvectors of A
! The NAG name equivalent of zgeev is f08nnf
Call zgeev('No left vectors','Vectors (right)',n,a,lda,w,dummy,1,vr, &
ldvr,work,lwork,rwork,info)
If (info==0) Then
! Print solution
Write (nout,*) 'Eigenvalues'
Write (nout,99999) w(1:n)
Write (nout,*)
Flush (nout)
! ifail: behaviour on error exit
! =0 for hard exit, =1 for quiet-soft, =-1 for noisy-soft
ifail = 0
Call x04daf('General',' ',n,n,vr,ldvr,'Eigenvectors',ifail)
Else
Write (nout,*)
Write (nout,99998) 'Failure in ZGEEV. INFO = ', info
End If
99999 Format ((3X,4(' (',F7.4,',',F7.4,')',:)))
99998 Format (1X,A,I4)
End Program f08nnfe