请高手帮我看看这个fortran程序
运行时出现一个错误……帮我看看哪里有错……不胜感谢!雅可比法real*8A(4,4),b(4),x(4)open(1,file='set-yakobi.dat')data...
运行时出现一个错误……帮我看看哪里有错……不胜感谢
!雅可比法
real*8 A(4,4),b(4),x(4)
open(1,file='set-yakobi.dat')
data A/5.0,-1.0,-1.0,-1.0,-1.0,10.0,-1.0,-1.0,-1.0,-1.0,5.0,-1.0,
*-1.0,-1.0,-1.0,10.0/
data b/4.0,12.0,8.0,34.0/
eps=1.0e-05 !迭代终止误差
call yakobi(A,b,4,x,eps)
write(*,*)(x(i),i=1,4)
write(1,*)(x(i),i=1,4)
end
subroutine yakobi(A,b,N,x,eps)
real*8 A(4,4),b(4),x(4),s,t(4),p,q
do 10 i=1,N
10 x(i)=0.0
20 p=0.0
do 50 i=1,N
do 100 k=1,N
100 t(k)=x(k)
s=0.0
do 30 j=1,N
s=s+A(i,j)*t(j)
30 continue
x(i)=x(i)+(b(i)-s)/A(i,i)
q=abs(x(i)-t(i))
if(q.gt.p) p=q
50 continue
if(p.ge.eps)
goto 20
return
end 展开
!雅可比法
real*8 A(4,4),b(4),x(4)
open(1,file='set-yakobi.dat')
data A/5.0,-1.0,-1.0,-1.0,-1.0,10.0,-1.0,-1.0,-1.0,-1.0,5.0,-1.0,
*-1.0,-1.0,-1.0,10.0/
data b/4.0,12.0,8.0,34.0/
eps=1.0e-05 !迭代终止误差
call yakobi(A,b,4,x,eps)
write(*,*)(x(i),i=1,4)
write(1,*)(x(i),i=1,4)
end
subroutine yakobi(A,b,N,x,eps)
real*8 A(4,4),b(4),x(4),s,t(4),p,q
do 10 i=1,N
10 x(i)=0.0
20 p=0.0
do 50 i=1,N
do 100 k=1,N
100 t(k)=x(k)
s=0.0
do 30 j=1,N
s=s+A(i,j)*t(j)
30 continue
x(i)=x(i)+(b(i)-s)/A(i,i)
q=abs(x(i)-t(i))
if(q.gt.p) p=q
50 continue
if(p.ge.eps)
goto 20
return
end 展开
1个回答
展开全部
我这里编译没有问题
结果如下:
2.79166448724679 2.24999911365647 3.45833233369737
4.24999959346006
real*8 A(4,4),b(4),x(4)
open(1,file='set-yakobi.dat')
data A/5.0,-1.0,-1.0,-1.0,-1.0,10.0,-1.0,-1.0,-1.0,-1.0,5.0,-1.0,-1.0,-1.0,-1.0,10.0/
data b/4.0,12.0,8.0,34.0/
eps=1.0e-05 !迭代终止误差
call yakobi(A,b,4,x,eps)
write(*,*)(x(i),i=1,4)
write(1,*)(x(i),i=1,4)
end
subroutine yakobi(A,b,N,x,eps)
real*8 A(4,4),b(4),x(4),s,t(4),p,q
do 10 i=1,N
10 x(i)=0.0
20 p=0.0
do 50 i=1,N
do 100 k=1,N
100 t(k)=x(k)
s=0.0
do 30 j=1,N
s=s+A(i,j)*t(j)
30 continue
x(i)=x(i)+(b(i)-s)/A(i,i)
q=abs(x(i)-t(i))
if(q.gt.p) p=q
50 continue
if(p.ge.eps) then !//这里稍微改了改,If 后面要有 then,和 end if
goto 20
endif
return
end
结果如下:
2.79166448724679 2.24999911365647 3.45833233369737
4.24999959346006
real*8 A(4,4),b(4),x(4)
open(1,file='set-yakobi.dat')
data A/5.0,-1.0,-1.0,-1.0,-1.0,10.0,-1.0,-1.0,-1.0,-1.0,5.0,-1.0,-1.0,-1.0,-1.0,10.0/
data b/4.0,12.0,8.0,34.0/
eps=1.0e-05 !迭代终止误差
call yakobi(A,b,4,x,eps)
write(*,*)(x(i),i=1,4)
write(1,*)(x(i),i=1,4)
end
subroutine yakobi(A,b,N,x,eps)
real*8 A(4,4),b(4),x(4),s,t(4),p,q
do 10 i=1,N
10 x(i)=0.0
20 p=0.0
do 50 i=1,N
do 100 k=1,N
100 t(k)=x(k)
s=0.0
do 30 j=1,N
s=s+A(i,j)*t(j)
30 continue
x(i)=x(i)+(b(i)-s)/A(i,i)
q=abs(x(i)-t(i))
if(q.gt.p) p=q
50 continue
if(p.ge.eps) then !//这里稍微改了改,If 后面要有 then,和 end if
goto 20
endif
return
end
AiPPT
2024-09-19 广告
2024-09-19 广告
随着AI技术的飞速发展,如今市面上涌现了许多实用易操作的AI生成工具1、简介:AiPPT: 这款AI工具智能理解用户输入的主题,提供“AI智能生成”和“导入本地大纲”的选项,生成的PPT内容丰富多样,可自由编辑和添加元素,图表类型包括柱状图...
点击进入详情页
本回答由AiPPT提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询