求 N阶行列式的程序~~~~

入党誓词是什么2023-04-26  27

方法很多啊,你需要什么方法的?(LU,QR,SVD)什么语言编写的?(C,ForTran)
给你一个ForTran编写的Schmidt_QR方法:
cccc --------------- 主程序 ---------------- cccc
ccc --------------- 主程序 ---------------- ccc
program test
real temp
real s,t
allocatable::A(:,:),B(:,:),R(:,:)
call preenter(n,'matrix_Adat')
allocate(A(n,n),B(n,n),R(n,n))
call enter(n,A,'matrix_Adat')
do m=1,n
call prebeita(A,B,R,n,m)
call beita_f2(B,n,m,s)
call beita(B,n,m,s)
call R_array(A,B,R,n,m,s)
end do
call output(B,R,n)
end program
cccc --------------主程序结束---------------- cccc
ccc ---------------------------------------- ccc
cc -------------以下为子程序--------------- cc
ccc cc ccc
subroutine preenter(n,filename)
character() filename
open(10,file=filename,status='old')
read(10,) n
close(10)
end subroutine
cccc cc cccc
subroutine enter(n,A,filename)
real A(n,n)
character() filename
open(10,file=filename,status='old')
read(10,)
read(10,) ((A(i,j),j=1,n),i=1,n)
close(10)
end subroutine
c
subroutine prebeita(A,B,R,n,m)
real A(n,n),B(n,n),R(n,n)
do i=1,n
b(i,m)=00
do k=1,m-1
b(i,m)=b(i,m)+r(k,m)b(i,k)
end do
b(i,m)=a(i,m)-b(i,m)
end do
end subroutine
c
subroutine beita_f2(B,n,m,s)
real B(n,n),s
s=00
do i=1,n
s=s+b(i,m)b(i,m)
end do
s=sqrt(s)
end subroutine
c
subroutine beita(B,n,m,s)
real B(n,n),s
do i=1,n
b(i,m)=b(i,m)/s
end do
end subroutine
c
subroutine inner_multiply(A,B,n,m,t,p)
real A(n,n),B(n,n),t
integer p
t=00
do i=1,n
t=t+a(i,p)b(i,m)
end do
end subroutine
c
subroutine R_array(A,B,R,n,m,s)
real A(n,n),B(n,n),R(n,n),t
r(m,m)=s
do i=m+1,n
call inner_multiply(A,B,n,m,t,i)
r(m,i)=t
end do
end subroutine
c
subroutine output(B,R,n)
real B(n,n),R(n,n)
open(10,file='vector_Xdat',status='unknown')
write(10,) n
do i=1,n
write(10,) (B(i,j),j=1,n)
end do
write(10,) ''
do i=1,n
write(10,) (R(i,j),j=1,n)
end do
end subroutine

以上就是关于求 N阶行列式的程序~~~~全部的内容,包括:求 N阶行列式的程序~~~~、、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

转载请注明原文地址:https://juke.outofmemory.cn/read/3690230.html

最新回复(0)