Beispiel #1
0
 def __mul__(self, other):
     if isinstance(other, int):
         return self.mul_int(other)
     try:
         if min(self.n, other.n) != 1:
             raise NotImplementedError('high order multiplication')
         n = max(self.n, other.n)
         res = self.new(n=max(self.n, other.n))
         order = (self, other) if self.n != 1 else (other, self)
         inst.andrs(n, res, *order)
         return res
     except AttributeError:
         return NotImplemented
Beispiel #2
0
 def __mul__(self, other):
     if isinstance(other, int):
         return self.mul_int(other)
     try:
         if min(self.n, other.n) != 1:
             raise NotImplementedError('high order multiplication')
         n = max(self.n, other.n)
         res = self.new(n=max(self.n, other.n))
         order = (self, other) if self.n != 1 else (other, self)
         inst.andrs(n, res, *order)
         return res
     except AttributeError:
         return NotImplemented
Beispiel #3
0
 def get_bit_matrix(cls, self_bits, other):
     n = len(self_bits)
     assert n == other.n
     res = []
     for i, bit in enumerate(self_bits):
         if util.is_zero(bit):
             res.append([0] * (n - i))
         else:
             if cls.vector_mul:
                 x = sbits.get_type(n - i)()
                 inst.andrs(n - i, x, other, bit)
                 res.append(x.bit_decompose(n - i))
             else:
                 res.append([(x & bit) for x in other.bit_decompose(n - i)])
     return res