program EConstant
include 'mpif.h'
INTEGER n,ierr,lcv,rank,size,i
DOUBLE PRECISION INTEGER factor, reduc
DOUBLE PRECISION INTEGER redat, redrl, repnt
DOUBLE PRECISION actval, actdiff,erpnt
DOUBLE PRECISION este, reldiff
integer status(MPI_STATUS_SIZE)
call MPI_INIT(ierr)
call MPI_COMM_SIZE(MPI_COMM_WORLD, size, ierr)
call MPI_COMM_RANK(MPI_COMM_WORLD, rank, ierr)
l
actval = 2.71828D0
n=1000
factor = 1.D0
este = 0.D0
DO lcv = rank, n, size
DO i=1,lcv
factor=factor*i
END DO
c factor = factor * lcv
este = este + 1/factor
END DO
actdiff = actval - este
reldiff = actdiff/((actval+este)/2)
erpnt = (actdiff/actval)*100
CALL MPI_REDUCE(este,reduc,1,MPI_DOUBLE_PRECISION,
& MPI_SUM,0,MPI_COMM_WORLD,ierr)
CALL MPI_REDUCE(actdiff,redat,1,MPI_DOUBLE_PRECISION,
& MPI_SUM,0,MPI_COMM_WORLD,ierr)
CALL MPI_REDUCE(reldiff,redrl,1,MPI_DOUBLE_PRECISION,
& MPI_SUM,0,MPI_COMM_WORLD,ierr)
CALL MPI_REDUCE(erpnt,repnt,1,MPI_DOUBLE_PRECISION,
& MPI_SUM,0,MPI_COMM_WORLD,ierr)
if(rank.eq.0)PRINT *,'The estimate of e is: ', reduc
if(rank.eq.0)PRINT *,'Actual difference is: ', redat
if(rank.eq.0)PRINT *,'Relative difference is: ', redrl
if(rank.eq.0)PRINT *,'Error percentage (%) is: ', repnt
call MPI_FINALIZE(ierr)
end
我的错误百分比(%)为:199.20
我在做什么错误?我的公式是
error percentage = (actual difference/ actual value) *100 I am getting error percentage (%) as: `199.20` what mistake am I doing ? My formula is
error percentage = (actual difference/ actual value) *100 I am getting error percentage (%) as: `199.20` what mistake am I doing ? My formula is
error percentage = (actual difference/ actual value) *100 I am getting error percentage (%) as: `199.20` what mistake am I doing ? My formula is
error percentage = (actual difference/ actual value) *100
答案 0 :(得分:2)
快速浏览一下,向我表明,您正在对某种程度的错误进行累加减少,而不是纠正所涉及的过程数量。或许,如果一个流程测量的错误为100%
而第二个流程测量的错误为99.2%
,则您的程序似乎会将这些错误添加到一起以产生199.2%
错误。< / p>
但是,正如我所说,我只是快速看一下。