Exemplo n.º 1
0
def cohomology_2_rel_boundary(t, field, as_matrix_with_column_vectors = False):
    """
    computes H^2(t,boundary of t; field)
    i.e. t is a manifold with boundary (cusps are cut), coefficients are in field
    
    >>> from algebra.field_p import field_p
    >>> from fractions import Fraction
    >>> Fraction.one = staticmethod(lambda : Fraction(1,1))
    >>> Fraction.zero = staticmethod(lambda : Fraction(0,1))
    >>> def is_zero(m):
    ...     for r in m.values:
    ...         for c in r:
    ...             if not c == 0:
    ...                 return False
    ...     return True
    >>> from manifold3D.triangulation import *
    >>> t = read_triangulation_from_file("lib/triangulations/m003.trig")
    >>> p = d2(t) * d3(t)
    >>> is_zero(p)
    True

    H_1(m003)=H^2(m003,boundary) = Z + Z/5,
    dim(H^2(m003,boundary;Q)) = 1
    
    >>> len(cohomology_2_rel_boundary(t, Fraction))
    1
    >>> t = read_triangulation_from_file("lib/triangulations/m206.trig")
    >>> is_zero(d2(t) * d3(t))
    True
    >>> field = field_p(5)

    H_1(m206)=H^2(m206,boundary) = Z + Z/5,
    dim(H^2(m206,boundary;Z/5)) = 2
    
    >>> len(cohomology_2_rel_boundary(t, field))
    2
    >>> t = read_triangulation_from_file("lib/triangulations/m053.trig")
    >>> is_zero(d2(t) * d3(t))
    True
    >>> len(cohomology_2_rel_boundary(t, Fraction))
    1
    >>> cohomology_2_rel_boundary(t, Fraction, True).no_columns()
    1
    """

    assert isinstance(t,triangulation)
    
    m_d3 = matrix(d3(t), field).transpose()
    m_d2 = matrix(d2(t), field).transpose()
    
    H = homology_generators(m_d2, m_d3, as_matrix_with_column_vectors)

    return H
Exemplo n.º 2
0
def d2(t):
    """
    the differential C_2 -> C_1 of chains with Z coefficients as a matrix
    """

    faces = t.get_face_classes()
    edges = t.get_edge_classes()

    def boundary(face,an_edge_class):
        res = 0

        for an_edge in an_edge_class:
            if face.tet1()==an_edge.tet():
                if not (face.face1()==an_edge.vert_0() or
                        face.face1()==an_edge.vert_1()):
                    
                    if an_edge.vert_0()>face.face1():
                        vert0 = an_edge.vert_0()-1
                    else:
                        vert0 = an_edge.vert_0()
                    if an_edge.vert_1()>face.face1():
                        vert1 = an_edge.vert_1()-1
                    else:
                        vert1 = an_edge.vert_1()
                    if (vert0,vert1) in [(0,1),(1,2),(2,0)]:
                        res += + (-1) ** face.face1()
                    else:
                        assert (vert0,vert1) in [(1,0),(2,1),(0,2)]
                        res += - (-1) ** face.face1()
        return res

    return matrix([[boundary(i,j) for i in faces] for j in edges],int)
Exemplo n.º 3
0
def d3(t):

    """
    the differential C_3 -> C_2 of chains with Z coefficients as a matrix
    """
    
    tets = t.tet_list
    faces = t.get_face_classes()

    def boundary(tet,a_face_class):
        res = 0
        if tet.index==a_face_class.tet1():
            res += +1
            #res += (-1)**a_face_class.face1()
        if tet.index==a_face_class.tet2():
            res += a_face_class.orient()
            #res += ((-1)**a_face_class.face2()) * a_face_class.orient()
        return res

    return matrix([[boundary(i,j) for i in tets] for j in faces],int)

    return m