本文整理汇总了Python中sage.all.ZZ.ideal方法的典型用法代码示例。如果您正苦于以下问题:Python ZZ.ideal方法的具体用法?Python ZZ.ideal怎么用?Python ZZ.ideal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sage.all.ZZ
的用法示例。
在下文中一共展示了ZZ.ideal方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: randomize
# 需要导入模块: from sage.all import ZZ [as 别名]
# 或者: from sage.all.ZZ import ideal [as 别名]
def randomize(self, prime):
assert not self.randomized
prev = None
for i in xrange(0, len(self.bp)):
d_i_minus_one = self.bp[i].zero.nrows()
d_i = self.bp[i].zero.ncols()
MSZp = MatrixSpace(ZZ.residue_field(ZZ.ideal(prime)), d_i_minus_one, d_i)
MSZp_square = MatrixSpace(ZZ.residue_field(ZZ.ideal(prime)), d_i, d_i)
if i != 0:
MSZp = MatrixSpace(ZZ.residue_field(ZZ.ideal(prime)), d_i_minus_one, d_i)
self.bp[i] = self.bp[i].group(MSZp, prime).mult_left(prev.adjoint())
if i != len(self.bp) - 1:
cur = MSZp_square.random_element()
self.bp[i] = self.bp[i].group(MSZp, prime).mult_right(cur)
prev = cur
# compute S * B_0
d_0 = self.bp[0].zero.nrows()
d_1 = self.bp[0].zero.ncols()
S = matrix.identity(d_0)
for i in xrange(d_0):
S[i, i] = random.randint(0, prime - 1)
MSZp = MatrixSpace(ZZ.residue_field(ZZ.ideal(prime)), d_0, d_1)
self.bp[0] = self.bp[0].group(MSZp, prime).mult_left(S)
# compute B_ell * T
r = self.bp[-1].zero.nrows()
c = self.bp[-1].zero.ncols()
T = matrix.identity(c)
for i in xrange(c):
T[i, i] = random.randint(0, prime - 1)
MSZp = MatrixSpace(ZZ.residue_field(ZZ.ideal(prime)), r, c)
self.bp[-1] = self.bp[-1].group(MSZp, prime).mult_right(T)
self.randomized = True
示例2: randomize
# 需要导入模块: from sage.all import ZZ [as 别名]
# 或者: from sage.all.ZZ import ideal [as 别名]
def randomize(self, prime):
assert not self.randomized
MSZp = MatrixSpace(ZZ.residue_field(ZZ.ideal(prime)), self.size)
def random_matrix():
while True:
m = MSZp.random_element()
if not m.is_singular() and m.rank() == self.size:
return m, m.inverse()
m0, m0i = random_matrix()
self.bp[0] = self.bp[0].group(MSZp, prime).mult_left(m0)
for i in xrange(1, len(self.bp)):
mi, mii = random_matrix()
self.bp[i-1] = self.bp[i-1].group(MSZp, prime).mult_right(mii)
self.bp[i] = self.bp[i].group(MSZp, prime).mult_left(mi)
self.bp[-1] = self.bp[-1].group(MSZp, prime).mult_right(m0i)
VSZp = VectorSpace(ZZ.residue_field(ZZ.ideal(prime)), self.size)
self.s = copy(VSZp.zero())
self.s[0] = 1
self.t = copy(VSZp.zero())
self.t[len(self.t) - 1] = 1
self.m0, self.m0i = m0, m0i
self.randomized = True