예제 #1
0
파일: digraph.py 프로젝트: bzhan/bfh_python
    def __init__(self, parent, gen_left, gen_right):
        """Specify generators on the two sides of the tensor. Both are type D
        generators because the AA generator in between is assumed.

        """
        # Note tuple initialization is automatic
        Generator.__init__(self, parent)
예제 #2
0
    def __init__(self, parent, idem1, idem2):
        """Every generator has two idempotents. idem1 is the type D idempotent
        on the left. idem2 is the type A idempotent on the right.

        """
        Generator.__init__(self, parent)
        self.idem1, self.idem2 = idem1, idem2
예제 #3
0
    def __init__(self, parent, source, coeff, target):
        """Specifies the morphism source -> coeff * target. Note coeff has type
        TensorDGAlgebra of the two algebras that act on the DD structures.

        """
        Generator.__init__(self, parent)
        MorObject.__init__(self, source, coeff, target)
예제 #4
0
 def __init__(self, parent, source, coeff, target):
     """Specifies the morphism source -> coeff * target."""
     Generator.__init__(self, parent)
     MorObject.__init__(self, source, coeff, target)
     filt = []
     if hasattr(source, "filtration"):
         filt += [1-x for x in source.filtration]
     if hasattr(target, "filtration"):
         filt += target.filtration
     if filt != []:
         self.filtration = filt
예제 #5
0
파일: signs.py 프로젝트: bzhan/bfh_python
    def __init__(self, parent, strands):
        """Specifies the parent algebra (of type PreStrandAlgebra), and a list
        of strands. Each element of strands is a pair specifying the starting
        and ending points.

        """
        Generator.__init__(self, parent)
        self.pmc = parent.pmc
        self.strands = tuple(sorted(strands))
        self.left_pt_idem = tuple(sorted([s for s, t in self.strands]))
        self.right_pt_idem = tuple(sorted([t for s, t in self.strands]))
        self.left_idem = tuple(sorted([self.pmc.pairid[s]
                                       for s in self.left_pt_idem]))
        self.right_idem = tuple(sorted([self.pmc.pairid[s]
                                        for s in self.right_pt_idem]))
예제 #6
0
    def __init__(self, parent, coeff_d, coeffs_a, source, target):
        """Specifies the morphism m(source, coeffs_a) -> coeff_d * target.
        source and target are generators in two type DA bimodules with same
        algebra actions. If the bimodules have left type D action by algebra1
        and right type A action by algebra2, then as a MorObject coeff is of
        type TensorDGAlgebra(algebra1, CobarAlgebra(algebra2)).

        """
        Generator.__init__(self, parent)
        self.coeff_d, self.coeffs_a = coeff_d, coeffs_a
        cobar_alg = CobarAlgebra(source.parent.algebra2)
        tensor_alg = TensorDGAlgebra((source.parent.algebra1, cobar_alg))
        coeff = TensorGenerator(
            (coeff_d, TensorStarGenerator(coeffs_a, cobar_alg, source.idem2)),
            tensor_alg)
        MorObject.__init__(self, source, coeff, target)
예제 #7
0
파일: pmc.py 프로젝트: bzhan/bfh_python
    def __init__(self, parent, left_idem, strands, right_idem = None):
        """Specifies PMC, left idempotent and right idempotent as list of pair
        ID's, and strands as a list of pairs (start, end).
        For example, in the split PMC of genus 2, the strand diagram with
        double horizontal at (1,3) and strand from 2 to 5 would be encoded as:
        left_idem = [1,2], right_idem = [1,3], strands = [(2,5)], since pair
        (1,3) has index 1, pair (2,4) has index 2, and pair (5,7) has index 3.

        """
        Generator.__init__(self, parent)
        self.pmc = parent.pmc
        self.mult_one = parent.mult_one

        self.strands = strands
        if not isinstance(self.strands, Strands):
            self.strands = Strands(self.pmc, self.strands)

        # Calculate left idempotent if necessary
        if left_idem is None:
            assert right_idem is not None
            left_idem = self.strands.propagateLeft(right_idem)
        self.left_idem = left_idem
        if not isinstance(self.left_idem, Idempotent):
            self.left_idem = Idempotent(self.pmc, self.left_idem)

        # Calculate right idempotent if necessary
        if right_idem is None:
            right_idem = self.strands.propagateRight(self.left_idem)
        assert right_idem is not None, \
            "Invalid init data for strand diagram: cannot propagate to right."
        self.right_idem = right_idem
        if not isinstance(self.right_idem, Idempotent):
            self.right_idem = Idempotent(self.pmc, self.right_idem)

        # Enumerate double horizontals
        self.double_hor = list(self.left_idem)
        for st in self.strands:
            self.double_hor.remove(self.pmc.pairid[st[0]])
        self.double_hor = tuple(self.double_hor)

        # Get multiplicity from strands
        self.multiplicity = self.strands.multiplicity
def opposite_algebra(A_inf):
    gen_by_name = AttrDict({})
    for gen in A_inf.genset:
        gen_by_name[gen.name + '*'] = Generator(gen.name + '*')

    new_A_inf_actions = Bunch_of_arrows([])

    for action in A_inf.a_inf_actions:
        new_action = ()
        for element in action:
            new_action = new_action + (gen_by_name[element.name + '*'], )
        new_A_inf_actions[new_action[:-1][::-1] + (new_action[-1], )] += 1

    return simpler_A_inf_Algebra(gen_by_name, 'opposite of ' + A_inf.name,
                                 new_A_inf_actions)
def rename_generators(A, list_of_tuples_to_rename):
    new_generators = AttrDict({})
    # for t in list_of_tuples_to_rename:
    #     new_generators[t[1]]=Generator(name=t[1], aux_info=A.gen_by_name[t[0]])

    for gen in A.gen_by_name.values():
        if gen.name in [t[0] for t in list_of_tuples_to_rename]:
            t = next(t for t in list_of_tuples_to_rename if t[0] == gen.name)
            new_generators[t[1]] = Generator(name=t[1],
                                             aux_info=A.gen_by_name[t[0]])
        else:
            new_generators[gen.name] = Generator(name=gen.name, aux_info=gen)

    new_A_inf_actions = Bunch_of_arrows({})
    for action in A.a_inf_actions:
        new_action = ()
        for el in action:
            new_action = new_action + (next(gen
                                            for gen in new_generators.values()
                                            if gen.aux_info == el), )
        new_A_inf_actions[new_action] += 1

    return simpler_A_inf_Algebra(new_generators, A.name + '_renamed',
                                 new_A_inf_actions)
예제 #10
0
    def __init__(self, parent, left_idem, strands):
        """Specifies the parent algebra (which contains the local PMC), left
        idempotent, and strands.

        Input parameters:
        - parent: must be an object of LocalStrandAlgebra.
        - left_idem: tuple containing IDs of occupied pairs.
        - strands: tuple of pairs specifying strands.

        """
        Generator.__init__(self, parent)
        self.local_pmc = parent.local_pmc
        self.left_idem = left_idem
        if not isinstance(self.left_idem, LocalIdempotent):
            self.left_idem = LocalIdempotent(self.local_pmc, self.left_idem)
        if not isinstance(strands, LocalStrands):
            strands = LocalStrands(self.local_pmc, strands)
        self.strands = strands

        # Get right_idem and multiplicity from strands
        self.right_idem = self.strands.propagateRight(self.left_idem)
        self.multiplicity = self.strands.multiplicity

        # Enumerate single and double horizontals
        self.all_hor = list(self.left_idem)
        for st in self.strands:
            start_idem = self.local_pmc.pairid[st[0]]
            if start_idem != -1:
                if start_idem not in self.all_hor:
                    print left_idem, strands
                self.all_hor.remove(start_idem)
        self.all_hor = tuple(self.all_hor)
        self.single_hor = tuple([i for i in self.all_hor
                                 if len(self.local_pmc.pairs[i]) == 1])
        self.double_hor = tuple([i for i in self.all_hor
                                 if len(self.local_pmc.pairs[i]) == 2])
def u_i_rename_generators(A):
    new_generators = AttrDict({})
    i = 0
    for gen in A.gen_by_name.values():
        new_generators["u_" + str(i)] = Generator(name="u_" + str(i),
                                                  aux_info=gen)
        i += 1

    new_A_inf_actions = Bunch_of_arrows({})
    for action in A.a_inf_actions:
        new_action = ()
        for el in action:
            new_action = new_action + (next(gen
                                            for gen in new_generators.values()
                                            if gen.aux_info == el), )
        new_A_inf_actions[new_action] += 1

    return simpler_A_inf_Algebra(new_generators, A.name + '_renamed',
                                 new_A_inf_actions)
예제 #12
0
파일: Digraph.py 프로젝트: al3393/dfh
 def __init__(self, parent, gen_left, gen_right):
     ''' Specifies generators on the two sides of the tensor.''' # Both are type D generators? ( CB and reread)
     
     Generator.__init__(self, parent)
예제 #13
0
파일: DAstructure.py 프로젝트: al3393/dfh
 def __init__(self, parent, idem1, idem2):
     ''' Every generator has two idempotents. 
     idem1: left type D idempotent on the left.
     idem2: right type A idempotent on the right.''' # cb and check
     Generator.__init__(self,parent)
     self.idem1, self.idem2 = idem1, idem2
예제 #14
0
 def __init__(self, parent, idem):
     ''' Every generator must have an idempotent. '''
     Generator.__init__(self, parent)
     self.idem = idem  # ask akram # left idempotent CB and fill in
def base_change_AA_from_fuk(Fuk, generators, left_dg_algebra,
                            right_dg_algebra):
    def check_validity(x, action):
        if action[:-1].count(x) == 1 and (action[-1] in generators):
            index_of_x = action[:-1].index(x)
            for el in action[:index_of_x]:
                if not el.name in left_dg_algebra.gen_by_name.keys():
                    return False
            for el in action[index_of_x + 1:-1]:
                if not el.name in right_dg_algebra.gen_by_name.keys():
                    return False
            return True
        else:
            return False

    gen_by_name = AttrDict({})
    for x in generators:
        gen_by_name['' + x.name + ''] = Generator('' + x.name + '')
        # gen_by_name[''+x.name+''].add_idems(x.idem.left, x.idem.right)

        # adding idempotents
        for action in [
                act for act in Fuk.a_inf_actions if (len(act) == 3 and (
                    act[0].name in left_dg_algebra.idem_by_name.keys()) and (
                        x == act[1]) and (x == act[-1]))
        ]:
            left_idem = left_dg_algebra.idem_by_name[action[0].name]
        for action in [
                act for act in Fuk.a_inf_actions if (len(act) == 3 and (
                    act[1].name in right_dg_algebra.idem_by_name.keys()) and (
                        x == act[0]) and (x == act[-1]))
        ]:
            right_idem = right_dg_algebra.idem_by_name[action[1].name]
        gen_by_name['' + x.name + ''].add_idems(left_idem, right_idem)

    arrows = Bunch_of_arrows([])
    for y in generators:
        for action in Fuk.a_inf_actions:
            if (len(action) == 3
                    and (action[0].name in left_dg_algebra.idem_by_name.keys())
                    and (y == action[1]) and (y == action[-1])):
                continue
            if (len(action) == 3 and
                (action[1].name in right_dg_algebra.idem_by_name.keys())
                    and (y == action[0]) and (y == action[-1])):
                continue
            if check_validity(y, action):
                index_of_y = action[:-1].index(y)
                tuple_from_left = tuple([
                    (lambda z: left_dg_algebra.gen_by_name[z.name])(z)
                    for z in action[:index_of_y]
                ])
                tuple_from_right = tuple([
                    (lambda z: right_dg_algebra.gen_by_name[z.name])(z)
                    for z in action[index_of_y + 1:-1]
                ])
                arrows[(tuple_from_left, gen_by_name['' + y.name + ''],
                        tuple_from_right,
                        gen_by_name['' + action[-1].name + ''])] += 1

    return AA_bimodule(gen_by_name,
                       arrows,
                       left_dg_algebra,
                       right_dg_algebra,
                       name='AA_from_Fuk',
                       to_check=True)
예제 #16
0
 def __init__(self, parent, sd_left, sd_right):
     "Specifies the two strand diagrams." ""
     # Note tuple initialization is automatic
     Generator.__init__(self, parent)
예제 #17
0
 def __init__(self, parent, idem):
     """Every generator must have an idempotent."""
     Generator.__init__(self, parent)
     self.idem = idem
예제 #18
0
 def __init__(self, parent, idem1, idem2):
     """Every generator has two idempotents (for the two type D actions)."""
     Generator.__init__(self, parent)
     self.idem1, self.idem2 = idem1, idem2
예제 #19
0
파일: DAstructure.py 프로젝트: al3393/dfh-1
 def __init__(self, parent, idem1, idem2):
     ''' Every generator has two idempotents. 
     idem1: left type D idempotent on the left.
     idem2: right type A idempotent on the right.''' # cb and check
     Generator.__init__(self, parent)
     self.idem1, self.idem2 = idem1, idem2
예제 #20
0
    def __init__(self, parent, gen_left, gen_right):
        ''' Specifies generators on the two sides of the tensor.'''  # Both are type D generators? ( CB and reread)

        Generator.__init__(self, parent)