def degree(self): deg = intmath.nbits(self.coeff) - 1 if deg >= 0: return deg else: # Wikipedia says -Inf is 'convenient' http://en.wikipedia.org/wiki/Degree_of_a_polynomial#Degree_of_the_zero_polynomial return -float("infinity")
def repren(self): strng = '' coefflst = [] for i in xrange(intmath.nbits(self.coeff)-1,-1,-1): # if self.getcoeff(i) == 0: continue # if i == 0: strx = '1' elif i == 1: strx = 'x' else: strx = 'x**' + str(i) if len(strng) > 0: strng += ' + ' strng += strx if len(strng) == 0: strng = '0' return strng
def repren(self): strng = "" coefflst = [] for i in xrange(intmath.nbits(self.coeff) - 1, -1, -1): # if self.getcoeff(i) == 0: continue # if i == 0: strx = "1" elif i == 1: strx = "x" else: strx = "x**" + str(i) if len(strng) > 0: strng += " + " strng += strx if len(strng) == 0: strng = "0" return strng
def degree(self): return intmath.nbits(self.coeff) - 1