主题:关于矩阵fortran中的表示
可以这样表示一个矩阵吗?
real,dimension(2,2):: a,b
a=reshape((/0.0,0.0,t,0.0/),(/2,2/))
b=transpose(a)
real,dimension(2,2):: a,b
a=reshape((/0.0,0.0,t,0.0/),(/2,2/))
b=transpose(a)
do y=1,2*n-1,2
ny=(y+1)/2
c=reshape((/w,t*exp(i*(-1)**(ny+1)*(pi/M+2*pi/3*f*(1.5*ny+1/4))),t*exp(i*(-1)**ny*(pi/M+2*pi/3*f*(1.5*ny+1/4))),w/),(/2,2/))
h0(y:y+1,y:y+1)=c
if(y==1) then
h0(y:y+1,y+2:y+3)=a
h0(y:y+1,2*n-1:2*n)=b
else if(y>=3.and.y<2*N-1) then
h0(y:y+1,y+2:y+3)=a
h0(y:y+1,y-2:y-1)=b
else
h0(y:y+1,y-2:y-1)=b
h0(2*N-1:2*N,1:2)=a
end if
end do
a,b,c都是2*2矩阵,h0矩阵由a,b,c矩阵构成,在对角上是c,两边分别是a,b。
再问:怎么用fortran表示一个n*n的0矩阵?
real,dimension(2,2):: a,b
a=reshape((/0.0,0.0,t,0.0/),(/2,2/))
b=transpose(a)
real,dimension(2,2):: a,b
a=reshape((/0.0,0.0,t,0.0/),(/2,2/))
b=transpose(a)
do y=1,2*n-1,2
ny=(y+1)/2
c=reshape((/w,t*exp(i*(-1)**(ny+1)*(pi/M+2*pi/3*f*(1.5*ny+1/4))),t*exp(i*(-1)**ny*(pi/M+2*pi/3*f*(1.5*ny+1/4))),w/),(/2,2/))
h0(y:y+1,y:y+1)=c
if(y==1) then
h0(y:y+1,y+2:y+3)=a
h0(y:y+1,2*n-1:2*n)=b
else if(y>=3.and.y<2*N-1) then
h0(y:y+1,y+2:y+3)=a
h0(y:y+1,y-2:y-1)=b
else
h0(y:y+1,y-2:y-1)=b
h0(2*N-1:2*N,1:2)=a
end if
end do
a,b,c都是2*2矩阵,h0矩阵由a,b,c矩阵构成,在对角上是c,两边分别是a,b。
再问:怎么用fortran表示一个n*n的0矩阵?