Reputation: 27
I want to find the smallest eigenvalue from DSYEV and I'm not sure what I'm meant to put into the code for DSYEV.
Say my matrix A is 45x45 and I want to find its eigenvalues. So far I have:
subroutine eigenvalues()
implicit none
real(kind=8),allocatable,dimension(:,:)::A
real(kind=8),allocatable,dimension(:)::WORK, W
integer, allocatable, dimension(:)::t
integer::info,k,Z
t = shape(A)
k = t(1)
allocate(W(k))
print *, shape(M)
Z = 3*k-1
call dsyev('N','U',k,M,k,W,WORK,Z,info)
end subroutine eigenvalues
I'm not really sure what is meant by choosing to store the upper triangular matrix either. I don't know what LWORK means from the documentation still.
Upvotes: 0
Views: 2232
Reputation: 345
A
but call your dsyev with M
A
M
Where do your matrices come from? You may have to pass them to your subroutine if you calculate them somewhere else. Then you need to pass the dimensions also.
subroutine eigenvalues(A,k,k,eigvalues)
!calling list
integer, intent(in) :: k
double precision, intent(inout) :: A(k,k), eigvalues(k)
!local
double precision,allocatable :: work(:)
integer :: lwork,info
lwork = max(1,3*k-1)
allocate(work(lwork))
call dsyev('N','U',k,A,k,eigvalues,WORK,LWORK,info)
if(info .neq. 0) exit
Something like this (not complete example).
You will need to allocate your eigenvalue vector in the calling routine aswell, im sure you need the eigenvalues there...
WORK and LWORK don't really need to concern you. About Upper and Lower, look at your matrix A
before and after your dsyev call...
Upvotes: 1