function [A, f] = setup(R, n)
% SETUP -- Create coefficient matrix and right hand side for problem
%          studied in mandatory problem set 2.
% 
% SYNOPSIS:
%   [A, f] = setup(R, n)
%
% PARAMETERS:
%   R   - `Region name'.  Designates a sub-region of the square
%          [-1,1] x [-1,1].  Supported values are:
%            'S' - The square itself.
%            'L' - The L-shaped domain made from 3/4 of the square.
%            'C' - Like 'L', but with a quarter circle in the 4th square.
%            'D' - The unit disc.
%            'A' - An annulus.
%            'H' - A heart shaped cardioid.
%            'B' - The exterior of a butterfly.
%   n   - The number of subintervals, each of length 2/n, in each
%         direction.
%
% RETURNS:
%   A   - The coefficient matrix corresponding to the traditional finite
%         difference approximation of the Laplacian operator.
%   f   - The linear system right hand side.
%
% NOTE:
%  The number of unknowns (i.e. the system dimension) is less than or
%  equal to (n-1)^2.

G = numgrid(R, n+1);
N = sum(G(:) > 0);
h = 2 / n;
f = ones([N, 1]);
A = delsq(G) ./ h^2;
