📄 tconv.m
字号:
function h=tconv(f,g)%TCONV Twisted convolution% Usage: h=tconv(f,g);%% TCONV(f,g) computes the twisted convolution of the square matrices% f and g.%%% Let h=tconv(f,g) for f,g being LxL matrices. Then h is given by% % L-1 L-1% h(m+1,n+1) = sum sum f(k+1,l+1)*g(m-k+1,n-l+1)*exp(2*pi*i*(m-k)*l/L);% l=0 k=0% % where m-k is compute module M and n-l is computed modulo N.%% The routine SPREADINV can be used to calculate an inverse convolution.% Define h and r by% % h=tconv(f,g);% r=tconv(spreadinv(f),h);% % then r is equal to g.%% SEE ALSO: SPREADOP, SPREADFUN, SPREADINV% This program is free software: you can redistribute it and/or modify% it under the terms of the GNU General Public License as published by% the Free Software Foundation, either version 3 of the License, or% (at your option) any later version.% % This program is distributed in the hope that it will be useful,% but WITHOUT ANY WARRANTY; without even the implied warranty of% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the% GNU General Public License for more details.% % You should have received a copy of the GNU General Public License% along with this program. If not, see <http://www.gnu.org/licenses/>.% AUTHOR: Peter Soendergaarderror(nargchk(2,2,nargin));M=size(f,1);N=size(f,2);if nargin==2 L=M; a=1;else L=N*a; end;if any(size(f)~=size(g)) error('Input matrices must be same size.');end;if a==1 if M~=N error('Input matrices must be square.'); end;end;b=L/M;f=fft(f);g=fft(g);Tf=zeros(L);Tg=zeros(L);for ii=0:L-1 for jj=0:L-1 Tf(ii+1,jj+1)=f(ii+1,mod(ii-jj,L)+1); Tg(ii+1,jj+1)=g(ii+1,mod(ii-jj,L)+1); end;end;Th=Tf*Tg;h=zeros(L);for ii=0:L-1 for jj=0:L-1 h(ii+1,jj+1)=Th(ii+1,mod(ii-jj,L)+1); end;end;h=ifft(h);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -