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

求 N阶行列式的程序~~~~,第1张

方法很多啊,你需要什么方法的?(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阶行列式的程序~~~~、、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:聚客百科

原文地址: http://juke.outofmemory.cn/life/3690230.html

()
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-26
下一篇 2023-04-26

发表评论

登录后才能评论

评论列表(0条)

保存