function out = SJPC(A,B)
% 时卷频乘,可用于求矩阵卷积
[ra,ca] = size(A);
[rb,cb] = size(B);
r = ra+rb-1; % A,B两个矩阵做卷积后其行数和列数分别为A,B矩阵的行列数相加减1
c = ca+cb-1;
a1 = [A zeros(ra,c-ca);zeros(r-ra,c)]; % 0延拓,补齐成r*c大小的矩阵,原矩阵在左上方
b1 = [B zeros(rb,c-cb);zeros(r-rb,c)];
fftA = fft2(a1);
fftB = fft2(b1);
result1 = ifft2(fftA.*fftB); % 频域相乘
r_start = floor(rb/2) +1;
r_end = r_start + ra -1;
c_start = floor(cb/2) +1;
c_end = c_start + ca -1; % 此处返回的矩阵大小和A相同,也可不做截取,返回result1
out = result1(r_start:r_end,c_start:c_end);
end