我想从DSYEV中找到最小的特征值,我不确定我将在DSYEV的代码中加入什么。
假设我的矩阵A是45x45,我想找到它的特征值。到目前为止,我有:
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
我不确定选择存储上三角矩阵是什么意思。我还不知道LWORK在文档中的含义。
答案 0 :(得分:0)
A
的特征值,但请使用M
A
M
你的矩阵来自哪里?如果你在其他地方计算它们,你可能必须将它们传递给你的子程序。然后你还需要传递尺寸。
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
像这样的东西(不是完整的例子)。
你需要在调用程序中分配你的特征值向量,我确定你需要那里的特征值......
WORK和LWORK并不需要关心你。关于Upper和Lower,在dsyev调用之前和之后查看矩阵A
...