主题:急求助高手进!。fortran和matlab的结果有差异
%下面的matlab
LceLL=0.001e0;
pi=3.1415926535897932e0;
Tv=1*LceLL;
Tp=LceLL*0.5;
Az=2*Tv+Tp;
Fv=Tv/Az;
Fp=Tp/Az;
Gz=2*pi*2/Az;
P=(Fv+Fp)*exp(-i*Gz*(Tv+Tp))/(-i*Gz*(Tv+Tp))-(Fv)*exp(-i*Gz*(Tv))/(-i*Gz*(Tv))
!fortran
PROGRAM TEST
implicit none
real*8::Az,Tv,Tp,Fv,Fp,Gz,LceLL=0.001,pi=3.1415926535897932d0
doublecomplex:: c=(0.0,1.0),P
Tv=1*LceLL
Tp=LceLL*0.5
Az=2*Tv+Tp
Fv=Tv/Az
Fp=Tp/Az
Gz=2*pi*2/Az
P=(Fv+Fp)*cdexp(-c*Gz*(Tv+Tp))/(-c*Gz*(Tv+Tp))-(Fv)*cdexp(-c*Gz*(Tv))/(-c*Gz*(Tv))
print*,P
END PROGRAM TEST
下面是P的值
matlab
P =
1.513653457281314e-001 -3.122502256758253e-017i
fortran
(0.151365345728131,-3.469446951953614E-017)
虚部差异还是比较明显!怎么解决?谢谢
LceLL=0.001e0;
pi=3.1415926535897932e0;
Tv=1*LceLL;
Tp=LceLL*0.5;
Az=2*Tv+Tp;
Fv=Tv/Az;
Fp=Tp/Az;
Gz=2*pi*2/Az;
P=(Fv+Fp)*exp(-i*Gz*(Tv+Tp))/(-i*Gz*(Tv+Tp))-(Fv)*exp(-i*Gz*(Tv))/(-i*Gz*(Tv))
!fortran
PROGRAM TEST
implicit none
real*8::Az,Tv,Tp,Fv,Fp,Gz,LceLL=0.001,pi=3.1415926535897932d0
doublecomplex:: c=(0.0,1.0),P
Tv=1*LceLL
Tp=LceLL*0.5
Az=2*Tv+Tp
Fv=Tv/Az
Fp=Tp/Az
Gz=2*pi*2/Az
P=(Fv+Fp)*cdexp(-c*Gz*(Tv+Tp))/(-c*Gz*(Tv+Tp))-(Fv)*cdexp(-c*Gz*(Tv))/(-c*Gz*(Tv))
print*,P
END PROGRAM TEST
下面是P的值
matlab
P =
1.513653457281314e-001 -3.122502256758253e-017i
fortran
(0.151365345728131,-3.469446951953614E-017)
虚部差异还是比较明显!怎么解决?谢谢