function A = laplacian2d_dense(k)
% LAPLACIAN2D_DENSE : discrete Laplace operator in 2 dimensions
%
% A = laplacian2d_dense(k) returns a k^2-by-k^2 dense matrix

m = k^2;
A = zeros(m,m);

for x = 1:k
    for y = 1:k
        i = (y-1)*k + x;
        
        A(i,i) = 4;
        
        if y > 1, A(i,i-k) = -1; end;
        if y < k, A(i,i+k) = -1; end;
        if x > 1, A(i,i-1) = -1; end;
        if x < k, A(i,i+1) = -1; end;
        
    end;
end;

