求计算本征值和本征矢的程序

来源:百度知道 编辑:UC知道 时间:2024/06/04 09:15:23
求计算本征值和本征矢的程序,用fortran语言写的,计算非对称矩阵。

有点长哦,去年写的,改矩阵看注释部分

!==================Fortran不会区分大小写,注意变量的命名!!======================
!============================IN==变量声明模块==================================
module IN
implicit none
integer,parameter::dimen=5 !@@换矩阵维数时需要修改
real(kind=8)::A(dimen,dimen),A1(dimen,dimen)
real(kind=8)::err=1E-6
contains
!设置矩阵,@@换矩阵时需要修改
subroutine inp()
A(:,1)=(/4,2,2,5,8/)
A(:,2)=(/2,5,1,3,4/)
A(:,3)=(/2,1,6,2,6/)
A(:,4)=(/5,3,2,1,3/)
A(:,5)=(/8,4,6,3,3/)
end subroutine
!格式化输出矩阵
subroutine output(matrix)
implicit none
integer::m,n
real(kind=8)::matrix(:,:)
integer::i
character(len=20)::for='(??(1x,f13.8))'
m=size(matrix,1)
n=size(matrix,2)
write(for(2:3),'(I2)')n
do i=1,m
write(*,fmt=for)matrix(:,i)
end do
return
end subroutine
end module
!==