function A = laplacian2d_sparse1(k)
% LAPLACIAN2D_SPARSE1 : discrete Laplace operator in 2 dimensions
%
% A = laplacian2d_sparse1(k) returns a k^2-by-k^2 sparse matrix

m = k^2;
A = sparse(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;

