Efficiently compute a 3D matrix of outer products - MATLAB
This is just a minor improvement over Divakar's answer. It is a little faster because it replaces a 3D-array permute with a 2D-array permute:
B = bsxfun(@times, permute(A, [1 3 2]), permute(A, [3 1 2]));
To state the obvious, have you tried a simple for-loop:
[m,n] = size(A);
B = zeros(m,m,n);
for i=1:n
B(:,:,i) = A(:,i) * A(:,i).';
end
You'll be surprised how competitively fast it is.