import torch


def arap_S(Eij, Dij, Eij_prime):
    """
    Computes the ARAP S covariance matrix for point Pi as described in the article.
    
    Parameters
    ----------
    Eij : Tensor
        the (N,3,) tensor represeting the vector Pi-Pj in the undeformed state
    Dij : Tensor
        a (N,N,) diagonal matrix with the edge weights
    Eij_prime : Tensor
        the (N,3,) tensor represeting the vector Pi-Pj in the deformed state
        
    Returns
    -------
    Tensor
        a (3,3,) tensor representing the covariance matrix of point Pi
    """
    
    return torch.matmul(torch.t(Eij), torch.matmul(Dij, Eij_prime))