A=rand(4,4);
b=rand(4,1)
c=rand(1,4)
try
    A*b
    A*c
    A*c'
catch err
    disp(err)
end
pause
lotimes=zeros(4,5);
% 1 access A by rows
for N=1:4
    M=10^N;
    s(N)=M;
    A=rand(M);
    b=rand(M,1);
    tic
    for i=1:M
        c(i)=0;
        for j=1:M
            c(i)=c(i)+A(i,j)*b(j);
        end
    end
    lotimes(N,1)=toc;
end
pause
% 1 access A by columns
for N=1:4
    M=10^N;
    A=rand(M);
    b=rand(M,1);
    c=zeros(M,1);
    tic
    for j=1:M
        for i=1:M
            c(i)=c(i)+A(i,j)*b(j);
        end
    end
    lotimes(N,2)=toc;
end
% 1 access A by columns, but vectorially
pause

for N=1:4
    M=10^N;
    A=rand(M);
    b=rand(M,1);
    c=zeros(M,1);
    tic
    for j=1:M
        c(:)=c(:)+A(:,j)*b(j);
    end
    lotimes(N,3)=toc;
end
% 1 access A by rows, but vectorially
pause

for N=1:4
    M=10^N;
    A=rand(M);
    b=rand(M,1);
    c=zeros(M,1);
    tic
    for i=1:M
        c(i)=c(i)+dot(A(i,:),b(:));
    end
    lotimes(N,4)=toc;
end
pause
% do it by a single statement
for N=1:4
    M=10^N;
    A=rand(M);
    b=rand(M,1);
    c=zeros(M,1);
    tic
    c=A*b;
    lotimes(N,5)=toc;
end

lotimes




