clc
close all
clear
%normalized gaussian kernel
a=[.0003 .1065 .7866 .1065 .0003];
n=length(a);
%make a 4D kernel
b=a;
for d=2:4
b=kron(b,a');
end
H=reshape(b,n*ones(1,4));
%make a test matrix
A = randn(64,64,64,64);
%compare execution times
tic
B = convn(H,A);
toc
tic
B2 = convnsep({a,a,a,a},A);
toc
%compare error to size of the result of convn
norm(B(:)-B2(:))
norm(B(:))