function x = diagsolve(A, b)
% Solve A x = b for a diagonal matrix A.
  d = diag(A);
  if any(d == 0), error('A is singular!'), end
  x = b ./ d;
  
return

