Cyclic Codes

Cyclic codes are a subtype of LinearCode and inherit its methods. For a worked introduction see the Cyclic Codes tutorial.

A cyclic code of length $n$ over $\mathbb{F}_q$ is determined by its defining set, a union of $q$-cyclotomic cosets modulo $n$. The cyclotomic functions below are therefore the natural way to specify and inspect these codes, and several of them are useful on their own when hunting for codes with prescribed parameters.

Reed-Solomon and BCH codes are the classical special cases. The generalized Reed-Solomon view of a Reed-Solomon code, along with alternant and Goppa codes, is documented in Generalized Reed-Solomon codes.

CodingTheory.BCHCode — Type
BCHCode(
    q::Int64,
    n::Int64,
    δ::Int64
) -> Union{BCHCode, ReedSolomonCode}
BCHCode(
    q::Int64,
    n::Int64,
    δ::Int64,
    b::Int64
) -> Union{BCHCode, ReedSolomonCode}

Return the BCHCode of length n over GF(q) with design distance δ and designed offset b.

source
CodingTheory.CyclicCode — Method
CyclicCode(
    q::Int64,
    n::Int64,
    elements::Vector{<:AbstractAlgebra.FinFieldElem};
    type
) -> Union{BCHCode, CyclicCode, ReedSolomonCode}

Return the Cyclic code of length n over GF(q) defined by the exact field elements passed in elements. If type = :nonzeros, they are treated as the non-roots.

source
CodingTheory.CyclicCode — Method
CyclicCode(
    q::Int64,
    n::Int64,
    elements::Vector{Int64};
    type
) -> Union{BCHCode, CyclicCode, ReedSolomonCode}

Return the Cyclic code of length n over GF(q) defined by the roots given as integer exponents in elements (where the roots are β^i for i ∈ elements). If type = :nonzeros is passed, elements are treated as the non-root exponents.

source
CodingTheory.CyclicCode — Method
CyclicCode(
    q::Int64,
    n::Int64,
    cosets::Vector{Vector{Int64}}
) -> Union{BCHCode, CyclicCode, ReedSolomonCode}

Return the CyclicCode of length n over GF(q) with q-cyclotomic cosets cosets. Evaluates lazily and auto-detects BCH and Reed-Solomon parameters.

source
CodingTheory.CyclicCode — Method
CyclicCode(
    n::Int64,
    g::Union{Nemo.FqPolyRingElem, Nemo.fpPolyRingElem, Nemo.fqPolyRepPolyRingElem}
) -> Union{BCHCode, CyclicCode, ReedSolomonCode}

Return the length n cyclic code generated by the polynomial g.

source
CodingTheory.ReedSolomonCode — Type
ReedSolomonCode(q::Int64, d::Int64) -> ReedSolomonCode
ReedSolomonCode(
    q::Int64,
    d::Int64,
    b::Int64
) -> ReedSolomonCode

Return the ReedSolomonCode over GF(q) with distance d and designed offset b.

source
AbstractAlgebra.is_irreducible — Method
is_irreducible(C::AbstractCyclicCode) -> Bool

Return true if the cyclic code C is irreducible.

Notes

  • An irreducible cyclic code has no non-trivial cyclic subcodes.
  • Algebraically, this occurs if and only if its non-zeros form exactly one q-cyclotomic coset (meaning it has exactly one constituent).
source
Base.:⊆ — Method
⊆(C1::AbstractCyclicCode, C2::AbstractCyclicCode) -> Any

Return whether or not C1 is a subcode of C2. A cyclic code is a subcode of another if and only if its defining set is a superset of the other's.

source
Base.zeros — Method
zeros(C::AbstractCyclicCode) -> Any

Return the zeros (as field elements) of C.

source
CodingTheory.:⊂ — Method
⊂(C1::AbstractCyclicCode, C2::AbstractCyclicCode) -> Any

Return whether C1 is a subcode of C2, not necessarily properly. This is an alias for ⊆, matching the behavior for general linear codes; use ⊊ to test proper containment.

source
CodingTheory.BCH_bound — Method
BCH_bound(C::AbstractCyclicCode) -> Any

Return the BCH bound for C. Computes lazily and caches the result.

source
CodingTheory.DuadicCodes — Method
DuadicCodes(
    q::Int64,
    n::Int64;
    include_zero
) -> NamedTuple{(:codes, :multiplier), <:Tuple{Vector{T} where T<:AbstractCyclicCode, Union{Missing, Int64}}}

Return the pair of Duadic codes of length n over GF(q).

Notes

  • Duadic codes exist if and only if there is a multiplier of order 2 that splits the roots.
  • Quadratic Residue (QR) codes are a special, highly symmetric case of Duadic codes.
source
CodingTheory.FireCode — Method
FireCode(
    p::Union{Nemo.FqPolyRingElem, Nemo.fpPolyRingElem},
    l::Int64
) -> Union{BCHCode, CyclicCode, ReedSolomonCode}

Return the fire code with generator polynomial (x^(2l - 1) + 1) * p.

source
CodingTheory.HT_bound — Method
HT_bound(C::AbstractCyclicCode) -> Any

Return the Hartmann-Tzeng bound for C. Computes lazily and caches the result.

source
CodingTheory.Hadamard_product_code — Method
Hadamard_product_code(
    C1::AbstractCyclicCode,
    C2::AbstractCyclicCode
) -> Union{BCHCode, CyclicCode, ReedSolomonCode}

Return the entrywise product code of C1 and C2, or the entrywise square of C. This is an alias for Schur_product_code.

source
CodingTheory.MattsonSolomon_transform — Method
MattsonSolomon_transform(
    v::Vector{<:AbstractAlgebra.FinFieldElem},
    α::AbstractAlgebra.FinFieldElem
) -> Any

Return the Mattson–Solomon polynomial of a vector v over F.

Notes

  • The Mattson-Solomon transform is the finite field equivalent of the Discrete Fourier Transform (DFT).
source
CodingTheory.PolyadicCodes — Method
PolyadicCodes(
    q::Int64,
    n::Int64,
    m::Int64;
    include_zero
) -> NamedTuple{(:codes, :multiplier), <:Tuple{Vector{T} where T<:AbstractCyclicCode, Union{Missing, Int64}}}

Return the family of m Polyadic codes of length n over GF(q).

Notes

  • Searches for a multiplier μ_a that splits the non-zero roots into m cycling sets.
  • Returns a NamedTuple containing the array of m codes and the multiplier a used.
  • If include_zero = true, the root 0 is added to all defining sets (yielding the even-like subcodes).
source
CodingTheory.QuadraticResidueCode — Method
QuadraticResidueCode(
    q::Int64,
    n::Int64
) -> Union{BCHCode, CyclicCode, ReedSolomonCode}

Return the cyclic code whose roots are the quadratic residues of q, n.

source
CodingTheory.Roos_bound — Method
Roos_bound(C::AbstractCyclicCode) -> Any

Return the Roos bound for C. Computes lazily and caches the result.

source
CodingTheory.Schur_product_code — Method
Schur_product_code(
    C1::AbstractCyclicCode,
    C2::AbstractCyclicCode
) -> Union{BCHCode, CyclicCode, ReedSolomonCode}

Return the entrywise product code of C1 and C2, or the entrywise square of C. This is an alias for entrywise_product_code.

source
CodingTheory.TetradicCodes — Method
TetradicCodes(
    q::Int64,
    n::Int64;
    include_zero
) -> NamedTuple{(:codes, :multiplier), <:Tuple{Vector{T} where T<:AbstractCyclicCode, Union{Missing, Int64}}}

Return the quad of Tetradic codes of length n over GF(q).

source
CodingTheory.TriadicCodes — Method
TriadicCodes(
    q::Int64,
    n::Int64;
    include_zero
) -> NamedTuple{(:codes, :multiplier), <:Tuple{Vector{T} where T<:AbstractCyclicCode, Union{Missing, Int64}}}

Return the triplet of Triadic codes of length n over GF(q).

source
CodingTheory.ambient_constituents — Method
ambient_constituents(
    q::Int64,
    n::Int64
) -> Vector{AbstractCyclicCode}

Return all irreducible cyclic codes of length n over GF(q).

Notes

  • This decomposes the entire ambient space F_q[x]/<x^n - 1> into its minimal ideals.
source
CodingTheory.apply_multiplier — Method
apply_multiplier(
    C::AbstractCyclicCode,
    a::Int64
) -> Union{BCHCode, CyclicCode, ReedSolomonCode}

Return a new cyclic code by applying the multiplier a to the cyclic code C.

Notes

  • Algebraically, this multiplies the defining set of the code by a (mod n).
  • This implies the codewords of the new code are a permutation of the original codewords.
source
CodingTheory.apply_multiplier — Method
apply_multiplier(v::Array{T, 1}, a::Int64) -> Vector

Apply the multiplier a to the vector v of length n.

Notes

  • The multiplier maps the coordinate index i to a * i (mod n).
  • Requires gcd(a, n) == 1 to ensure the mapping is a valid permutation.
source
CodingTheory.componentwise_product_code — Method
componentwise_product_code(
    C1::AbstractCyclicCode,
    C2::AbstractCyclicCode
) -> Union{BCHCode, CyclicCode, ReedSolomonCode}

Return the entrywise product code of C1 and C2, or the entrywise square of C. This is an alias for Schur_product_code.

source
CodingTheory.constituents — Method
constituents(
    C::AbstractCyclicCode
) -> Vector{<:AbstractCyclicCode}

Return the irreducible cyclic constituents of the cyclic code C.

Notes

  • By the Chinese Remainder Theorem, every cyclic code is a direct sum of irreducible cyclic codes.
  • These constituents correspond to the individual q-cyclotomic cosets that make up the non-zeros (the trace representation) of C.
source
CodingTheory.defining_set — Function
defining_set(
    nums::Vector{Int64},
    q::Int64,
    n::Int64
) -> Union{Vector{Vector{Int64}}, Vector{Int64}}
defining_set(
    nums::Vector{Int64},
    q::Int64,
    n::Int64,
    flat::Bool
) -> Union{Vector{Vector{Int64}}, Vector{Int64}}

Return the set of q-cyclotomic cosets of the numbers in nums modulo n. If flat is true, returns a single sorted array of the defining set.

source
CodingTheory.dual_defining_set — Method
dual_defining_set(
    def_set::Vector{Int64},
    n::Int64
) -> Vector{Int64}

Return the defining set of the dual code of length n and defining set def_set.

Notes

  • Mathematically, if C has roots β^i for i ∈ Z, the dual has roots β^(-i) for i ∉ Z.
source
CodingTheory.entrywise_product_code — Method
entrywise_product_code(
    C1::AbstractCyclicCode,
    C2::AbstractCyclicCode
) -> Union{BCHCode, CyclicCode, ReedSolomonCode}

Return the entrywise (Schur / Hadamard) product of cyclic codes C1 and C2.

Notes

  • By the Mattson-Solomon Transform, the non-zeros of the Schur product are the Minkowski sum of the non-zeros of the constituent codes.
source
CodingTheory.entrywise_product_code — Method
entrywise_product_code(
    C::AbstractCyclicCode
) -> Union{BCHCode, CyclicCode, ReedSolomonCode}

Return the entrywise (Schur / Hadamard) product of C with itself.

source
CodingTheory.inverse_MattsonSolomon_transform — Method
inverse_MattsonSolomon_transform(
    MS::AbstractAlgebra.PolyRingElem{<:AbstractAlgebra.FinFieldElem},
    n::Int64,
    α::AbstractAlgebra.FinFieldElem
) -> Any

Return the vector recovered by applying the inverse Mattson–Solomon transform to the Mattson–Solomon polynomial MS.

source
CodingTheory.is_multiplier_equivalent — Method
is_multiplier_equivalent(
    C1::AbstractCyclicCode,
    C2::AbstractCyclicCode
) -> Tuple{Bool, Any}

Return true and the multiplier a if the cyclic codes C1 and C2 are multiplier equivalent. Otherwise, return false and missing.

Notes

  • Two cyclic codes are multiplier equivalent if there exists some multiplier a coprime to n such that μ_a(C1) == C2.
  • Multiplier equivalence implies the codes are permutation equivalent and share the same weight enumerator and minimum distance.
source
CodingTheory.is_narrowsense — Method
is_narrowsense(C::AbstractBCHCode) -> Any

Return true if the BCH code is narrow-sense (offset b is 1 or 0 depending on convention).

source
CodingTheory.is_subcode — Method
is_subcode(
    C1::AbstractCyclicCode,
    C2::AbstractCyclicCode
) -> Any

Return true if C1 is a subcode of C2, and false otherwise. For cyclic codes this holds exactly when the defining set of C1 contains the defining set of C2.

source
CodingTheory.multiplier_group — Method
multiplier_group(C::AbstractCyclicCode) -> Vector{Int64}

Return the set of all multipliers a that map the cyclic code C strictly to itself.

Notes

  • This set forms a subgroup of the multiplicative group (Z/nZ)*.
  • These multipliers correspond to the automorphisms of the cyclic code.
source
CodingTheory.multiplier_subgroup_Sn — Method
multiplier_subgroup_Sn(
    C::AbstractCyclicCode
) -> Tuple{Oscar.PermGroup, Oscar.GAPGroupEmbedding{Oscar.PermGroup, Oscar.PermGroup}}

Return the multiplier group of C as a formal subgroup of the symmetric group S_n.

Notes

  • Returns (H, f), where H is the subgroup and f is the inclusion morphism H -> S_n.
  • The multiplier action i -> a * i (mod n) is internally shifted to 1-based indexing to match Oscar's permutation group standards.
source
CodingTheory.multiplier_subgroup_Zn — Method
multiplier_subgroup_Zn(C::AbstractCyclicCode) -> Any

Return the multiplier group of C as a formal subgroup of the unit group Z_n^x.

Notes

  • Returns (H, inc), where H is the abstract abelian subgroup and inc is the injection.
  • To map an element h ∈ H back to an integer, use the unit group isomorphism: R, _ = residue_ring(ZZ, C.n); U, f = unit_group(R); int_val = lift(f(inc(h)))
source
CodingTheory.parity_check_matrix — Function
parity_check_matrix(C::AbstractCyclicCode) -> Any
parity_check_matrix(
    C::AbstractCyclicCode,
    stand_form::Bool
) -> Any

Return the parity-check matrix of the cyclic code. Evaluates lazily by extracting the reversed coefficients of the parity polynomial C.h.

source
CodingTheory.print_all_cyclic_codes — Function
print_all_cyclic_codes(io::IO, n::Int64, q::Int64)
print_all_cyclic_codes(
    io::IO,
    n::Int64,
    q::Int64,
    def_set::Bool
)

Print all cyclic codes of length n over GF(q).

Set def_set to true to include each defining set, BCH offset, and BCH bound. The table includes the zero and full ambient codes.

source
CodingTheory.print_all_cyclotomic_cosets — Method
print_all_cyclotomic_cosets(io::IO, n::Int64, q::Int64)

Print one cyclic code for each q-cyclotomic coset modulo n.

Each row gives the code obtained by omitting that coset from the defining set, together with its dimension, BCH offset and bound, generator polynomial, idempotent, and defining cosets.

source
CodingTheory.qcosets_reps — Method
qcosets_reps(C::AbstractCyclicCode) -> Any

Return the set of representatives for the q-cyclotomic cosets of the cyclic code.

source
CodingTheory.trace_representation — Method
trace_representation(C::AbstractCyclicCode) -> Vector{Int64}

Return the Trace representation parameters of the cyclic code C.

Notes

  • Returns a vector of the primitive root powers that define the independent trace components of the codewords.
  • A codeword c can be generated by c_i = sum_j Tr_{E/F}( A_j * β^(i * j) ) where A_j are arbitrary elements in the splitting field.
source
Hecke.dual — Method
dual(
    C::AbstractCyclicCode
) -> Union{BCHCode, CyclicCode, ReedSolomonCode}

Return the dual of the cyclic code C. This operation evaluates in O(1) time using the dual defining set properties.

source
Hecke.is_cyclic — Method
is_cyclic(
    C::AbstractLinearCode
) -> Union{Tuple{Bool, Missing}, Tuple{Bool, AbstractLinearCode}}

Return true and the equivalent cyclic code object if C is a cyclic code; otherwise, return false, missing.

source
Hecke.is_degenerate — Method
is_degenerate(C::AbstractCyclicCode) -> Bool

Return true if the cyclic code is degenerate. A cyclic code is degenerate if the parity-check polynomial divides x^r - 1 for some r < n.

source
Oscar.complement — Method
complement(
    C::AbstractCyclicCode
) -> Union{BCHCode, CyclicCode, ReedSolomonCode}

Return the cyclic code whose cyclotomic cosets are the complement of C's.

source
Oscar.generator_matrix — Function
generator_matrix(C::AbstractCyclicCode) -> Any
generator_matrix(
    C::AbstractCyclicCode,
    stand_form::Bool
) -> Any

Return the generator matrix of the cyclic code. Evaluates lazily by extracting the coefficients of the generator polynomial C.g and mapping them into a strictly typed dense matrix (fpMatrix or FqMatrix).

source
CodingTheory.all_cyclotomic_cosets — Method
all_cyclotomic_cosets(
    q::Int64,
    n::Int64;
    to_sort,
    verbose
) -> Vector{Vector{Int64}}

Return all q-cyclotomic cosets modulo n.

Notes

  • If the optional parameter to_sort is set to false, the result will not be

sorted. If the optional parameter verbose is set to true, the result will pretty print.

source
CodingTheory.are_conjugates — Method
are_conjugates(
    x::AbstractAlgebra.FinFieldElem,
    y::AbstractAlgebra.FinFieldElem,
    q::Int64
) -> Bool

Return true if x and y are conjugates over the subfield of order q.

source
CodingTheory.complement_qcosets — Method
complement_qcosets(
    q::Int64,
    n::Int64,
    qcosets::Vector{Vector{Int64}}
) -> Vector{Vector{Int64}}

Return the complement of the q-cyclotomic cosets modulo n of qcosets.

source
CodingTheory.cyclotomic_coset — Method
cyclotomic_coset(
    x::Int64,
    q::Int64,
    n::Int64;
    to_sort,
    verbose
) -> Vector{Int64}

Return the q-cyclotomic coset of x modulo n.

Notes

  • If the optional parameter to_sort is set to false, the result will not be

sorted. If the optional parameter verbose is set to true, the result will pretty print.

source
CodingTheory.dual_qcosets — Method
dual_qcosets(
    q::Int64,
    n::Int64,
    qcosets::Vector{Vector{Int64}}
) -> Vector{Vector{Int64}}

Return the dual of the q-cyclotomic cosets modulo n of qcosets.

source
CodingTheory.minimal_polynomial — Method
minimal_polynomial(
    coset::Vector{Int64},
    α::AbstractAlgebra.FinFieldElem
) -> Any

Return the minimal polynomial of α defined by the q-cyclotomic coset coset.

Notes

  • The minimal polynomial is computed over the parent field of α, but mathematically its coefficients are guaranteed to lie in the base field GF(q).
source
CodingTheory.qcoset_pairings — Method
qcoset_pairings(
    arr::Vector{Vector{Int64}},
    n::Int64
) -> Tuple{Vector{Tuple{Vector{Int64}, Vector{Int64}}}, Vector{Tuple{Int64, Int64}}}

Return the q-cyclotomic cosets modulo n collected into complementary pairs.

source

The following are not exported but may be useful.

Hecke.is_degenerate — Function
is_degenerate(C::AbstractCyclicCode) -> Bool

Return true if the cyclic code is degenerate. A cyclic code is degenerate if the parity-check polynomial divides x^r - 1 for some r < n.

source
Hecke.is_cyclic — Function
is_cyclic(
    C::AbstractLinearCode
) -> Union{Tuple{Bool, Missing}, Tuple{Bool, AbstractLinearCode}}

Return true and the equivalent cyclic code object if C is a cyclic code; otherwise, return false, missing.

source