%% Set up matrices
n = 200;
A = rand(n,n);
B = rand(n,n);
C = zeros(n,n);

%% Naive
tic
for i=1:n
	for j=1:n
		sum = 0;
		for k=1:n
			sum = sum + A(i, k) * B(k, j);
		end
		C(i, j) = sum;
	end
end
toc

%% Dot product
tic
for i=1:n
	for j=1:n
		C(i, j) = A(i, :) * B(:, j);
	end
end
toc

%% SAXPY
tic
C = zeros(n,n);
for j=1:n
	for k=1:n
		C(:, j) = C(:, j) + A(:, k) * B(k, j);
	end
end
toc

%% Matrix multiplication
tic
for i=1:n
	C(:, j) = A * B(:, j);
end
toc

%% Outer product
tic
C = zeros(n,n);
for i=1:n
	C = C + A(:,i) * B(i, :);
end
toc
%% Builtin
tic
C = A * B;
toc
