def test_horner(self): a = self.coefficients b = [ (i+1)*a[i+1] for i in range(len(a)-1) ] c = [ (i+1)*b[i+1] for i in range(len(b)-1) ] x = random.random() ref0 = simplest_horner(a,x) ref1 = simplest_horner(b,x) ref2 = simplest_horner(c,x) self.assertEqual( ref0, polyuv.horner(a,x) ) self.assertEqual( ref0, polyuv.horner01(a,x)[0] ) self.assertEqual( ref0, polyuv.horner012(a,x)[0] ) self.assertEqual( ref1, polyuv.horner01(a,x)[1] ) self.assertEqual( ref1, polyuv.hornerd(a,x,1) ) self.assertEqual( ref1, polyuv.horner012(a,x)[1] ) self.assertEqual( ref2, polyuv.horner012(a,x)[2] ) self.assertEqual( ref2, polyuv.hornerd(a,x,2) )
def test_horner(self): x = random.random() self.assertEqual( simplest_horner(self.coefs, x), polyuv.horner(self.coefs, x) )