本文整理汇总了Python中sage.modules.free_module.span函数的典型用法代码示例。如果您正苦于以下问题:Python span函数的具体用法?Python span怎么用?Python span使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了span函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: ExtendedTernaryGolayCode
def ExtendedTernaryGolayCode():
"""
ExtendedTernaryGolayCode returns a ternary Golay code. This is a
self-dual perfect [12,6,6] code.
EXAMPLES::
sage: C = codes.ExtendedTernaryGolayCode()
sage: C
Linear code of length 12, dimension 6 over Finite Field of size 3
sage: C.minimum_distance()
6
sage: C.minimum_distance(algorithm='gap') # long time, check d=6
6
AUTHORS:
- David Joyner (11-2005)
"""
B = [[1, 0, 0, 0, 0, 0, 2, 0, 1, 2, 1, 2],\
[0, 1, 0, 0, 0, 0, 1, 2, 2, 2, 1, 0],\
[0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1],\
[0, 0, 0, 1, 0, 0, 1, 1, 0, 2, 2, 2],\
[0, 0, 0, 0, 1, 0, 2, 1, 2, 2, 0, 1],\
[0, 0, 0, 0, 0, 1, 0, 2, 1, 2, 2, 1]]
V = span(B, GF(3))
return LinearCodeFromVectorSpace(V, d=6)
开发者ID:aaditya-thakkar,项目名称:sage,代码行数:27,代码来源:code_constructions.py
示例2: ExtendedBinaryGolayCode
def ExtendedBinaryGolayCode():
"""
ExtendedBinaryGolayCode() returns the extended binary Golay code.
This is a perfect [24,12,8] code. This code is self-dual.
EXAMPLES::
sage: C = codes.ExtendedBinaryGolayCode()
sage: C
Linear code of length 24, dimension 12 over Finite Field of size 2
sage: C.minimum_distance()
8
sage: C.minimum_distance(algorithm='gap') # long time, check d=8
8
AUTHORS:
- David Joyner (2007-05)
"""
B = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1],\
[0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0],\
[0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1],\
[0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0],\
[0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1],\
[0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1],\
[0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1],\
[0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0],\
[0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 0],\
[0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0],\
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1],\
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1]]
V = span(B, GF(2))
return LinearCodeFromVectorSpace(V, d=8)
开发者ID:aaditya-thakkar,项目名称:sage,代码行数:33,代码来源:code_constructions.py
示例3: TernaryGolayCode
def TernaryGolayCode():
r"""
TernaryGolayCode returns a ternary Golay code. This is a perfect
[11,6,5] code. It is also equivalent to a cyclic code, with
generator polynomial `g(x)=2+x^2+2x^3+x^4+x^5`.
EXAMPLES::
sage: C = codes.TernaryGolayCode()
sage: C
Linear code of length 11, dimension 6 over Finite Field of size 3
sage: C.minimum_distance()
5
sage: C.minimum_distance(algorithm='gap') # long time, check d=5
5
AUTHORS:
- David Joyner (2007-5)
"""
F = GF(3)
B = [[2, 0, 1, 2, 1, 1, 0, 0, 0, 0, 0],\
[0, 2, 0, 1, 2, 1, 1, 0, 0, 0, 0],\
[0, 0, 2, 0, 1, 2, 1, 1, 0, 0, 0],\
[0, 0, 0, 2, 0, 1, 2, 1, 1, 0, 0],\
[0, 0, 0, 0, 2, 0, 1, 2, 1, 1, 0],\
[0, 0, 0, 0, 0, 2, 0, 1, 2, 1, 1]]
V = span(B, F)
return LinearCodeFromVectorSpace(V, d=5)
开发者ID:aaditya-thakkar,项目名称:sage,代码行数:29,代码来源:code_constructions.py
示例4: rational_part
def rational_part(self):
"""
Return the rational part of this `L`-function at the central critical
value 1.
OUTPUT:
a rational number
EXAMPLES::
sage: from sage_modabvar import J0
sage: A, B = J0(43).decomposition()
sage: A.lseries().rational_part()
0
sage: B.lseries().rational_part()
2/7
"""
abelian_variety = self.abelian_variety()
modular_symbols = abelian_variety.modular_symbols()
Phi = modular_symbols.rational_period_mapping()
ambient_module = modular_symbols.ambient_module()
if self.vanishes_at_1():
return QQ(0)
else:
s = ambient_module.sturm_bound()
I = ambient_module.hecke_images(0, range(1, s+1))
PhiTe = span([Phi(ambient_module(I[n]))
for n in range(I.nrows())], ZZ)
ambient_plus = ambient_module.sign_submodule(1)
ambient_plus_cusp = ambient_plus.cuspidal_submodule()
PhiH1plus = span([Phi(x) for
x in ambient_plus_cusp.integral_basis()], ZZ)
return PhiTe.index_in(PhiH1plus)
开发者ID:kevinywlui,项目名称:sage_modabvar,代码行数:36,代码来源:lseries.py
示例5: BinaryGolayCode
def BinaryGolayCode():
r"""
BinaryGolayCode() returns a binary Golay code. This is a perfect
[23,12,7] code. It is also (equivalent to) a cyclic code, with
generator polynomial
`g(x)=1+x^2+x^4+x^5+x^6+x^{10}+x^{11}`. Extending it yields
the extended Golay code (see ExtendedBinaryGolayCode).
EXAMPLE::
sage: C = codes.BinaryGolayCode()
sage: C
Linear code of length 23, dimension 12 over Finite Field of size 2
sage: C.minimum_distance()
7
sage: C.minimum_distance(algorithm='gap') # long time, check d=7
7
AUTHORS:
- David Joyner (2007-05)
"""
F = GF(2)
B = [
[1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1],
]
# MS = MatrixSpace(F,12,23)
# V = VectorSpace(F,23)
V = span(B, F)
return LinearCode(V, d=7)
开发者ID:novoselt,项目名称:sage,代码行数:41,代码来源:code_constructions.py
示例6: RandomLinearCode
def RandomLinearCode(n,k,F):
r"""
The method used is to first construct a `k \times n`
matrix using Sage's random_element method for the MatrixSpace
class. The construction is probabilistic but should only fail
extremely rarely.
INPUT: Integers n,k, with `n>k`, and a finite field F
OUTPUT: Returns a "random" linear code with length n, dimension k
over field F.
EXAMPLES::
sage: C = codes.RandomLinearCode(30,15,GF(2))
sage: C
Linear code of length 30, dimension 15 over Finite Field of size 2
sage: C = codes.RandomLinearCode(10,5,GF(4,'a'))
sage: C
Linear code of length 10, dimension 5 over Finite Field in a of size 2^2
AUTHORS:
- David Joyner (2007-05)
"""
MS = MatrixSpace(F,k,n)
for i in range(50):
G = MS.random_element()
if G.rank() == k:
V = span(G.rows(), F)
return LinearCodeFromVectorSpace(V) # may not be in standard form
MS1 = MatrixSpace(F,k,k)
MS2 = MatrixSpace(F,k,n-k)
Ik = MS1.identity_matrix()
A = MS2.random_element()
G = Ik.augment(A)
return LinearCode(G) # in standard form
开发者ID:aaditya-thakkar,项目名称:sage,代码行数:37,代码来源:code_constructions.py
注:本文中的sage.modules.free_module.span函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论