Exemplo n.º 1
0
 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")
Exemplo n.º 2
0
 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
Exemplo n.º 3
0
 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
Exemplo n.º 4
0
 def degree(self):
     return intmath.nbits(self.coeff) - 1