def __init__(self, data = None): """Corrects type of coefficients if necessary.""" if data is None: data = {} SummableDict.__init__(self, data) if self: convert = self.getElt().parent.ring.convert for key, value in self.items(): self[key] = convert(value)
def __init__(self, data=None): if data is None: data = {} SummableDict.__init__(self, data) if self: # if the object is instantialized convert = self.getElt().parent.ring.convert #? for key, value in self.items(): self[key] = convert(value)
def __init__(self,data = None): if data is None: data = {} SummableDict.__init__(self,data) if self: # if the object is instantialized convert = self.getElt().parent.ring.convert #? for key,value in self.items(): self[key] = convert(value)
def __rmul__(self, other): # First try multiplying each coefficient with other, using the function # in SummableDict. result = SummableDict.__rmul__(self, other) if result != NotImplemented: return result # Now try to multiply key by other on the left. result = E0 for k, v in self.items(): prod = safeMultiply(other, k) if prod is NotImplemented: return NotImplemented result += [term * (v * coeff) for term, coeff in prod.items()] return result