%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% MAO 2002/2003
%
%   =================================================
%   Resolution numérique d'EDP par différences finies
%   =================================================
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%   Construction de la matrice du laplacien
%   sur un maillage régulier composé de n points
%   internes ; les conditions aux limites sont supposées
%   de type Dirichlet
%
%   - en dimension 1 si d=1
%   - en dimension 2 si d=2
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function A=matlapla(d,n)

%Construction de la matrice de dimension 1

T=sparse(toeplitz([2,-1,zeros(1,n-2)]));

if d==1
   A=(n+1)^2*T;
end

%Construction de la matrice de dimension 2

if d==2
   Id=sparse(eye(n,n));
   A=(n+1)^2*(kron(T,Id)+kron(Id,T));
end
