@@ -94,31 +94,31 @@ def __init__(self, evaluation_points, dimension, column_multipliers=None):
94
94
sage: C = codes.GeneralizedReedSolomonCode([1,2,3], 1)
95
95
Traceback (most recent call last):
96
96
...
97
- ValueError: Evaluation points must be in a finite field
97
+ ValueError: Evaluation points must be in a finite field (and Integer Ring is not one)
98
98
99
99
If the evaluation points are not from the same finite field, it raises an error::
100
100
101
101
sage: F2, F3 = GF(2) , GF(3)
102
102
sage: C = codes.GeneralizedReedSolomonCode([F2.zero(),F2.one(),F3(2)], 1)
103
103
Traceback (most recent call last):
104
104
...
105
- ValueError: All evaluation points must be in the same finite field
105
+ ValueError: Failed converting all evaluation points to the same field (unable to find a common ring for all elements)
106
106
107
- If the column multipliers are not from a finite field, or not in the same
107
+ If the column multipliers cannot be converted into the finite are not from a finite field, or cannot be not in the same
108
108
finite field as the evaluation points, it raises an error::
109
109
110
110
sage: F = GF(59)
111
111
sage: F2 = GF(61)
112
112
sage: n, k = 40, 12
113
- sage: C = codes.GeneralizedReedSolomonCode(F.list()[:n], k, vector(range(1,n+1)) )
113
+ sage: C = codes.GeneralizedReedSolomonCode(F.list()[:n], k, [.3]*n )
114
114
Traceback (most recent call last):
115
115
...
116
- ValueError: Column multipliers and evaluation points must be in the same field
116
+ ValueError: Failed converting all evaluation points and column multipliers to the same field (unable to find a common ring for all elements)
117
117
118
118
sage: C = codes.GeneralizedReedSolomonCode(F.list()[:n], k, F2.list()[1:n+1])
119
119
Traceback (most recent call last):
120
120
...
121
- ValueError: Column multipliers and evaluation points must be in the same field
121
+ ValueError: Failed converting all evaluation points and column multipliers to the same field (unable to find a common ring for all elements)
122
122
123
123
The number of column multipliers is checked as well::
124
124
@@ -127,7 +127,7 @@ def __init__(self, evaluation_points, dimension, column_multipliers=None):
127
127
sage: C = codes.GeneralizedReedSolomonCode(F.list()[:n], k, F.list()[1:n])
128
128
Traceback (most recent call last):
129
129
...
130
- ValueError: There must be exactly 40 column multipliers
130
+ ValueError: There must be the same number of evaluation points as column multipliers
131
131
132
132
It is not allowed to have 0 as a column multiplier::
133
133
@@ -138,35 +138,51 @@ def __init__(self, evaluation_points, dimension, column_multipliers=None):
138
138
...
139
139
ValueError: All column multipliers must be non-zero
140
140
141
- And all the evaluation points must be different::
141
+ And all the evaluation points must be different. Note that they should
142
+ be different after converting into the same field::
142
143
143
- sage: F = GF(59)
144
- sage: n, k = 40, 12
145
- sage: C = codes.GeneralizedReedSolomonCode([F.one()]*n, k)
144
+ sage: F = GF(5)
145
+ sage: C = codes.GeneralizedReedSolomonCode([ F(0), 1, 2, 3, 5 ], 3)
146
146
Traceback (most recent call last):
147
147
...
148
148
ValueError: All evaluation points must be different
149
+
150
+ The dimension is not allowed to exceed the length::
151
+
152
+ sage: F = GF(59)
153
+ sage: n, k = 40, 100
154
+ sage: C = codes.GeneralizedReedSolomonCode(F.list()[:n], k)
155
+ Traceback (most recent call last):
156
+ ...
157
+ ValueError: The dimension must be a positive integer at most the length of the code.
149
158
"""
150
- F = evaluation_points [0 ].base_ring ()
151
- if F .is_finite () == False :
152
- raise ValueError ("Evaluation points must be in a finite field" )
153
- if not all (F == e .base_ring () for e in evaluation_points ):
154
- raise ValueError ("All evaluation points must be in the same finite field" )
159
+ if column_multipliers :
160
+ if len (evaluation_points ) != len (column_multipliers ):
161
+ raise ValueError ("There must be the same number of evaluation points as column multipliers" );
162
+ try :
163
+ common_points = vector (list (evaluation_points ) + list (column_multipliers ))
164
+ F = common_points .base_ring ()
165
+ self ._evaluation_points = common_points [:len (evaluation_points )]
166
+ self ._column_multipliers = common_points [len (evaluation_points ):]
167
+ except (TypeError , ValueError ) as e :
168
+ raise ValueError ("Failed converting all evaluation points and column multipliers to the same field (%s)" % e .message )
169
+ else :
170
+ try :
171
+ self ._evaluation_points = vector (evaluation_points )
172
+ F = self ._evaluation_points .base_ring ()
173
+ self ._column_multipliers = vector (F , [F .one ()] * len (self ._evaluation_points ))
174
+ except (TypeError , ValueError ) as e :
175
+ raise ValueError ("Failed converting all evaluation points to the same field (%s)" % e .message )
176
+
177
+ if F .is_finite () == False or F .is_field () == False :
178
+ raise ValueError ("Evaluation points must be in a finite field (and %s is not one)" % F )
155
179
super (GeneralizedReedSolomonCode , self ).__init__ (F , \
156
- len (evaluation_points ), "EvaluationVector" , "Syndrome" )
157
- self ._evaluation_points = tuple (evaluation_points )
180
+ len (self ._evaluation_points ), "EvaluationVector" , "Syndrome" )
181
+
182
+ if dimension not in ZZ or dimension > self ._length or dimension < 1 :
183
+ raise ValueError ("The dimension must be a positive integer at most the length of the code." )
158
184
self ._dimension = dimension
159
185
160
- if column_multipliers is None :
161
- self ._column_multipliers = tuple (self .base_field ().one () for i in range (self ._length ) )
162
- else :
163
- if not all (F == e .base_ring () for e in column_multipliers ):
164
- raise ValueError ("Column multipliers and evaluation points\
165
- must be in the same field" )
166
- self ._column_multipliers = tuple (column_multipliers )
167
- if len (self ._column_multipliers ) != self ._length :
168
- raise ValueError ("There must be exactly %s column multipliers" \
169
- % self ._length )
170
186
if 0 in self ._column_multipliers :
171
187
raise ValueError ("All column multipliers must be non-zero" )
172
188
if len (self ._evaluation_points ) != len (set (self ._evaluation_points )):
@@ -257,7 +273,7 @@ def minimum_distance(self):
257
273
258
274
def evaluation_points (self ):
259
275
r"""
260
- Returns the list of evaluation points of ``self``.
276
+ Returns the evaluation points of ``self`` as a vector .
261
277
262
278
EXAMPLES::
263
279
@@ -271,7 +287,7 @@ def evaluation_points(self):
271
287
272
288
def column_multipliers (self ):
273
289
r"""
274
- Returns the list of column multipliers of ``self``.
290
+ Returns the column multipliers of ``self`` as a vector .
275
291
276
292
EXAMPLES::
277
293
0 commit comments