I'm fairly new to MATLAB. Normal matrix multiplication of a M x K matrix by an K x N matrix -- C = A * B
-- has c_ij = sum(a_ik * b_kj, k = 1:K)
. What if I want this to be instead c_ij = sum(op(a_ik, b_kj), k = 1:K)
for some simple binary operation op
? Is there any nice way to vectorize this in MATLAB (or maybe even a built-in function)?
EDIT: This is currently the best I can do.
% A is M x K, B is K x N
% op is min
C = zeros(M, N);
for i = 1:M:
C(i, :) = sum(bsxfun(@min, A(i, :)', B));
end