Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagelib
Path: blob/master/sage/coding/ag_code.py
4034 views
1
r"""nodoctest -- totally broken right now
2
Algebraic-Geometric Codes
3
4
AUTHOR:
5
-- David Joyner (2006-01-26): written
6
-- William Stein (2006-01-23) -- inclusion in Sage
7
"""
8
9
#*****************************************************************************
10
# Copyright (C) 2006 David Joyner <[email protected]>
11
# 2006 William Stein <[email protected]>
12
#
13
# Distributed under the terms of the GNU General Public License (GPL)
14
#
15
# http://www.gnu.org/licenses/
16
#*****************************************************************************
17
18
import copy
19
20
import linear_code
21
22
from sage.matrix.all import MatrixSpace
23
24
def ag_code(C, D, E):
25
r"""
26
INPUT:
27
C -- a plane curve over a finite field F of prime order
28
D -- a divisor on C
29
E -- P1 + ... + Pn, another divisor, a sum of distinct
30
points on X whose support is disjoint from that
31
of D and with n > deg(D) > 0.
32
33
OUTPUT:
34
The linear code defined by C, D, and E as in Stichtenoth.
35
36
Calls Singular's \code{BrillNoether functions}. Will break on some
37
singular curves or if the field size is too large, etc.; when
38
this happens a ??? exception is raised.
39
40
EXAMPLES:
41
sage: x,y,z = ProjectiveSpace(2, GF(17), names = 'xyz').gens()
42
sage: C = Curve(y^2*z^7 - x^9 - x*z^8)
43
sage: pts = C.rational_points(sorted=False)
44
sage: D = C.divisor([(3,pts[0]), (-1,pts[1]), (10,pts[5])]); D
45
3*(0 : 0 : 1) - (0 : 1 : 0) + 10*(11 : 0 : 1)
46
sage: E = add([C.divisor(p) for p in [pts[2],pts[3],pts[4]]]); E
47
(1 : 11 : 1) + (1 : 6 : 1) + (10 : 0 : 1)
48
sage: V = ag_code(C, D,E)
49
sage: V
50
Linear code of length 2, dimension 2 over Finite Field of size 17
51
sage: V.basis()
52
[(12, 12), (11, 11), (12, 12), (2, 2), (2, 2), (3, 14), (13, 4), (7, 7), (7, 10)]
53
54
sage: P2 = ProjectiveSpace(2, GF(11), names = ['x','y','z'])
55
sage: x, y, z = P2.coordinate_ring().gens()
56
sage: f = y^8 + x^8 - z^8
57
sage: C = Curve(f)
58
sage: pts = C.rational_points()
59
sage: D = C.divisor(pts[0])*10 - C.divisor(pts[1]) + C.divisor(pts[5])*10
60
sage: E = add([C.divisor(pts[i]) for i in [2,3,4,6,7,8,9,10,11]])
61
sage: V = ag_code(C, D,E); V
62
Linear code of length 8, dimension 2 over Finite Field of size 11
63
sage: V.basis()
64
[(6, 6), (11, 11), (13, 13), (13, 13), (15, 15), (8, 9), (3, 14), (7, 7), (9, 8)]
65
66
sage: P2 = ProjectiveSpace(2, GF(11), names = ['x','y','z'])
67
sage: x, y, z = P2.coordinate_ring().gens()
68
sage: f = x^3*y - y^3*z + z^3*x
69
sage: C = Curve(f)
70
sage: pts = C.rational_points(sorted=False)
71
sage: D = C.divisor(pts[0])*3 - C.divisor(pts[1]) + C.divisor(pts[5])*5
72
sage: len(C.riemann_roch_basis(D))
73
5
74
sage: E = add([C.divisor(pts[i]) for i in [2,3,4,6,7,8,9,10,11]])
75
sage: V = ag_code(C, D,E); V
76
Linear code of length 8, dimension 5 over Finite Field of size 11
77
sage: V.basis()
78
[(1, 8, 4, 1, 10, 1, 5, 8), (2, 8, 1, 7, 3, 5, 8, 2), (1, 7, 4, 7, 5, 7, 4, 9), (0, 7, 0, 9, 5, 8, 6, 3), (6, 10, 1, 4, 6, 4, 8, 0)]
79
sage: V.minimum_distance()
80
3
81
82
AUTHOR: David Joyner (2006-01)
83
"""
84
F = C.base_ring()
85
one = F(1)
86
B = C.riemann_roch_basis(D)
87
k = len(B)
88
if k == 0:
89
A = MatrixSpace(F, 0, 0)(0)
90
return sage.coding.all.LinearCode(A)
91
92
P = C.rational_points(algorithm="bn", sorted=False) # algorithm="bn" does not work here ....
93
94
N = len(P)
95
pts = copy.copy(E.support())
96
for p in pts:
97
for i in range(k):
98
if (B[i].denominator())(F(p[0]), F(p[1]), F(p[2])) == 0:
99
pts.remove(p)
100
break
101
102
MS = MatrixSpace(F, len(B), len(pts))
103
pts.sort()
104
G = [[B[i](F(p[0]), F(p[1]), F(p[2])) for p in pts] for i in range(k)]
105
G = MS(G)
106
return linear_code.LinearCode(G)
107
108