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.
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.
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.
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.
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.
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.
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).
AbstractAlgebra.polynomial_ring — Method
polynomial_ring(C::AbstractCyclicCode) -> Any
Return the polynomial ring of the generator polynomial.
Base.zeros — Method
zeros(C::AbstractCyclicCode) -> Any
Return the zeros (as field elements) of C.
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.
CodingTheory.BCH_bound — Method
BCH_bound(C::AbstractCyclicCode) -> Any
Return the BCH bound for C. Computes lazily and caches the result.
CodingTheory.BCH_offset — Method
BCH_offset(C::AbstractCyclicCode) -> Any
Return the offset of the BCH bound for C. Computes lazily.
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.
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.
CodingTheory.HT_bound — Method
HT_bound(C::AbstractCyclicCode) -> Any
Return the Hartmann-Tzeng bound for C. Computes lazily and caches the result.
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.
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).
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
μ_athat splits the non-zero roots intomcycling sets. - Returns a NamedTuple containing the array of
mcodes and the multiplieraused. - If
include_zero = true, the root0is added to all defining sets (yielding the even-like subcodes).
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.
CodingTheory.Roos_bound — Method
Roos_bound(C::AbstractCyclicCode) -> Any
Return the Roos bound for C. Computes lazily and caches the result.
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.
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).
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).
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.
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.
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
itoa * i (mod n). - Requires
gcd(a, n) == 1to ensure the mapping is a valid permutation.
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.
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) ofC.
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.
CodingTheory.defining_set — Method
defining_set(C::AbstractCyclicCode) -> Any
Return the defining set (as integer exponents) of the cyclic code.
CodingTheory.design_distance — Method
design_distance(C::AbstractBCHCode) -> Any
Return the design distance of the BCH code.
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.
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.
CodingTheory.entrywise_product_code — Method
entrywise_product_code(
C::AbstractCyclicCode
) -> Union{BCHCode, CyclicCode, ReedSolomonCode}
Return the entrywise (Schur / Hadamard) product of C with itself.
CodingTheory.generator_polynomial — Method
generator_polynomial(C::AbstractCyclicCode) -> Any
Return the generator polynomial of the cyclic code.
CodingTheory.idempotent — Method
idempotent(C::AbstractCyclicCode) -> Any
Return the idempotent (polynomial) of the cyclic code.
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.
CodingTheory.is_antiprimitive — Method
is_antiprimitive(C::AbstractBCHCode) -> Any
Return true if the BCH code is antiprimitive.
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
acoprime tonsuch thatμ_a(C1) == C2. - Multiplier equivalence implies the codes are permutation equivalent and share the same weight enumerator and minimum distance.
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).
CodingTheory.is_reversible — Method
is_reversible(C::AbstractCyclicCode) -> Any
Return true if the cyclic code is reversible.
CodingTheory.is_self_dual — Method
is_self_dual(C::AbstractCyclicCode) -> Any
Return whether or not C == dual(C).
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.
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.
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), whereHis the subgroup andfis the inclusion morphismH -> S_n. - The multiplier action
i -> a * i (mod n)is internally shifted to 1-based indexing to match Oscar's permutation group standards.
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), whereHis the abstract abelian subgroup andincis the injection. - To map an element
h ∈ Hback 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)))
CodingTheory.nonzeros — Method
nonzeros(C::AbstractCyclicCode) -> Any
Return the nonzeros (as field elements) of C.
CodingTheory.offset — Method
offset(C::AbstractBCHCode) -> Any
Return the offset of the BCH code.
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.
CodingTheory.parity_check_polynomial — Method
parity_check_polynomial(C::AbstractCyclicCode) -> Any
Return the parity-check polynomial of the cyclic code.
CodingTheory.primitive_root — Method
primitive_root(C::AbstractCyclicCode) -> Any
Return the primitive root of the splitting field.
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.
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.
CodingTheory.qcosets — Method
qcosets(C::AbstractCyclicCode) -> Any
Return the q-cyclotomic cosets of the cyclic code.
CodingTheory.qcosets_reps — Method
qcosets_reps(C::AbstractCyclicCode) -> Any
Return the set of representatives for the q-cyclotomic cosets of the cyclic code.
CodingTheory.splitting_field — Method
splitting_field(C::AbstractCyclicCode) -> Any
Return the splitting field of the generator polynomial.
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
ccan be generated byc_i = sum_j Tr_{E/F}( A_j * β^(i * j) )whereA_jare arbitrary elements in the splitting field.
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.
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.
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.
Hecke.is_primitive — Method
is_primitive(C::AbstractBCHCode) -> Any
Return true if the BCH code is primitive.
Oscar.complement — Method
complement(
C::AbstractCyclicCode
) -> Union{BCHCode, CyclicCode, ReedSolomonCode}
Return the cyclic code whose cyclotomic cosets are the complement of C's.
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).
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_sortis set tofalse, the result will not be
sorted. If the optional parameter verbose is set to true, the result will pretty print.
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.
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.
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_sortis set tofalse, the result will not be
sorted. If the optional parameter verbose is set to true, the result will pretty print.
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.
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 fieldGF(q).
CodingTheory.ord — Method
ord(n::Int64, q::Int64) -> Int64
Return the multiplicative order of q mod n.
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.
CodingTheory.qcoset_table — Method
qcoset_table(a::Int64, b::Int64, q::Int64)
Print all q-cyclotomic cosets modulo n for n between a and b.
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.
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.