当前位置: 首页>>代码示例>>Python>>正文


Python Polynomial._fastdivmod方法代码示例

本文整理汇总了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)
开发者ID:gcmcom,项目名称:pyFileFixity,代码行数:12,代码来源:polynomialtest.py

示例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])
开发者ID:gcmcom,项目名称:pyFileFixity,代码行数:13,代码来源:polynomialtest.py

示例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)
开发者ID:gcmcom,项目名称:pyFileFixity,代码行数:17,代码来源:polynomialtest.py


注:本文中的polynomial.Polynomial._fastdivmod方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。