Exemplo n.º 1
0
    def __compute_dual_volume(self, s, parent, pts, bpts, signs, dim):    
        ## s: simplex whose dual volume is desired (NumPy array)
        ## parent: simplex initiating this call whose face is s (NumPy
        ## array) 
        ## pts: circumcenters at all dimensions (NumPy array)
        ## bpts: circumcenters at all dimensions in barycentric 
        ## coordinates (Python list)

        ## Remark: Sign s is determined by location of cicumcenter
        ## with respect to a face of a simplex and the opposite vertex
        ## of the face in the simplex. It is +1 if the circumcenter
        ## and the opposite vertex lie on the same side with respect
        ## to the halfplane generated by the face. It is -1 if they
        ## lie on opposite sides of this halfplane. Consequently, sign
        ## can be determined as the sign of that component of the
        ## barycentric coordiante of the circumcenter which
        ## corresponds to the opposite vertex.

        data = self[dim]
        index = data.simplex_to_index[s]  
        pts[dim] = data.circumcenter[index]
        bpts[dim] = data.bary_circumcenter[index]
        sgn = 1
        if parent is not None:
            opposite_vertex = list(set(parent) - set(s))[0]
            ov_index = list(parent).index(opposite_vertex)
            signs[dim] = copysign(1, bpts[-1][ov_index])
        for i in range(dim, self.complex_dimension()):
            sgn *= signs[i]
        data.dual_volume[index] += sgn * unsigned_volume(pts[dim:,:])
        if dim > 0:
            for bs in s.boundary():
                self.__compute_dual_volume(bs, s, pts, bpts, signs, dim-1)
Exemplo n.º 2
0
 def __compute_dual_volume(self,s,pts,dim):        
     data = self[dim]
     index = data.simplex_to_index[s]        
     pts[dim] = data.circumcenter[index]
     data.dual_volume[index] += unsigned_volume(pts[dim:,:])
     if dim > 0:
         for bs in s.boundary():
             self.__compute_dual_volume(bs,pts,dim-1)
Exemplo n.º 3
0
    def compute_primal_volume(self,dim):
        """Compute the volume of all simplices for a given dimension

        If the top simplex is of the same dimension as its embedding,
        the signed volume is computed.        
        """
        data = self[dim]
        data.primal_volume = zeros((data.num_simplices,))

        if dim == self.embedding_dimension():
            for i,s in enumerate(self.simplices):
                pts = self.vertices[s,:]            
                data.primal_volume[i] = signed_volume(pts)
        else:

            for i,s in enumerate(data.simplices):
                pts = self.vertices[s,:]            
                data.primal_volume[i] = unsigned_volume(pts)