本文整理汇总了Python中polynomial.Polynomial.coef方法的典型用法代码示例。如果您正苦于以下问题:Python Polynomial.coef方法的具体用法?Python Polynomial.coef怎么用?Python Polynomial.coef使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类polynomial.Polynomial
的用法示例。
在下文中一共展示了Polynomial.coef方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_ntt_mul
# 需要导入模块: from polynomial import Polynomial [as 别名]
# 或者: from polynomial.Polynomial import coef [as 别名]
def test_ntt_mul():
global w,wInv
print "test_ntt_mul"
powers2 = [pow(2,i) for i in range(1,19)]
for N in powers2:
print N
k = (P-1)/(2*N)
assert (P-1)%(2*N) == 0
wN = pow(7,k,P)
assert pow(wN,(2*N),P) == 1
w = []
for j in range(2*N):
w.append(pow(wN,j,P))
wInv = []
for j in range(2*N):
wInv.append(pow(w[j],P-2,P))
a = [randint(0,2**16) for _ in xrange(N)]+[0]*N
b = [randint(0,2**16) for _ in xrange(N)]+[0]*N
polynomial_a = Polynomial()
polynomial_a.coef = a
polynomial_b = Polynomial()
polynomial_b.coef = b
polynomial_c = polynomial_a*polynomial_b
my_ntt_a = CPU_NTT(a)
my_ntt_b = CPU_NTT(b)
my_ntt_c = [x[0]*x[1] % P for x in zip(my_ntt_a,my_ntt_b)]
ntt_intt_c = CPU_INTT(my_ntt_c)
# assert len(ntt_intt_c) == len(polynomial_c.coef)
for i,v in enumerate(polynomial_c.coef):
v2 = ntt_intt_c[i]/(2*N)
assert v == v2
print "We are good"