clear all;

n = 500;
fprintf('n=%d\n',n);
A = rand(n);
B = rand(n);
C = zeros(n);

% point - level
t0 = clock;
for i = 1 : n
    for j = 1 : n
        for k = 1 : n
            C(i,j) = C(i,j) + A(i,k)*B(k,j);
        end
    end
end
t1 = etime(clock,t0);
fprintf('point-point:   %.0f s\n', t1);

% vector - level
t0 = clock;
for i = 1 : n
    for j = 1 : n
        C(i,j) = A(i,:)*B(:,j);
    end
end
t2 = etime(clock,t0);
fprintf('vector-vector: %.4f s\n', t2);

% matrix - vector - level
t0 = clock;
for i = 1 : n
    C(:,i) = A*B(:,i);
end
t3 = etime(clock,t0);
fprintf('matrix-vector: %.4f s\n', t3);

% matrix - matrix - level
t0 = clock;
C = A * B;
t4 = etime(clock,t0);
fprintf('matrix-matrix: %.0f s\n', t4);
