function A=setdiag(A,x)
% setdiag - set elements on diagonal to something
%
% setdiag :: [[N,M]], real -> [[N,M]].
% setdiag :: [[N,N]], [[N]] -> [[N,N]].

dom=size(A);
i=1:min(dom);
A(sub2ind(dom,i,i))=x;
