📄 squarepixel_toeplitz.asv
字号:
%RectPixel_Toeplitz.m
%Purpose: Construct the Toeplitz matrix of 2D ebxn with rectangular pixels
%Ref:Linfang Shen, Sailing He, and Sanshui Xiao, Large absolute band gaps
%in two-dimensional photonic crystals formed by large dielectric pixels,
%Physical Review B 66, 165315-1->-6 (2002)
function [tp,sig]=RectPixel_Toeplitz(ebxn,pw,M,flag)
%ebxn=The first quadrant of 2D permittivity with rectangular pixels
%pw=width of each pixel
%M=maximal half order number of Fourier coefficients
%flag=1:Laurent's rule;
%flag=2:inverse rule for x;
%flag=3:inverse rule for y.
t=size(ebxn);
if t(1)~=t(2)
sig=-1;
tp='ebxn is not a square matrix';
return;
end
cw=2*t(1)*pw;
N=2*M+1;
tp=zeros(N^2);
Srr=zeros(1,N);
Src=zeros(1,N);
Scr=zeros(1,N);
Scc=zeros(1,N);
Sr=zeros(N,N^2);
Sc=zeros(N,N^2);
tl=zeros(N,2*N^2-N);
if flag==1
ebxn1=ebxn;
else
ebxn1=1./ebxn;
end
for n=0:-1:-2*M
%row vector of a given n(y) in long row
for m=0:-1:-2*M
Srr(1-m)=RectPixel_ebxn_2D_FC(ebxn1,pw,cw,m,n,flag);
end
%column vector of a given n(y)in long row
for m=0:2*M
Src(1+m)=RectPixel_ebxn_2D_FC(ebxn1,pw,cw,m,n,flag);
end
%structure Toeplitz matrix of a given n(y), add it into a long row
%matrix Sr
st=-n*N+1;
ed=st+N-1;
if flag==1
Sr(:,st:ed)=toeplitz(Src,Srr);
else
Sr(:,st:ed)=inv(toeplitz(Src,Srr));
end
end
for n=0:2*M
%row vector of a given n(y) in long column
for m=0:-1:-2*M
Scr(1-m)=RectPixel_ebxn_2D_FC(ebxn1,pw,cw,m,n);
end
%column vector of a given n(y)in long column
for m=0:2*M
Scc(1+m)=RectPixel_ebxn_2D_FC(ebxn1,pw,cw,m,n);
end
%structure Toeplitz matrix of a given n(y), add it into a long column
%matrix Sc
st=(2*M-n)*N+1;
ed=st+N-1;
if flag==1
Sc(:,st:ed)=toeplitz(Scc,Scr);
else
Sc(:,st:ed)=inv(toeplitz(Scc,Scr));
end
end
%catenate the row and column matrix, all elemental matrix of final result
%contained in it
tl=cat(2,Sc(:,1:2*M*N),Sr);
%structure the final large (double) Toeplitz matrix
st2=N^2-N+1;
ed2=st2+N^2-1;
tp(1:N,:)=tl(:,st2:ed2);
for m=2:N
st1=(m-1)*N+1;
ed1=st1+N-1;
st2=st2-N;
ed2=st2+N^2-1;
tp(st1:ed1,:)=tl(:,st2:ed2);
end
sig=1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -