Suppose I have two matrices A
and B
which are made up of column vectors as follows.
A = [a_1,a_2,...,a_N];
B = [b_1,b_2,...,b_N];
Is there any way to vectorize the calculation of the sum of outer products for every column in A
with the corresponding column in B. Here is my non-vectorized solution.
S = zeros(size(A,1), size(B,1));
for n=1:N
S = S + A(:,n)*B(:,n)'; % S = S + a_n * b_n'
end
Any help would be greatly appreciated.