Skip to content

Commit b711d97

Browse files
Release Managervbraun
Release Manager
authored andcommitted
Trac #20342: Method for the rate of a linear code.
The "rate" of a linear code is `k/n` where `k` is the dimension and `n` the length of the code. This is fundamental number that all coding theorists use. This should be available for any linear code in Sage. Note that it should be implemented on the class `AbstractLinearCode` to be available to both `LinearCode` and specific families of codes such as `GeneralizedReedSolomonCode`. URL: https://trac.sagemath.org/20342 Reported by: jsrn Ticket author(s): David Lucas Reviewer(s): Daniel Augot
2 parents 4b0dc61 + e397cec commit b711d97

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/sage/coding/linear_code.py

+15
Original file line numberDiff line numberDiff line change
@@ -2772,6 +2772,21 @@ def relative_distance(self):
27722772
"""
27732773
return self.minimum_distance() / self.length()
27742774

2775+
2776+
def rate(self):
2777+
r"""
2778+
Return the ratio of the number of information symbols to
2779+
the code length.
2780+
2781+
EXAMPLES::
2782+
2783+
sage: C = codes.HammingCode(GF(2), 3)
2784+
sage: C.rate()
2785+
4/7
2786+
"""
2787+
return self.dimension() / self.length()
2788+
2789+
27752790
def redundancy_matrix(self):
27762791
r"""
27772792
Returns the non-identity columns of a systematic generator matrix for

0 commit comments

Comments
 (0)