Fortran Coder

标题: 新手求助,关于复数运算的,求大神指导 [打印本页]

作者: pandaxox    时间: 2019-7-29 20:49
标题: 新手求助,关于复数运算的,求大神指导
本帖最后由 pandaxox 于 2019-7-29 21:00 编辑

我想通过fortran77  进行含复数i的复杂式运算例如,X=(1+C)*e**ia+(1-C)*e**ib
这种类型的式子,其中i为复数i
能否实现

作者: li913    时间: 2019-7-30 08:49
[Fortran] 纯文本查看 复制代码
program test
implicit none
complex x
real a, b, c
x=(1+c)*exp(cmplx(0.0,a)) + (1-c)*exp(cmplx(0.0,b))
end program

作者: pandaxox    时间: 2019-7-30 13:58
li913 发表于 2019-7-30 08:49
[mw_shl_code=fortran,true]program test
implicit none
complex x

谢谢你了
作者: pandaxox    时间: 2019-7-30 15:21
本帖最后由 pandaxox 于 2019-7-30 15:41 编辑

已修正谢谢

作者: pandaxox    时间: 2019-7-30 15:22
pandaxox 发表于 2019-7-30 15:21
[mw_shl_code=fortran,true]c
      parameter (nn=500000)
      dimension p1(nn),p2(nn),amp(nn),a(nn) ...

这个代码,其中关于复数运算的部分是不是错的一塌糊涂?
求指教一下
作者: pandaxox    时间: 2019-7-30 15:54
li913 发表于 2019-7-30 08:49
[mw_shl_code=fortran,true]program test
implicit none
complex x

请问我在输出时想把复数的实部和虚部用f7.3格式定义的话,
该怎么写
作者: li913    时间: 2019-7-30 20:39
pandaxox 发表于 2019-7-30 15:54
请问我在输出时想把复数的实部和虚部用f7.3格式定义的话,
该怎么写

复数看作两个实数

complex x
write(*,"(f7.3,2x,f7.3)") x
作者: pandaxox    时间: 2019-7-31 09:12
li913 发表于 2019-7-30 20:39
复数看作两个实数

complex x

非常感谢
作者: lookbook    时间: 2019-8-3 12:34
li913 发表于 2019-7-30 08:49
[mw_shl_code=fortran,true]program test
implicit none
complex x

大佬,学习了




欢迎光临 Fortran Coder (http://bbs.fcode.cn/) Powered by Discuz! X3.2