Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
r""" Hamming Code
Given an integer `r` and a field `F`, such that `F=GF(q)`, the `[n, k, d]` code with length `n=\frac{q^{r}-1}{q-1}`, dimension `k=\frac{q^{r}-1}{q-1} - r` and minimum distance `d=3` is called the Hamming Code of order `r`.
REFERENCES:
- [Rot2006]_ """
#***************************************************************************** # Copyright (C) 2016 David Lucas <david.lucas@inria.fr> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. # http://www.gnu.org/licenses/ #*****************************************************************************
LinearCodeParityCheckEncoder)
r""" Representation of a Hamming code.
INPUT:
- ``base_field`` -- the base field over which ``self`` is defined.
- ``order`` -- the order of ``self``.
EXAMPLES::
sage: C = codes.HammingCode(GF(7), 3) sage: C [57, 54] Hamming Code over GF(7) """
r""" TESTS:
If ``base_field`` is not a finite field, an exception is raised::
sage: codes.HammingCode(RR, 3) Traceback (most recent call last): ... ValueError: base_field has to be a finite field
If ``order`` is not a Sage Integer or a Python int, an exception is raised:: sage: codes.HammingCode(GF(3), 3.14) Traceback (most recent call last): ... ValueError: order has to be a Sage Integer or a Python int """ from sage.misc.superseded import deprecation deprecation(19930, "codes.HammingCode(r, F) is now deprecated. Please use codes.HammingCode(F, r) instead.") tmp = copy(order) order = copy(base_field) base_field = copy(tmp)
r""" Tests equality of Hamming Code objects.
EXAMPLES::
sage: C1 = codes.HammingCode(GF(7), 3) sage: C2 = codes.HammingCode(GF(7), 3) sage: C1 == C2 True """ and self.length() == other.length()\ and self.dimension() == other.dimension()
r""" Returns a string representation of ``self``.
EXAMPLES::
sage: C = codes.HammingCode(GF(7), 3) sage: C [57, 54] Hamming Code over GF(7) """ % (self.length(), self.dimension(), self.base_field().cardinality())
r""" Returns a latex representation of ``self``.
EXAMPLES::
sage: C = codes.HammingCode(GF(7), 3) sage: latex(C) [57, 54] \textnormal{ Hamming Code over }\Bold{F}_{7} """ % (self.length(), self.dimension(), self.base_field()._latex_())
def parity_check_matrix(self): r""" Returns 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]
"""
r""" Returns the minimum distance of ``self``. It is always 3 as ``self`` is a Hamming Code.
EXAMPLES::
sage: C = codes.HammingCode(GF(7), 3) sage: C.minimum_distance() 3 """
####################### registration ###############################
|