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