% Driscoll p60 6.2 vect1
n = input('n = length of x = ');
tic
x = rand(n,1);
toc
tic
D = zeros(n);
toc
tic
for j = 1:n
  for i = 1:n
    D(i,j) = x(i) - x(j);
  end
end
toc
tic
for j = 1:n
  D(:,j) = x - x(j);
end 
toc
tic
X = x(:,ones(n,1)); % copy columns to make n by n
toc
tic
D = X - X.';
toc

