本文整理匯總了Python中polynomial.Polynomial._fastdivmod方法的典型用法代碼示例。如果您正苦於以下問題:Python Polynomial._fastdivmod方法的具體用法?Python Polynomial._fastdivmod怎麽用?Python Polynomial._fastdivmod使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類polynomial.Polynomial
的用法示例。
在下文中一共展示了Polynomial._fastdivmod方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_div_fast
# 需要導入模塊: from polynomial import Polynomial [as 別名]
# 或者: from polynomial.Polynomial import _fastdivmod [as 別名]
def test_div_fast(self):
one = Polynomial(map(GF2int, [8,3,5,1]))
two = Polynomial(map(GF2int, [5,3,1,1,6,8]))
q, r = two._fastdivmod(one)
self.assertEqual(list(q.coefficients), [101, 152, 11])
self.assertEqual(list(r.coefficients), [183, 185, 3])
# Make sure they multiply back out okay
self.assertEqual(q*one + r, two)
示例2: test_div_fast_1
# 需要導入模塊: from polynomial import Polynomial [as 別名]
# 或者: from polynomial.Polynomial import _fastdivmod [as 別名]
def test_div_fast_1(self):
# no remander
one = Polynomial([1,0,0,2,2,0,1,-2,-4])
two = Polynomial([1,0,-1])
q, r = one._fastdivmod(two)
self.assertEqual(q, one._fastfloordiv(two))
self.assertEqual(r, one._fastmod(two))
self.assertEqual(list(q.coefficients), [1,0,1,2,3,2,4])
self.assertEqual(list(r.coefficients), [0])
示例3: test_div_gffast
# 需要導入模塊: from polynomial import Polynomial [as 別名]
# 或者: from polynomial.Polynomial import _fastdivmod [as 別名]
def test_div_gffast(self):
one = Polynomial(map(GF2int, [1,3,5,1])) # must be monic! (because the function is optimized for monic divisor polynomial)
two = Polynomial(map(GF2int, [5,3,1,1,6,8]))
q, r = two._gffastdivmod(one) # optimized for monic divisor polynomial
q2, r2 = two._fastdivmod(one)
self.assertEqual(q, q2)
self.assertEqual(r, r2)
self.assertEqual(list(q.coefficients), [5, 12, 4])
self.assertEqual(list(r.coefficients), [52, 30, 12])
# Make sure they multiply back out okay
self.assertEqual(q*one + r, two)