function C = loopmatprod(A,B)
% Nested loop implementation of matrix multiplication
  [n,k] = size(A); % A is an $n\times k$-matrix
  [kb,m] = size(B); % B is an $k\times m$-matrix
  if (k ~= kb), error('Mismatch of matrix dimensions'); end
  C = zeros(n,m);
  for i=1:n
     for j=1:m
         C(i,j) = 0;
         for l=1:k
             C(i,j) = C(i,j)+ A(i,l)*B(l,j);
         end
     end
  end
end
