[Fortran] 纯文本查看 复制代码
program main
use f95_precision
use lapack95
implicit none
integer :: i, j, n, info
integer,allocatable:: ipiv(:)!// ipiv 为整数
complex(8), allocatable :: a(:,:), b(:,:)
n = 3
allocate( ipiv(n) )
allocate( a(n,n), b(n,1) )
a = 0.0
open (5, file='a.txt', status='old') ! input file
do j=1,n
do i=1,n
read(5,*) a(j,i)!//a转置
enddo
enddo
!a = transpose(a)!//或者这样转置
b = 0.0
open (6, file='b.txt', status='old') ! input file
do i=1,n
read(6,*) b(i,1)
enddo
write(*,*)
write(*,*)'matrix a : '
do i=1,n;
write(*,*) (a(i,:));
enddo
write(*,*)
write(*,*)'matrix b : '
do i=1,n;
write(*,*) (b(i,1));
enddo
!call zgetrs( 'n', n, 1, a, n, ipiv, b, n, info )
call getrf(a,ipiv,info)!//先 getrf
call getrs(a,ipiv,b,'n',info) !//后 getrs
write(*,*)
write(*,*)'matrix b : '
do i=1,n;
write(*,*) (b(i,1));
enddo
write(*,*) info
end program main