How this calculation works
Decode a small linear code by exact exhaustive nearest-codeword search, reporting the syndrome, all nearest candidates and minimum-weight errors.
s = H rᵀ; nearest codewords minimize wt(r−c), and their errors satisfy H(r−c)ᵀ=s.A worked example
For the binary repetition code generated by [1,1,1], the codewords are 000 and 111. Received word 100 is distance one from 000 and distance two from 111, so its unique nearest codeword is 000 with error 100.
Good to know
Prime fields p≤7, length at most twelve, and no more than fifty thousand distinct codewords after row-rank normalization. Exact modular parity checks and exhaustive Hamming distances. All nearest ties are returned within an explicit output cap; cap exhaustion is unresolved. No soft-decision channel likelihoods or guaranteed correction beyond a proven code radius.
Reference: Primary method or official documentation (opens in a new tab) ↗
Decoding asks about a received word
A linear code is a finite-field subspace generated by the rows of a matrix. Decoding adds a received word and asks which codeword is closest under a specified distance. This page uses Hamming distance, the number of coordinates that differ, and returns every nearest codeword rather than choosing an arbitrary winner in a tie.
The task differs from calculating only a code’s weight enumerator or minimum distance. Those properties summarize the code, while the received word determines a particular decoding problem. A decoder can be ambiguous even when the code parameters are known exactly, so the interface must preserve ties instead of labeling the first enumerated codeword as certainly transmitted.
Compare this with the Linear error correcting code distance and weight enumerator calculator. Decode a received word through its syndrome and minimum-weight error coset, rather than only compute code distance and a weight enumerator.
Enter prime-field coordinates
Choose a prime p, enter the generator matrix and a received vector of matching length. Entries are interpreted modulo p. Dependent generator rows are removed by exact row reduction so that enumeration produces distinct codewords without multiplying the workload by redundant messages. The resulting rank determines the code size p^k.
A composite modulus is not accepted as a prime field, and extension fields require their own element representation. Row operations change the generator basis without changing the code. Therefore the nearest codewords and Hamming distances should remain unchanged after replacing the generator by another full-rank basis for the same row space.
The syndrome identifies an error coset
A parity-check matrix H has nullspace equal to the generated code and satisfies GHᵀ=0 under the row-generator convention. The syndrome of received word r is Hrᵀ. Subtracting any codeword leaves that syndrome unchanged, so candidate error vectors all lie in the same syndrome coset.
The syndrome detects whether r itself lies in the code: syndrome zero means it does. A nonzero syndrome does not reveal a unique error without a decoding rule. Finding a minimum-weight vector with that syndrome gives a nearest-codeword correction, and several vectors can share the same minimum weight.
Exhaustive search supplies all nearest choices
For the supported small code size, enumerate every coefficient vector over the prime field, form its codeword and compute the Hamming distance to r. Keep the smallest distance and every codeword attaining it. The corresponding errors are r−c modulo p, with weights equal to that minimum.
The finite complete enumeration proves nearest-neighbor optimality within the declared code. It does not establish which candidate was actually transmitted. If output or work caps prevent retaining all ties, report unresolved or an explicitly incomplete list rather than claiming the displayed subset contains every nearest codeword.
Trace the repetition-code example
The default binary generator [1,1,1] has rank one and generates only 000 and 111. For r=100, the distance to 000 is one because only the first coordinate differs. The distance to 111 is two because the second and third coordinates differ.
Thus 000 is the unique nearest codeword and the minimum-weight error is 100. A possible parity-check matrix has rows 110 and 101, giving syndrome (1,1). That same syndrome is produced by error 100, while subtracting the decoded codeword leaves the received vector unchanged in this example.
Unique nearest is not certainty
If a code has minimum distance d, every word within floor((d−1)/2) errors of a codeword is guaranteed to decode uniquely to it under Hamming nearest-neighbor decoding. Outside that radius, a nearest choice can still be unique but can be the wrong transmitted word after too many errors.
A tie signals ambiguity under the selected metric, not an implementation failure. Channel-specific likelihoods, unequal symbol reliability or soft information can change the appropriate decision rule. This page does not infer those quantities from the received vector, so it must not attach a probability of correctness to a nearest-codeword result.
Verify parity and distance certificates
Check GHᵀ=0, the reported code size, and each candidate’s membership in the row span. For every nearest candidate, recompute r−c and count its nonzero coordinates. Finally confirm that its error syndrome equals the received syndrome. These tests verify the displayed witnesses independently of their formatting.
Completeness of the nearest list depends on the full supported enumeration, while the algebraic checks verify each individual candidate. Preserve the normalized field and coordinate order when comparing another package. A syndrome vector may change after a different parity-check basis is chosen, even though the underlying error coset and nearest codewords remain identical.
A few questions, answered
Does a unique nearest result prove what was sent?
No. It is the unique minimizer of Hamming distance, not certainty about transmission history.
Why can another package show a different syndrome?
Different parity-check bases can give different syndrome coordinates while describing the same code and cosets.
Are all tied nearest codewords kept?
Yes within the declared output cap; an interrupted or truncated search must be labeled incomplete or unresolved.
Can dependent generator rows change the result?
No. Removing them preserves the code; it only avoids duplicate codeword generation.