Ejemplo n.º 1
0
 def _find_values(self, commutators):
     results_list = []
     for c in commutators:
         vector_multipliers = c.x.ms + c.y.ms + c.z.ms
         vectors_sign = c.x.sign * c.y.sign * c.z.sign
         commutator = Commutator(
             Vector(c.x.value), Vector(c.y.value), Vector(c.z.value),
             sign=c.sign*vectors_sign,
             multipliers=c.multipliers+vector_multipliers
         )
         commutator = commutator.flip()
         for v in self.get(commutator):
             v.ms += commutator.multipliers
             results_list.append(v)
     return results_list
 def _find_values(self, commutators):
     results_list = []
     for c in commutators:
         vector_multipliers = c.x.ms + c.y.ms + c.z.ms
         vectors_sign = c.x.sign * c.y.sign * c.z.sign
         commutator = Commutator(Vector(c.x.value),
                                 Vector(c.y.value),
                                 Vector(c.z.value),
                                 sign=c.sign * vectors_sign,
                                 multipliers=c.multipliers +
                                 vector_multipliers)
         commutator = commutator.flip()
         for v in self.get(commutator):
             v.ms += commutator.multipliers
             results_list.append(v)
     return results_list
def init_basis_and_commutators():
    global evens, odds, basis, commutators, odd_count, even_count

    evens = tuple([Vector('e%d' % (i + 1)) for i in range(EVEN_COUNT)])
    odds = tuple([Vector('f%d' % (i + 1)) for i in range(ODD_COUNT)])
    basis = evens + odds

    commutators = tuple(Commutator.get_commutators(basis))
    for c in commutators:
        multiplier_count = len(odds) if c.is_odd() else len(evens)
        if c.is_zero():
            values = []
        elif c.is_odd():
            multipliers = [
                "m_%d" % (odd_count + i + 1) for i in range(multiplier_count)
            ]
            odd_count += multiplier_count
            values = [
                Vector('f%d' % i, [m]) for i, m in enumerate(multipliers, 1)
            ]
        else:
            multipliers = [
                "l_%d" % (even_count + i + 1) for i in range(multiplier_count)
            ]
            even_count += multiplier_count
            values = [
                Vector('e%d' % i, [m]) for i, m in enumerate(multipliers, 1)
            ]

        c.set_values_list(values)
        commutator_map[c] = values
 def get(self, commutator):
     v1 = Vector(commutator.x.value)
     v2 = Vector(commutator.y.value)
     v3 = Vector(commutator.z.value)
     invert = commutator.sign == -1
     return [
         v.copy(invert=invert)
         for v in self.commutator_map[Commutator(v1, v2, v3)]
     ]
Ejemplo n.º 5
0
def init_basis_and_commutators():
    global evens, odds, basis, commutators, odd_count, even_count

    evens = tuple([Vector('e%d' % (i + 1)) for i in range(EVEN_COUNT)])
    odds = tuple([Vector('f%d' % (i + 1)) for i in range(ODD_COUNT)])
    basis = evens + odds

    commutators = tuple(Commutator.get_commutators(basis))
    for c in commutators:
        multiplier_count = len(odds) if c.is_odd() else len(evens)
        if c.is_zero():
            values = []
        elif c.is_odd():
            multipliers = ["m_%d" % (odd_count + i+1) for i in range(multiplier_count)]
            odd_count += multiplier_count
            values = [Vector('f%d' % i, [m]) for i, m in enumerate(multipliers, 1)]
        else:
            multipliers = ["l_%d" % (even_count + i+1) for i in range(multiplier_count)]
            even_count += multiplier_count
            values = [Vector('e%d' % i, [m]) for i, m in enumerate(multipliers, 1)]

        c.set_values_list(values)
        commutator_map[c] = values
    def calculate_identity_value(self, y1, y2, commutator):
        """
        Returns right hand side of Jacobi identity of given vectors
        [y1, y2, [x1, x2, x3]] =
            [[y1, y2, x1], x2, x3] +
            (-1)^{|x1|(|y1|+|y2|)} [x1, [y1, y2, x2], x3] +
            (-1)^{(|x1|+|x2|)(|y1|+|y2|)} [x1, x2, [y1, y2, x3]]
        """
        x1, x2, x3 = commutator.x, commutator.y, commutator.z
        if any([v.ms for v in (x1, x2, x3, y1, y2)]):
            raise ValueError("One of %s has multipliers" %
                             [x1, x2, x3, y1, y2])
        elif commutator.sign != 1:
            raise ValueError("Invalid commutator with negative sign: %s" %
                             commutator)
        y_sign = abs(y1) + abs(y2)
        middle_sign = (-1)**(abs(x1) * y_sign)
        right_sign = (-1)**((abs(x1) + abs(x2)) * y_sign)
        left_inner = Commutator(y1, y2, x1).flip()
        middle_inner = Commutator(y1, y2, x2, sign=middle_sign).flip()
        right_inner = Commutator(y1, y2, x3, sign=right_sign).flip()

        # print("[{y1}, {y2}, [{x1}, {x2}, {x3}]] = [{li}, {x2}, {x3}] + [{x1}, {mi}, {x3}] + [{x1}, {x2}, {ri}]".format(
        #     x1=x1, x2=x2, x3=x3, y1=y1, y2=y2, li=left_inner, ri=right_inner, mi=middle_inner
        # ))

        left_commutators = [
            Commutator(v, x2, x3) for v in self.get(left_inner)
        ]
        middle_commutators = [
            Commutator(x1, v, x3) for v in self.get(middle_inner)
        ]
        right_commutators = [
            Commutator(x1, x2, v) for v in self.get(right_inner)
        ]

        vecs = self._find_values(left_commutators) +\
            self._find_values(middle_commutators) +\
            self._find_values(right_commutators)
        # print(vecs)
        return vecs
 def calculate_value(self, y1, y2, commutator):
     commutators = [Commutator(y1, y2, v) for v in self.get(commutator)]
     return self._find_values(commutators)