program dggevexample
implicit none
integer,parameter ::n=3
real*8 :: a(n,n),b(n,n),alpha(n),beta(n)
real*8 :: vl(n,n),vr(n,n)
integer ::lda,ldb,ldvl,ldvr,lwork,info
real*8,allocatable :: work(:)
!Initialize input matrices a and b
a=reshape((/1.0,2.0,3.0,2.0,4.0,5.0,3.8,5.8,6.0/),[n,n])
b=reshape((/1.0,0.0,0.0,0.0,2.6,0.0,0.0,0.0,3.0/),[n,n])
!Set leading dimensions for input matrices
lda =n
ldb =n
!Allocate workspace
lwork = 4*n
allocate(work(lwork))
!Call DGGEV to compute eigenvalues and eigenvectors
call dggev('v','v',n,a,lda,b,ldb, alpha, beta,vl,ldvl,vr,ldvr,work,lwork,info)
!Print results
if(info.eq.0.d0)then
write(*,*)'Eigenvalues:'
write(*,'(3f10.6)')alpha
write(*,*)'Eigenvectors:'
write(*,'(3f10.6)') vl(:,1),vl(:,2),vl(:,3)
else
write(*,*)'Error in DGGEV:',info
end if
!Deallocate workspace
deallocate(work)
end program dggevexample
微信截图_20240709173802.png (105.57 KB, 下载次数: 45)
运行窗口
微信截图_20240709173747.png (181.12 KB, 下载次数: 51)
debug错误显示
欢迎光临 Fortran Coder (http://bbs.fcode.cn/) | Powered by Discuz! X3.2 |