www.pudn.com > convolutive.rar > fast_ip.m


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
function C = fast_ip(A,B) 
% for high-(more than three)-dimensional arrays with a lot 
% of elements in those higher dimensions it might be very  
% expensive to calculate the inner product. this function  
% implements it in a fast way 
[rA cA sA] = size(A); 
[rB cB sB] = size(B); 
if cA~=rB, error('the inner dimensions of A and B do not agree'), end 
if sA~=sB, error('the higher dimensions of A and B do not agree'), end 
C = zeros(rA,cB,sB); 
for row=1:rA, for col=1:cB 
C(row,col,:) = sum(reshape(A(row,:,:),[cA 1 sA]) .* B(:,col,:),1); 
end, end