def line_vertices(self): r""" Return the vertices for each line in a 3-d acyclic vector_configuration. NOTE: An acyclic vector configuration corresponds to the normal vectors of a hyperplane arrangement with a selected base region. OUTPUT: A list of pairs. EXAMPLES:: sage: from cn_hyperarr.vector_classes import * sage: vc = VectorConfiguration([[1,0,0],[0,1,0],[0,0,1],[1,1,0],[0,1,1],[1,1,1]]) sage: vc.line_vertices() [(0, 1), (1, 2), (2, 3), (0, 4)] The vectors [-1,0,1] and [1,0,1] are the vertices of the line containing [0,0,1]:: sage: vc = VectorConfiguration([[0,0,1],[-1,0,1],[1,0,1]]) sage: vc.line_vertices() [(1, 2)] """ assert self.is_acyclic(), "The vector configuration should be acyclic" nb_pts = self.n_vectors() cocircuits = self.three_dim_cocircuits() list_verts = [] for coc in cocircuits: zero_indices = coc[1] if len(zero_indices) > 2: the_cone = Polyhedron(rays=[self[j] for j in zero_indices], backend=self._backend) the_verts = tuple([ _ for _ in zero_indices if not the_cone.relative_interior_contains(self[_]) ]) assert len(the_verts) == 2, "problem with the cocircuits" if the_verts not in list_verts: list_verts += [the_verts] return list_verts
def dominating_pairs(self): r""" Return the dominating pairs for each point in a 3-d acyclic vector_configuration. A point p has a dominating pair (a,b) when p lies in the positive linear span of a and b. OUTPUT: A dictionary where keys are the indices of the vectors and the values are the associated dominating pairs. EXAMPLES:: sage: from cn_hyperarr.vector_classes import * sage: vc = VectorConfiguration([[1,0,0],[0,1,0],[0,0,1],[1,1,0],[0,1,1],[1,1,1]]) sage: vc.dominating_pairs() {0: set(), 1: set(), 2: set(), 3: {(0, 1)}, 4: {(1, 2)}, 5: {(0, 4), (2, 3)}} sage: tau = AA((1+sqrt(5))/2) sage: ncn = [[2*tau+1,2*tau,tau],[2*tau+2,2*tau+1,tau+1],[1,1,1],[tau+1,tau+1,tau],[2*tau,2*tau,tau],[tau+1,tau+1,1],[1,1,0],[0,1,0],[1,0,0],[tau+1,tau,tau]] sage: ncn_conf = VectorConfiguration(ncn); sage: ncn_conf.dominating_pairs() {0: {(4, 8), (6, 9)}, 1: {(0, 2), (3, 8), (5, 9)}, 2: set(), 3: {(2, 6), (7, 9)}, 4: {(1, 7), (2, 6)}, 5: {(0, 7), (2, 6)}, 6: {(7, 8)}, 7: set(), 8: set(), 9: {(2, 8)}} The vector [0,0,1] is in the positive linear span of [-1,0,1] and [1,0,1]:: sage: vc = VectorConfiguration([[0,0,1],[-1,0,1],[1,0,1]]) sage: vc.dominating_pairs() {0: {(1, 2)}, 1: set(), 2: set()} """ assert self.is_acyclic(), "The vector configuration should be acyclic" nb_pts = self.n_vectors() cocircuits = self.three_dim_cocircuits() dom_dict = {} for index in range(nb_pts): the_dominating_pairs = set() my_v = self[index] # We only consider the cocircuits that are zero at given index and contains at least 3 zero elements. relevant_cocircuits = (coc for coc in cocircuits if index in coc[1] and len(coc[1]) >= 3) for r_coc in relevant_cocircuits: the_cone = Polyhedron(rays=[self[j] for j in r_coc[1]], backend=self._backend) if the_cone.relative_interior_contains(my_v): # This means that my_v is dominated. # Now we catch the dominating rays: # We are interested in the index of # the rays and not just the ray (which # may not be equal to the vector we started with dom_rays = [ j for j in r_coc[1] if not the_cone.relative_interior_contains(self[j]) ] assert len(dom_rays) == 2, "problem with the cocircuits" the_dominating_pairs.add(tuple(dom_rays)) dom_dict[index] = the_dominating_pairs return dom_dict
def is_acyclic(self): r""" Return whether ``self`` is acyclic. A vector configuration is acyclic if the origin is not in the relative interior of the cone spanned by the vectors. OUTPUT: Boolean. Whether ``self`` is acyclic. .. SEEALSO:: :meth:`is_totally_cyclic`. EXAMPLES:: sage: from cn_hyperarr.vector_classes import * sage: vc = VectorConfiguration([[1,0,0],[0,1,0],[0,0,1],[1,1,0],[0,1,1],[1,1,1]]) sage: vc.is_acyclic() True sage: v = [[1, -1, -1], ....: [1, 1, -1], ....: [1, 1, 1], ....: [1, -1, 1], ....: [-1, -1, 1], ....: [-1, -1, -1], ....: [-1, 1, -1], ....: [-1, 1, 1]] sage: vc = VectorConfiguration(v) sage: vc.is_acyclic() False TESTS:: sage: vc = VectorConfiguration([]) sage: vc.is_acyclic() True sage: vc2 = VectorConfiguration([[1,0,0],[-1,0,0]]) sage: vc2.is_acyclic() False sage: vc3 = VectorConfiguration([[0,0,0]]) sage: vc3.is_acyclic() Traceback (most recent call last): ... ValueError: PPL::ray(e): e == 0, but the origin cannot be a ray. sage: vc = VectorConfiguration([[1,0,0],[0,1,0],[0,0,1],[1,1,0],[0,1,1],[1,1,1],[-1,0,0]]) sage: vc.is_acyclic() False """ acyc_vc = Polyhedron(rays=self, backend=self.backend()) if acyc_vc.relative_interior_contains( vector([0] * acyc_vc.ambient_dim())): return False elif not acyc_vc.lines() == (): return False else: return True