function y = DIAG(A,NN, N);

%repeats the structure of A along the diagnol
%useful for converting 2 dimensional grid to column vectors

%NN is number of gridpoints in y
%N is number of gridpoints in x

y=zeros(NN*N);
for nn=1:NN
    y((nn-1)*N+1:(nn-1)*N+N, (nn-1)*N+1:(nn)*N)=A;
end

