function M = ComputeMassMatrix(X,T)

ngaus = 2; 
zgp = [-sqrt(3)/3; sqrt(3)/3];
wgp= [1 1];
N = [(1-zgp)/2 (1+zgp)/2];
Nxi = [-1/2 1/2; -1/2 1/2];

npt = size(X,1); 
[numel,nen] = size(T); 
M = spalloc(npt,npt,3*npt); 
for ielem = 1:numel
    Te = T(ielem,:); 
    Xe = X(Te,:); 
    
    Me = zeros(nen);    
    for ig=1:ngaus
        N_ig   = N(ig,:);
        Nxi_ig = Nxi(ig,:);
        %Jacobia 
        J = Nxi_ig*Xe; 
        % % Derivadas de las funciones de forma respecto a (x,y)
        % Nx = J\Nxi_ig; 
        %diferencial de volum
        dvolu = wgp(ig)*det(J);
        Me = Me + N_ig'*N_ig*dvolu; 
    end
    M(Te,Te) = M(Te,Te) + Me;    
end
