本文整理匯總了Python中sage.schemes.projective.projective_space.ProjectiveSpace.point_set方法的典型用法代碼示例。如果您正苦於以下問題:Python ProjectiveSpace.point_set方法的具體用法?Python ProjectiveSpace.point_set怎麽用?Python ProjectiveSpace.point_set使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類sage.schemes.projective.projective_space.ProjectiveSpace
的用法示例。
在下文中一共展示了ProjectiveSpace.point_set方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: parity_check_matrix
# 需要導入模塊: from sage.schemes.projective.projective_space import ProjectiveSpace [as 別名]
# 或者: from sage.schemes.projective.projective_space.ProjectiveSpace import point_set [as 別名]
def parity_check_matrix(self):
r"""
Return a parity check matrix of ``self``.
The construction of the parity check matrix in case ``self``
is not a binary code is not really well documented.
Regarding the choice of projective geometry, one might check:
- the note over section 2.3 in [Rot2006]_, pages 47-48
- the dedicated paragraph in [HP2003]_, page 30
EXAMPLES::
sage: C = codes.HammingCode(GF(3), 3)
sage: C.parity_check_matrix()
[1 0 1 1 0 1 0 1 1 1 0 1 1]
[0 1 1 2 0 0 1 1 2 0 1 1 2]
[0 0 0 0 1 1 1 1 1 2 2 2 2]
"""
n = self.length()
F = self.base_field()
m = n - self.dimension()
MS = MatrixSpace(F, n, m)
X = ProjectiveSpace(m - 1, F)
PFn = [list(p) for p in X.point_set(F).points()]
H = MS(PFn).transpose()
H = H[::-1, :]
H.set_immutable()
return H
示例2: HammingCode
# 需要導入模塊: from sage.schemes.projective.projective_space import ProjectiveSpace [as 別名]
# 或者: from sage.schemes.projective.projective_space.ProjectiveSpace import point_set [as 別名]
def HammingCode(r,F):
r"""
Implements the Hamming codes.
The `r^{th}` Hamming code over `F=GF(q)` is an
`[n,k,d]` code with length `n=(q^r-1)/(q-1)`,
dimension `k=(q^r-1)/(q-1) - r` and minimum distance
`d=3`. The parity check matrix of a Hamming code has rows
consisting of all nonzero vectors of length r in its columns,
modulo a scalar factor so no parallel columns arise. A Hamming code
is a single error-correcting code.
INPUT:
- ``r`` - an integer 2
- ``F`` - a finite field.
OUTPUT: Returns the r-th q-ary Hamming code.
EXAMPLES::
sage: codes.HammingCode(3,GF(2))
Linear code of length 7, dimension 4 over Finite Field of size 2
sage: C = codes.HammingCode(3,GF(3)); C
Linear code of length 13, dimension 10 over Finite Field of size 3
sage: C.minimum_distance()
3
sage: C.minimum_distance(algorithm='gap') # long time, check d=3
3
sage: C = codes.HammingCode(3,GF(4,'a')); C
Linear code of length 21, dimension 18 over Finite Field in a of size 2^2
While the ``codes`` object now gathers all code constructors,
``HammingCode`` is still available in the global namespace::
sage: HammingCode(3,GF(2))
doctest:...: DeprecationWarning: This method soon will not be available in that way anymore. To use it, you can now call it by typing codes.HammingCode
See http://trac.sagemath.org/15445 for details.
Linear code of length 7, dimension 4 over Finite Field of size 2
"""
q = F.order()
n = (q**r-1)/(q-1)
k = n-r
MS = MatrixSpace(F,n,r)
X = ProjectiveSpace(r-1,F)
PFn = [list(p) for p in X.point_set(F).points(F)]
H = MS(PFn).transpose()
Cd = LinearCode(H)
# Hamming code always has distance 3, so we provide the distance.
return LinearCode(Cd.dual_code().gen_mat(), d=3)
示例3: HammingCode
# 需要導入模塊: from sage.schemes.projective.projective_space import ProjectiveSpace [as 別名]
# 或者: from sage.schemes.projective.projective_space.ProjectiveSpace import point_set [as 別名]
def HammingCode(r,F):
r"""
Implements the Hamming codes.
The `r^{th}` Hamming code over `F=GF(q)` is an
`[n,k,d]` code with length `n=(q^r-1)/(q-1)`,
dimension `k=(q^r-1)/(q-1) - r` and minimum distance
`d=3`. The parity check matrix of a Hamming code has rows
consisting of all nonzero vectors of length r in its columns,
modulo a scalar factor so no parallel columns arise. A Hamming code
is a single error-correcting code.
INPUT:
- ``r`` - an integer 2
- ``F`` - a finite field.
OUTPUT: Returns the r-th q-ary Hamming code.
EXAMPLES::
sage: codes.HammingCode(3,GF(2))
Linear code of length 7, dimension 4 over Finite Field of size 2
sage: C = codes.HammingCode(3,GF(3)); C
Linear code of length 13, dimension 10 over Finite Field of size 3
sage: C.minimum_distance()
3
sage: C.minimum_distance(algorithm='gap') # long time, check d=3
3
sage: C = codes.HammingCode(3,GF(4,'a')); C
Linear code of length 21, dimension 18 over Finite Field in a of size 2^2
"""
q = F.order()
n = (q**r-1)/(q-1)
k = n-r
MS = MatrixSpace(F,n,r)
X = ProjectiveSpace(r-1,F)
PFn = [list(p) for p in X.point_set(F).points(F)]
H = MS(PFn).transpose()
Cd = LinearCode(H)
# Hamming code always has distance 3, so we provide the distance.
return LinearCode(Cd.dual_code().generator_matrix(), d=3)