function  [area,inv_transf]=Transform_information(mesh,area_index,matrix_index)

%  compute the ares and the inverse transf matrix for the mesh
% INPUT: MESH: the mesh
%  AREA_INDEX:   1 means we need to output the the area of each element
%        MATRIX: 0 means we don't need to compute the transform matrix 
%                1 means we need to compute the inverse transform matrix
%                2 means we need to compute the transform matrix
%
% OUTPUT: MESH: output the mesh include the corresponding information

%--------start to compute--------------------------------------------------
if area_index==1
    %----------------------------------------------------------------------
    % Compute vedge: edge as a vector and area of each element
    %----------------------------------------------------------------------
    ve(:,:,1) = mesh.node(mesh.elem(:,2),:)-mesh.node(mesh.elem(:,1),:);
    ve(:,:,2) = mesh.node(mesh.elem(:,3),:)-mesh.node(mesh.elem(:,1),:);
    area      = 0.5*(ve(:,1,1).*ve(:,2,2)-ve(:,1,2).*ve(:,2,1));
    %---------Compute the inverse transform  matrix------------------------
    if (matrix_index==1)
        inv_transf(:,1,1) =  0.5*ve(:,2,2)./area;
        inv_transf(:,1,2) = -0.5*ve(:,1,2)./area;
        inv_transf(:,2,1) = -0.5*ve(:,2,1)./area;
        inv_transf(:,2,2) =  0.5*ve(:,1,1)./area;
    end
    if (matrix_index==2)
        inv_transf(:,:,1) = ve(:,:,1);
        inv_transf(:,:,2) = ve(:,:,2);
    end
end
