function C=mapinner(A,B)
% mapinner - inner product for multidim arrays
%
% mapinner :: [[N,M]], [[M,L]] -> [[N,L]].
%
% This is like matrix multiplication except that the N and L
% can stand for multiple dimensions, ie inputs can be more
% than 2-dimensional arrays.

Adom=size(A);
Bdom=size(B);

A=reshape(A,[],Bdom(1));
B=reshape(B,Bdom(1),[]);
C=reshape(A*B,[Adom(1:end-1) Bdom(2:end)]);

