[Fortran] 纯文本查看 复制代码
Subroutine Test_GeTrfTri!矩阵分解成LU,并求逆阵
use lapack95
implicit none
real::a(3,3)=(/1,3,1,1,2,3,3,2,1/)
integer::ipiv(3),info=1
!integer::work(1)=3
write(*,*) a(1,:)
write(*,*) a(2,:)
write(*,*) a(3,:)
ipiv=3
!call sgetrf(3,3,a,3,ipiv,info)!Fortran77接口矩阵分解成LU
!call sgetri(3,a,3,ipiv,work(1),3,info)!求逆阵
call getrf(a,ipiv=ipiv)!Fortran95简化接口
!call getrf(a)
call getri(a,ipiv=ipiv,info=info)
write(*,*) info
write(*,*) ipiv
write(*,*) a(1,:)
write(*,*) a(2,:)
write(*,*) a(3,:)
End subroutine