function [d]=diagonal(A)
    LC = size(A);
    n = LC(1,1);
    D = [];
    for i=1:n
        for j=1:n
            if i==j then
                D(i,j)=A(i,j);
            else
                D(i,j)=0;
            end
        end
    end
    d=D;
endfunction
