exchangers,
I have run into a bit of a puzzling problem. To solve an complex eigenvalue-problem, I make use of the LAPACK library function ZHEEV. To test the implementation I used a real symmetric matrix:
\begin{align*} \left[ \begin{array}{c c c c} 2 & 0 & 2 & 0 \\ 0 & 2 & 0 & 2 \\ 2 & 0 & 2 & 0 \\ 0 & 2 & 0 & 2 \\ \end{array} \right] \end{align*}
which should have eigenvalues: 2x0, 2x4 Using ZHEEV I get however 2x -2 and 2x 2. Modifying the implementation to use DSYEV on the other hand gives the correct results.
I am missing something very trivial here, but I do not see what it is.
This is the subroutine:
subroutine solvearray(m)
complex(16), dimension(:,:),allocatable :: dm
complex(16), dimension(:), allocatable :: freq, work
complex(16) :: One
doubleprecision, dimension(:),allocatable :: w, rwork
integer,dimension(:,:),allocatable, intent(inout) :: m
integer :: n, k, h, l, info
One = cmplx(1.0,0.0,kind=SELECTED_REAL_KIND(15,300))
write(*,'(A)',advance='no') 'order of matrix = '
read(*,*) n
l = 2*n - 1
allocate(work(2*l), rwork(3*n-2), w(n))
w = 0.0
work = 0.0 *One
rwork = 0.0
info = 0
allocate(dm(1:n,1:n))
dm(1:n,1:n) = m(1:n,1:n)*One
write(*,*) 'Setup for lapack workspace has been completed.'
call ZHEEV('V','U', n, dm, n, w, work, 2*l, rwork, info)
write(*,*) 'This is the eigenvector matrix:'
do k=1,n
write(*,'(255F8.4)') dm(k,1:n)
end do
write(*,*) 'These are the eigenvalues :'
write(*,'(255F8.4)') w
deallocate(m)
deallocate(W,Work,rwork)
end subroutine
zheev
should give the correct results is reasonable. You likely have a bug in your code or possibly one in your lapack library. $\endgroup$