[問題] 複數陣列

看板Fortran作者 (Le Petit Prince)時間14年前 (2010/07/24 07:08), 編輯推噓1(101)
留言2則, 2人參與, 最新討論串1/1
我想要定義一個複數陣列, 分別可以知道此陣列元素的實部跟虛部, 底下是我的code program simple implicit none complex matrix(3,3) integer :: i,j real :: b,x,y complex :: a b=0.5 a=(sin(b),cos(b)) do i=1,3 do j=1,3 matrix(i,j) = a end do end do write(*,*) matrix(2,2) end program simple 錯誤訊息如下, a=(sin(b),cos(b)) ^ pathf95-197 pathf90: ERROR SIMPLE, File = simple.f90, Line = 10, Column = 12 Unexpected syntax: ")" was expected but found ",". pathf95: PathScale(TM) Fortran Version 2.5 (f14) Fri Jul 23, 2010 18:07:48 pathf95: 19 source lines pathf95: 1 Error(s), 0 Warning(s), 0 Other message(s), 0 ANSI(s) pathf95: "explain pathf95-message number" gives more information about each message 這樣的定義法好像是不行的,請有經驗的前輩告訴我該怎麼處理。 謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 174.20.210.146

07/24 11:08, , 1F
a=cmplx(cos(b),sin(b))
07/24 11:08, 1F

07/24 12:09, , 2F
應該是cmplx, 多謝回答
07/24 12:09, 2F
文章代碼(AID): #1CIY3fRq (Fortran)