本文整理汇总了Python中sage.rings.finite_rings.finite_field_constructor.FiniteField.gen方法的典型用法代码示例。如果您正苦于以下问题:Python FiniteField.gen方法的具体用法?Python FiniteField.gen怎么用?Python FiniteField.gen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sage.rings.finite_rings.finite_field_constructor.FiniteField
的用法示例。
在下文中一共展示了FiniteField.gen方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: DuadicCodeOddPair
# 需要导入模块: from sage.rings.finite_rings.finite_field_constructor import FiniteField [as 别名]
# 或者: from sage.rings.finite_rings.finite_field_constructor.FiniteField import gen [as 别名]
def DuadicCodeOddPair(F,S1,S2):
"""
Constructs the "odd pair" of duadic codes associated to the
"splitting" S1, S2 of n.
.. warning::
Maybe the splitting should be associated to a sum of
q-cyclotomic cosets mod n, where q is a *prime*.
EXAMPLES::
sage: from sage.coding.code_constructions import _is_a_splitting
sage: n = 11; q = 3
sage: C = Zmod(n).cyclotomic_cosets(q); C
[[0], [1, 3, 4, 5, 9], [2, 6, 7, 8, 10]]
sage: S1 = C[1]
sage: S2 = C[2]
sage: _is_a_splitting(S1,S2,11)
True
sage: codes.DuadicCodeOddPair(GF(q),S1,S2)
([11, 6] Cyclic Code over GF(3),
[11, 6] Cyclic Code over GF(3))
This is consistent with Theorem 6.1.3 in [HP2003]_.
"""
from .cyclic_code import CyclicCode
n = len(S1) + len(S2) + 1
if not _is_a_splitting(S1,S2,n):
raise TypeError("%s, %s must be a splitting of %s."%(S1,S2,n))
q = F.order()
k = Mod(q,n).multiplicative_order()
FF = GF(q**k,"z")
z = FF.gen()
zeta = z**((q**k-1)/n)
P1 = PolynomialRing(FF,"x")
x = P1.gen()
g1 = prod([x-zeta**i for i in S1+[0]])
g2 = prod([x-zeta**i for i in S2+[0]])
j = sum([x**i/n for i in range(n)])
P2 = PolynomialRing(F,"x")
x = P2.gen()
coeffs1 = [_lift2smallest_field(c)[0] for c in (g1+j).coefficients(sparse=False)]
coeffs2 = [_lift2smallest_field(c)[0] for c in (g2+j).coefficients(sparse=False)]
gg1 = P2(coeffs1)
gg2 = P2(coeffs2)
gg1 = gcd(gg1, x**n - 1)
gg2 = gcd(gg2, x**n - 1)
C1 = CyclicCode(length = n, generator_pol = gg1)
C2 = CyclicCode(length = n, generator_pol = gg2)
return C1,C2
示例2: DuadicCodeEvenPair
# 需要导入模块: from sage.rings.finite_rings.finite_field_constructor import FiniteField [as 别名]
# 或者: from sage.rings.finite_rings.finite_field_constructor.FiniteField import gen [as 别名]
def DuadicCodeEvenPair(F,S1,S2):
r"""
Constructs the "even pair" of duadic codes associated to the
"splitting" (see the docstring for ``_is_a_splitting``
for the definition) S1, S2 of n.
.. warning::
Maybe the splitting should be associated to a sum of
q-cyclotomic cosets mod n, where q is a *prime*.
EXAMPLES::
sage: from sage.coding.code_constructions import _is_a_splitting
sage: n = 11; q = 3
sage: C = Zmod(n).cyclotomic_cosets(q); C
[[0], [1, 3, 4, 5, 9], [2, 6, 7, 8, 10]]
sage: S1 = C[1]
sage: S2 = C[2]
sage: _is_a_splitting(S1,S2,11)
True
sage: codes.DuadicCodeEvenPair(GF(q),S1,S2)
([11, 5] Cyclic Code over GF(3),
[11, 5] Cyclic Code over GF(3))
"""
from .cyclic_code import CyclicCode
n = len(S1) + len(S2) + 1
if not _is_a_splitting(S1,S2,n):
raise TypeError("%s, %s must be a splitting of %s."%(S1,S2,n))
q = F.order()
k = Mod(q,n).multiplicative_order()
FF = GF(q**k,"z")
z = FF.gen()
zeta = z**((q**k-1)/n)
P1 = PolynomialRing(FF,"x")
x = P1.gen()
g1 = prod([x-zeta**i for i in S1+[0]])
g2 = prod([x-zeta**i for i in S2+[0]])
P2 = PolynomialRing(F,"x")
x = P2.gen()
gg1 = P2([_lift2smallest_field(c)[0] for c in g1.coefficients(sparse=False)])
gg2 = P2([_lift2smallest_field(c)[0] for c in g2.coefficients(sparse=False)])
C1 = CyclicCode(length = n, generator_pol = gg1)
C2 = CyclicCode(length = n, generator_pol = gg2)
return C1,C2
示例3: check_consistency
# 需要导入模块: from sage.rings.finite_rings.finite_field_constructor import FiniteField [as 别名]
# 或者: from sage.rings.finite_rings.finite_field_constructor.FiniteField import gen [as 别名]
def check_consistency(self, n):
"""
Check that the pseudo-Conway polynomials of degree dividing
`n` in this lattice satisfy the required compatibility
conditions.
EXAMPLES::
sage: from sage.rings.finite_rings.conway_polynomials import PseudoConwayLattice
sage: PCL = PseudoConwayLattice(2, use_database=False)
sage: PCL.check_consistency(6)
sage: PCL.check_consistency(60) # long time
"""
p = self.p
K = FiniteField(p**n, modulus = self.polynomial(n), names='a')
a = K.gen()
for m in n.divisors():
assert (a**((p**n-1)//(p**m-1))).minimal_polynomial() == self.polynomial(m)
示例4: BCHCode
# 需要导入模块: from sage.rings.finite_rings.finite_field_constructor import FiniteField [as 别名]
# 或者: from sage.rings.finite_rings.finite_field_constructor.FiniteField import gen [as 别名]
def BCHCode(n, delta, F, b=0):
r"""
A 'Bose-Chaudhuri-Hockenghem code' (or BCH code for short) is the
largest possible cyclic code of length n over field F=GF(q), whose
generator polynomial has zeros (which contain the set)
`Z = \{a^{b},a^{b+1}, ..., a^{b+delta-2}\}`, where a is a
primitive `n^{th}` root of unity in the splitting field
`GF(q^m)`, b is an integer `0\leq b\leq n-delta+1`
and m is the multiplicative order of q modulo n. (The integers
`b,...,b+delta-2` typically lie in the range
`1,...,n-1`.) The integer `delta \geq 1` is called
the "designed distance". The length n of the code and the size q of
the base field must be relatively prime. The generator polynomial
is equal to the least common multiple of the minimal polynomials of
the elements of the set `Z` above.
Special cases are b=1 (resulting codes are called 'narrow-sense'
BCH codes), and `n=q^m-1` (known as 'primitive' BCH
codes).
It may happen that several values of delta give rise to the same
BCH code. The largest one is called the Bose distance of the code.
The true minimum distance, d, of the code is greater than or equal
to the Bose distance, so `d\geq delta`.
EXAMPLES::
sage: FF.<a> = GF(3^2,"a")
sage: x = PolynomialRing(FF,"x").gen()
sage: L = [b.minpoly() for b in [a,a^2,a^3]]; g = LCM(L)
sage: f = x^(8)-1
sage: g.divides(f)
True
sage: C = codes.CyclicCode(8,g); C
Linear code of length 8, dimension 4 over Finite Field of size 3
sage: C.minimum_distance()
4
sage: C = codes.BCHCode(8,3,GF(3),1); C
Linear code of length 8, dimension 4 over Finite Field of size 3
sage: C.minimum_distance()
4
sage: C = codes.BCHCode(8,3,GF(3)); C
Linear code of length 8, dimension 5 over Finite Field of size 3
sage: C.minimum_distance()
3
sage: C = codes.BCHCode(26, 5, GF(5), b=1); C
Linear code of length 26, dimension 10 over Finite Field of size 5
"""
q = F.order()
R = IntegerModRing(n)
m = R(q).multiplicative_order()
FF = GF(q ** m, "z")
z = FF.gen()
e = z.multiplicative_order() / n
a = z ** e # order n
P = PolynomialRing(F, "x")
x = P.gen()
L1 = []
for coset in R.cyclotomic_cosets(q, range(b, b + delta - 1)):
L1.extend(P((a ** j).minpoly()) for j in coset)
g = P(LCM(L1))
if not (g.divides(x ** n - 1)):
raise ValueError("BCH codes does not exist with the given input.")
return CyclicCodeFromGeneratingPolynomial(n, g)