pure subroutine dsyev_rel(matrix, eig_vecr, eig_val)
real(rk), dimension(:,:), intent(in) :: matrix
real(rk), dimension(:,:), allocatable, intent(out) :: eig_vecr
real(rk), dimension(:), allocatable, intent(out) :: eig_val
real(rk), dimension(:), allocatable :: work
real(rk), dimension(size(matrix,1),size(matrix,1)) :: A
integer :: lwork, m, info
real(rk) :: work1(1)
interface
pure subroutine dsyev(fjobz, fuplo, fn, fA, flda, fw, fwork, flwork, finfo)
import rk
character, intent(in) :: fjobz, fuplo
integer, intent(in) :: fn
integer, intent(in) :: flda
integer, intent(in) :: flwork
integer, intent(out) :: finfo
real(rk), intent(inout) :: fA(flda,*)
real(rk), intent(out) :: fw(*)
real(rk), intent(out) :: fwork(*)
end subroutine
end interface
m = size(matrix,1)
A = matrix
call dsyev('V', 'U', m, A, m, eig_val, work1, -1, info)
lwork = nint(work1(1))
allocate(work(lwork))
allocate(eig_vecr(m,m), eig_val(m))
call dsyev('V', 'U', m, A, m, eig_val, work, lwork, info)
eig_vecr = A
deallocate(work)
end subroutine dsyev_rel