Linear Codes
Generic linear codes may be constructed from a matrix or a vector-space object. If the optional parameter parity is true, a matrix input is interpreted as a parity-check matrix. Zero rows are removed automatically, while zero columns are retained. See the Linear Codes tutorial for usage examples.
Accessors are provided for every stored attribute, and users are strongly encouraged to use them rather than reaching into the structs directly: many functions rely on the stored data being in a specific order, and the accessors compute and cache derived quantities on first use.
If a code was created from a generator or parity-check matrix, that matrix is stored alongside the standard form. It is potentially overcomplete, meaning it has more rows than its rank. Passing stand_form = true returns the standard form instead. Some families are not built from an explicit matrix; there the matrices start out missing and are computed on demand.
Putting a matrix into standard form may require column permutations. When it does, standard_form_permutation returns the permutation matrix $P$ with $\mathrm{rowspace}(G) = \mathrm{rowspace}(G_\mathrm{stand} P)$, and missing otherwise.
The minimum distance of some families is known and is set during construction, and it is computed automatically for codes deemed small enough. Otherwise it is missing and must be requested explicitly; see Minimum distance. Functions that depend on knowing the distance return missing when it is unknown. The distance and its bounds may also be set by hand, in which case nothing is done to check the value for correctness.
CodingTheory.AbstractAdditiveCode — Type
abstract type AbstractAdditiveCode <: AbstractCodeSupertype for code families whose codewords form an additive group.
CodingTheory.AbstractAlgebraicGeometryCode — Type
abstract type AbstractAlgebraicGeometryCode <: AbstractLinearCodeSupertype for linear codes constructed from algebraic curves.
CodingTheory.AbstractAlternateCode — Type
abstract type AbstractAlternateCode <: AbstractLinearCodeSupertype for alternate-code families.
CodingTheory.AbstractBCHCode — Type
abstract type AbstractBCHCode <: AbstractCyclicCodeSupertype for BCH codes within the cyclic-code hierarchy.
CodingTheory.AbstractCode — Type
abstract type AbstractCodeRoot type for all classical and quantum code representations.
CodingTheory.AbstractConcatenatedCode — Type
abstract type AbstractConcatenatedCode <: AbstractLinearCodeSupertype for linear codes formed by concatenating constituent codes.
CodingTheory.AbstractCyclicCode — Type
abstract type AbstractCyclicCode <: AbstractLinearCodeSupertype for one-dimensional cyclic linear code families.
CodingTheory.AbstractCyclicCode2D — Type
abstract type AbstractCyclicCode2D <: AbstractCyclicCodeSupertype for two-dimensional cyclic code families.
CodingTheory.AbstractGeneralizedReedSolomonCode — Type
abstract type AbstractGeneralizedReedSolomonCode <: AbstractLinearCodeSupertype for generalized Reed–Solomon code families.
CodingTheory.AbstractGeneralizedSrivastavaCode — Type
abstract type AbstractGeneralizedSrivastavaCode <: AbstractAlternateCodeSupertype for generalized Srivastava codes within the alternate-code hierarchy.
CodingTheory.AbstractGoppaCode — Type
abstract type AbstractGoppaCode <: AbstractAlternateCodeSupertype for Goppa codes within the alternate-code hierarchy.
CodingTheory.AbstractLinearCode — Type
abstract type AbstractLinearCode <: AbstractAdditiveCodeSupertype for linear classical codes over a finite field.
CodingTheory.AbstractMatrixProductCode — Type
abstract type AbstractMatrixProductCode <: AbstractLinearCodeSupertype for linear codes constructed from constituent codes and a coefficient matrix.
CodingTheory.AbstractNonadditiveCode — Type
abstract type AbstractNonadditiveCode <: AbstractCodeSupertype for code families that are not additive.
CodingTheory.AbstractNonlinearCode — Type
abstract type AbstractNonlinearCode <: AbstractCodeSupertype for nonlinear classical code families.
CodingTheory.AbstractQuasiCyclicCode — Type
abstract type AbstractQuasiCyclicCode <: AbstractLinearCodeSupertype for quasi-cyclic linear code families.
CodingTheory.AbstractReedMullerCode — Type
abstract type AbstractReedMullerCode <: AbstractLinearCodeSupertype for Reed–Muller code families.
CodingTheory.AbstractReedSolomonCode — Type
abstract type AbstractReedSolomonCode <: AbstractBCHCodeSupertype for Reed–Solomon codes represented as BCH codes.
CodingTheory.AbstractTannerCode — Type
abstract type AbstractTannerCode <: AbstractLinearCodeSupertype for linear codes defined from Tanner-graph constraints.
CodingTheory.AbstractTwistedReedSolomonCode — Type
abstract type AbstractTwistedReedSolomonCode <: AbstractLinearCodeSupertype for twisted Reed–Solomon code families.
CodingTheory.LinearCode — Type
LinearCode(
Gs::Vector{Vector{Int64}},
q::Int64
) -> LinearCode
LinearCode(
Gs::Vector{Vector{Int64}},
q::Int64,
parity::Bool
) -> LinearCode
Return the linear code generated by integer row vectors over the finite field of order q.
CodingTheory.LinearCode — Type
LinearCode(G::Matrix{Int64}, q::Int64) -> LinearCode
LinearCode(
G::Matrix{Int64},
q::Int64,
parity::Bool
) -> LinearCode
Return the linear code generated by an integer matrix over the finite field of order q.
CodingTheory.LinearCode — Type
LinearCode(
G::Union{Nemo.FqMatrix, Nemo.fpMatrix, Hecke.SMat, SparseArrays.SparseMatrixCSC}
) -> LinearCode
LinearCode(
G::Union{Nemo.FqMatrix, Nemo.fpMatrix, Hecke.SMat, SparseArrays.SparseMatrixCSC},
parity::Bool
) -> LinearCode
Return the linear code constructed with matrix G. If parity is true, G is treated as the parity-check matrix. Safely handles sparse matrices and uses lazy evaluation to avoid eager rank and dual computations.
CodingTheory.LinearCode — Method
LinearCode(
G::Union{Nemo.FqMatrix, Nemo.fpMatrix, Hecke.SMat, SparseArrays.SparseMatrixCSC},
H::Union{Nemo.FqMatrix, Nemo.fpMatrix, Hecke.SMat, SparseArrays.SparseMatrixCSC};
check_orthogonality
) -> LinearCode
Return the linear code defined by generator matrix G and parity-check matrix H, including when the matrices mix sparse and dense representations.
CodingTheory.LinearCode — Method
LinearCode(
Gs::Vector{<:Union{Nemo.FqMatrix, Nemo.fpMatrix, Hecke.SMat, SparseArrays.SparseMatrixCSC}}
) -> LinearCode
Return the linear code generated by the vertical concatenation of Gs.
AbstractAlgebra.vector_space — Method
vector_space(C::AbstractLinearCode) -> Any
Return the code C as a vector space object.
Base.length — Method
length(C::AbstractLinearCode) -> Any
Return the length of C.
CodingTheory.:⊂ — Method
⊂(C1::AbstractLinearCode, C2::AbstractLinearCode) -> Any
Return whether C1 is a subcode of C2, not necessarily properly. This is an alias for ⊆; use ⊊ to test proper containment.
CodingTheory.Euclidean_dual — Method
Euclidean_dual(C::AbstractLinearCode) -> Any
Return the Euclidean dual of C. This is an alias for dual.
CodingTheory.Euclidean_hull — Method
Euclidean_hull(
C::AbstractLinearCode
) -> Union{Tuple{Missing, Int64}, Tuple{LinearCode, Any}}
Return the Euclidean hull $C \cap C^\perp$ and its dimension. This is an alias for hull; the code component is missing when the hull has dimension zero.
CodingTheory.Hermitian_dual — Method
Hermitian_dual(
C::AbstractLinearCode
) -> Union{LinearCode, MatrixProductCode}
Return the Hermitian dual of a code defined over a quadratic extension.
CodingTheory.Hermitian_hull — Method
Hermitian_hull(
C::AbstractLinearCode
) -> Union{Tuple{Missing, Int64}, Tuple{LinearCode, Any}}
Return the Hermitian hull of C and its dimension. The Hermitian hull of a code is the intersection of it and its Hermitian dual.
CodingTheory.Singleton_bound — Method
Singleton_bound(C::AbstractLinearCode) -> Int64
Return the Singleton bound on the minimum distance of the code ($d \leq n - k + 1$).
CodingTheory.Singleton_bound — Method
Singleton_bound(n::Int64, a::Int64) -> Int64
Return the Singleton bound $d \leq n - k + 1$ or $k \leq n - d + 1$ depending on the interpretation of a.
CodingTheory.are_equivalent — Method
are_equivalent(
C1::AbstractLinearCode,
C2::AbstractLinearCode
) -> Any
Return true if C1 ⊆ C2 and C2 ⊆ C1.
CodingTheory.cardinality — Method
cardinality(C::AbstractLinearCode) -> Any
Return the cardinality of C.
CodingTheory.change_field! — Method
change_field!(
C::AbstractLinearCode,
F::AbstractAlgebra.FinField
)
In-place change of the base ring of C to F. Safely updates all cached matrices.
CodingTheory.change_field — Method
change_field(
C::AbstractLinearCode,
F::AbstractAlgebra.FinField
) -> AbstractLinearCode
Return a new linear code which is C changed to the base ring F.
CodingTheory.characteristic_polynomial — Method
characteristic_polynomial(C::AbstractLinearCode) -> Any
Return the characteristic polynomial of C.
Notes
- The product runs over the nonzero weights of the dual code, so this requires the weight distribution of $C^\perp$.
CodingTheory.codewords — Function
codewords(C::AbstractLinearCode) -> Union{Nothing, Vector}
codewords(
C::AbstractLinearCode,
only_print::Bool
) -> Union{Nothing, Vector}
Return all codewords of C, or print them and return nothing when only_print is true. This is an alias for words; enumerating all $q^k$ codewords can require substantial time and memory.
CodingTheory.contains_self_dual_subcode — Method
contains_self_dual_subcode(C::AbstractLinearCode) -> Any
Return true if C contains a self-dual subcode.
CodingTheory.elements — Function
elements(C::AbstractLinearCode) -> Union{Nothing, Vector}
elements(
C::AbstractLinearCode,
only_print::Bool
) -> Union{Nothing, Vector}
Return all elements of C, or print them and return nothing when only_print is true. This is an alias for codewords and words; enumerating all $q^k$ elements can require substantial time and memory.
CodingTheory.hull — Method
hull(
C::AbstractLinearCode
) -> Union{Tuple{Missing, Int64}, Tuple{LinearCode, Any}}
Return the (Euclidean) hull of C and its dimension.
CodingTheory.information_set — Method
information_set(C::AbstractLinearCode) -> Any
Return a set of column indices corresponding to an information set of C.
CodingTheory.is_Euclidean_dual_containing — Method
is_Euclidean_dual_containing(C::AbstractLinearCode) -> Any
Return true if Euclidean_dual(C) ⊆ C.
CodingTheory.is_Euclidean_self_orthogonal — Method
is_Euclidean_self_orthogonal(C::AbstractLinearCode) -> Any
Return true if C ⊆ Euclidean_dual(C).
CodingTheory.is_Hermitian_LCD — Method
is_Hermitian_LCD(C::AbstractLinearCode) -> Any
Return true if C is linear complementary Hermitian dual. A code is linear complementary Hermitian dual if the dimension of Hermitian_hull(C) is zero.
CodingTheory.is_Hermitian_dual_containing — Method
is_Hermitian_dual_containing(
C::AbstractLinearCode
) -> Union{Missing, Bool}
Return true if Hermitian_dual(C) ⊆ C.
CodingTheory.is_Hermitian_self_dual — Method
is_Hermitian_self_dual(
C::AbstractLinearCode
) -> Union{Missing, Bool}
Return true if are_equivalent(C, Hermitian_dual(C)).
CodingTheory.is_Hermitian_self_orthogonal — Method
is_Hermitian_self_orthogonal(
C::AbstractLinearCode
) -> Union{Missing, Bool}
Return true if C ⊆ Hermitian_dual(C).
CodingTheory.is_Hermitian_weakly_self_dual — Method
is_Hermitian_weakly_self_dual(
C::AbstractLinearCode
) -> Union{Missing, Bool}
Return true if C ⊆ Hermitian_dual(C).
CodingTheory.is_LCD — Method
is_LCD(C::AbstractLinearCode) -> Any
Return true if C is linear complementary dual.
CodingTheory.is_MDS — Method
is_MDS(C::AbstractLinearCode) -> Any
Return true if code is maximum distance separable (MDS). Calculates the exact minimum distance if currently missing.
CodingTheory.is_doubly_even — Method
is_doubly_even(C::AbstractLinearCode) -> Bool
Return true if C is doubly-even.
CodingTheory.is_dual_containing — Method
is_dual_containing(C::AbstractLinearCode) -> Any
Return true if dual(C) ⊆ C.
CodingTheory.is_even — Method
is_even(C::AbstractLinearCode) -> Union{Missing, Bool}
Return true if C is even.
CodingTheory.is_l_Galois_LCD — Method
is_l_Galois_LCD(C::AbstractLinearCode, l::Int64) -> Any
Return true if C is linear complementary l-Galois dual (i.e., the dimension of l_Galois_hull(C, l) is zero).
CodingTheory.is_l_Galois_dual_containing — Method
is_l_Galois_dual_containing(
C::AbstractLinearCode,
l::Int64
) -> Union{Missing, Bool}
Return true if l_Galois_dual(C, l) ⊆ C.
CodingTheory.is_l_Galois_self_dual — Method
is_l_Galois_self_dual(
C::AbstractLinearCode,
l::Int64
) -> Union{Missing, Bool}
Return true if are_equivalent(C, l_Galois_dual(C, l)).
CodingTheory.is_l_Galois_self_orthogonal — Method
is_l_Galois_self_orthogonal(
C::AbstractLinearCode,
l::Int64
) -> Union{Missing, Bool}
Return true if C ⊆ l_Galois_dual(C, l).
CodingTheory.is_l_Galois_weakly_self_dual — Method
is_l_Galois_weakly_self_dual(
C::AbstractLinearCode,
l::Int64
) -> Union{Missing, Bool}
Return true if C ⊆ l_Galois_dual(C, l).
CodingTheory.is_overcomplete — Function
is_overcomplete(C::AbstractLinearCode) -> Any
is_overcomplete(C::AbstractLinearCode, which::Symbol) -> Any
Return true if the generator matrix is overcomplete. If the optional parameter is set to :H, returns true if the parity-check matrix is overcomplete.
CodingTheory.is_self_dual — Method
is_self_dual(C::AbstractLinearCode) -> Any
Return true if are_equivalent(C, dual(C)).
CodingTheory.is_self_orthogonal — Method
is_self_orthogonal(C::AbstractLinearCode) -> Any
Return true if C ⊆ dual(C).
CodingTheory.is_subcode — Method
is_subcode(
C1::AbstractLinearCode,
C2::AbstractLinearCode
) -> Any
Return whether C1 is a subcode of C2, not necessarily properly.
CodingTheory.is_triply_even — Method
is_triply_even(C::AbstractLinearCode) -> Bool
Return true if C is triply-even.
CodingTheory.is_weakly_self_dual — Method
is_weakly_self_dual(C::AbstractLinearCode) -> Any
Return true if C ⊆ dual(C).
CodingTheory.l_Galois_dual — Method
l_Galois_dual(
C::AbstractLinearCode,
l::Int64
) -> Union{LinearCode, MatrixProductCode}
Return the l-Galois dual of a code defined over a finite field.
CodingTheory.l_Galois_hull — Method
l_Galois_hull(
C::AbstractLinearCode,
l::Int64
) -> Union{Tuple{Missing, Int64}, Tuple{LinearCode, Any}}
Return the l-Galois hull of C and its dimension.
CodingTheory.minimum_distance_lower_bound — Method
minimum_distance_lower_bound(C::AbstractLinearCode) -> Any
Return the current lower bound on the minimum distance of C.
CodingTheory.minimum_distance_upper_bound — Method
minimum_distance_upper_bound(C::AbstractLinearCode) -> Any
Return the current upper bound on the minimum distance of C.
CodingTheory.number_correctable_errors — Method
number_correctable_errors(C::AbstractLinearCode) -> Any
Return the number of correctable errors for the code.
Notes
- The number of correctable errors is $t = \floor{(d - 1) / 2}$.
CodingTheory.parity_check_matrix — Function
parity_check_matrix(C::AbstractLinearCode) -> Any
parity_check_matrix(
C::AbstractLinearCode,
stand_form::Bool
) -> Any
Return the parity-check matrix of C. Evaluates lazily and caches the result. If the optional parameter stand_form is set to true, the standard form is returned.
CodingTheory.random_information_set — Method
random_information_set(C::AbstractLinearCode; rng) -> Any
Return a set of column indices corresponding to a random information set of C.
CodingTheory.random_linear_code — Method
random_linear_code(
F::AbstractAlgebra.FinField,
n::Int64,
k::Int64;
rng
) -> LinearCode
Return a random [n, k] linear code over F. Bypasses standard constructor checks for massive speedups on large codes.
CodingTheory.random_linear_code — Method
random_linear_code(
q::Int64,
n::Int64,
k::Int64;
rng
) -> LinearCode
Return a random [n, k] linear code over GF(q).
CodingTheory.rate — Method
rate(C::AbstractLinearCode) -> Union{Missing, Float64}
Return the rate of C.
CodingTheory.relative_distance — Method
relative_distance(C::AbstractLinearCode) -> Any
Return the relative minimum distance of C if $d$ is known; otherwise return missing.
CodingTheory.set_distance_lower_bound! — Method
set_distance_lower_bound!(
C::AbstractLinearCode,
l::Int64
) -> Any
Set the lower bound on the minimum distance of C, if l is better than the current bound.
CodingTheory.set_distance_upper_bound! — Method
set_distance_upper_bound!(
C::AbstractLinearCode,
u::Int64
) -> Any
Set the upper bound on the minimum distance of C, if u is better than the current bound.
CodingTheory.set_minimum_distance! — Method
set_minimum_distance!(
C::AbstractLinearCode,
d::Int64
) -> Int64
Set the exact minimum distance of the code to d and update the bounds.
CodingTheory.standard_form_permutation — Method
standard_form_permutation(C::AbstractLinearCode) -> Any
Return the permutation matrix required to permute the columns of the code matrices to have the same row space as the matrices in standard form. Evaluates lazily if not already computed.
CodingTheory.syndrome — Method
syndrome(
C::AbstractLinearCode,
v::Union{Vector{Int64}, Vector{Nemo.FpFieldElem}, Vector{Nemo.fpFieldElem}, Nemo.FqMatrix, Nemo.fpMatrix, Hecke.SMat, SparseArrays.SparseMatrixCSC}
) -> Any
Return the syndrome of v with respect to C.
CodingTheory.words — Function
words(C::AbstractLinearCode) -> Union{Nothing, Vector}
words(
C::AbstractLinearCode,
only_print::Bool
) -> Union{Nothing, Vector}
Return the elements of C. If only_print is true, the elements are only printed to the console and not returned.
Hecke.dimension — Method
dimension(C::AbstractLinearCode) -> Union{Missing, Int64}
Return the dimension of C.
Hecke.dual — Method
dual(C::AbstractLinearCode) -> GabidulinCode
Return the (Euclidean) dual of the code C. Evaluates lazily by swapping the cached generator and parity-check matrices.
Hecke.genus — Method
genus(C::AbstractLinearCode) -> Any
Return the genus, $n + 1 - k - d$, of the code.
Oscar.encode — Method
encode(
C::AbstractLinearCode,
v::Union{Nemo.FqMatrix, Nemo.fpMatrix, Hecke.SMat, SparseArrays.SparseMatrixCSC, Vector{Int64}}
) -> Any
Return the encoding of v into C.
Oscar.field — Method
field(C::AbstractLinearCode) -> Any
Return the base ring of the generator matrix of C.
Oscar.generator_matrix — Function
generator_matrix(C::AbstractLinearCode) -> Any
generator_matrix(
C::AbstractLinearCode,
stand_form::Bool
) -> Any
Return the generator matrix of C. Evaluates lazily and caches the result. If the optional parameter stand_form is set to true, the standard form is returned.
The following are not exported but may be useful.
Hecke.genus — Function
genus(C::AbstractLinearCode) -> Any
Return the genus, $n + 1 - k - d$, of the code.