|
板凳
楼主 |
发表于 2022-3-23 15:39:33
|
只看该作者
感谢!我还有个问题,在矩阵内元素的赋值中,比如我对其中一个元素赋值是0.29,但是最后输出的时候却成了0.28999999165534973,请问这是为什么,又应该如何改正呢?
[Fortran] 纯文本查看 复制代码 real(8) , parameter :: t1 = 3.12 , t2 = 0.29 , t3 = -0.0103
H_1 = reshape([complex(8) :: &
t0, t1*f1, t0, t0, t0, t0,&
t1*f2, t0, t0, t2, t0, t3,&
t0, t0, t0, t1*f2, t0 ,t0,&
t0, t2, t1*f1,t0, t0, t2, &
t0, t0, t0, t0, t0, t1*f1,&
t0, t3, t0, t2, t1*f2, t0],[6 , 6])
最后输出的结果是:
(0.0000000000000000,0.0000000000000000) (9.3596917284584578,-5.88094530879436223E-002) (0.0000000000000000,0.0000000000000000) (0.0000000000000000,0.0000000000000000) (0.0000000000000000,0.0000000000000000) (0.0000000000000000,0.0000000000000000)
(9.3596917284584578,5.88094530879436223E-002) (0.0000000000000000,0.0000000000000000) (0.0000000000000000,0.0000000000000000) (0.28999999165534973,0.0000000000000000) (0.0000000000000000,0.0000000000000000) (-1.03000001981854439E-002,0.0000000000000000)
(0.0000000000000000,0.0000000000000000) (0.0000000000000000,0.0000000000000000) (0.0000000000000000,0.0000000000000000) (9.3596917284584578,5.88094530879436223E-002) (0.0000000000000000,0.0000000000000000) (0.0000000000000000,0.0000000000000000)
(0.0000000000000000,0.0000000000000000) (0.28999999165534973,0.0000000000000000) (9.3596917284584578,-5.88094530879436223E-002) (0.0000000000000000,0.0000000000000000) (0.0000000000000000,0.0000000000000000) (0.28999999165534973,0.0000000000000000)
(0.0000000000000000,0.0000000000000000) (0.0000000000000000,0.0000000000000000) (0.0000000000000000,0.0000000000000000) (0.0000000000000000,0.0000000000000000) (0.0000000000000000,0.0000000000000000) (9.3596917284584578,-5.88094530879436223E-002)
(0.0000000000000000,0.0000000000000000) (-1.03000001981854439E-002,0.0000000000000000) (0.0000000000000000,0.0000000000000000) (0.28999999165534973,0.0000000000000000) (9.3596917284584578,5.88094530879436223E-002) (0.0000000000000000,0.0000000000000000) |
|