Reed–Solomon codes | |
Hierarchy: | Linear block code Polynomial code Reed–Solomon code |
Block Length: | n |
Message Length: | k |
Distance: | n − k + 1 |
Alphabet Size: | q = pm ≥ n (p prime) Often n = q − 1. |
Notation: | [''n'', ''k'', ''n'' − ''k'' + 1]q-code |
Decoding: | Berlekamp–Massey Euclidean et al. |
Properties: | Maximum-distance separable code |
Reed–Solomon codes are a group of error-correcting codes that were introduced by Irving S. Reed and Gustave Solomon in 1960.They have many applications, including consumer technologies such as MiniDiscs, CDs, DVDs, Blu-ray discs, QR codes, Data Matrix, data transmission technologies such as DSL and WiMAX, broadcast systems such as satellite communications, DVB and ATSC, and storage systems such as RAID 6.
Reed–Solomon codes operate on a block of data treated as a set of finite-field elements called symbols. Reed–Solomon codes are able to detect and correct multiple symbol errors. By adding = − check symbols to the data, a Reed–Solomon code can detect (but not correct) any combination of up to erroneous symbols, or locate and correct up to erroneous symbols at unknown locations. As an erasure code, it can correct up to erasures at locations that are known and provided to the algorithm, or it can detect and correct combinations of errors and erasures. Reed–Solomon codes are also suitable as multiple-burst bit-error correcting codes, since a sequence of consecutive bit errors can affect at most two symbols of size . The choice of is up to the designer of the code and may be selected within wide limits.
There are two basic types of Reed–Solomon codes original view and BCH view with BCH view being the most common, as BCH view decoders are faster and require less working storage than original view decoders.
Reed–Solomon codes were developed in 1960 by Irving S. Reed and Gustave Solomon, who were then staff members of MIT Lincoln Laboratory. Their seminal article was titled "Polynomial Codes over Certain Finite Fields". . The original encoding scheme described in the Reed & Solomon article used a variable polynomial based on the message to be encoded where only a fixed set of values (evaluation points) to be encoded are known to encoder and decoder. The original theoretical decoder generated potential polynomials based on subsets of k (unencoded message length) out of n (encoded message length) values of a received message, choosing the most popular polynomial as the correct one, which was impractical for all but the simplest of cases. This was initially resolved by changing the original scheme to a BCH code like scheme based on a fixed polynomial known to both encoder and decoder, but later, practical decoders based on the original scheme were developed, although slower than the BCH schemes. The result of this is that there are two main types of Reed Solomon codes, ones that use the original encoding scheme, and ones that use the BCH encoding scheme.
Also in 1960, a practical fixed polynomial decoder for BCH codes developed by Daniel Gorenstein and Neal Zierler was described in an MIT Lincoln Laboratory report by Zierler in January 1960 and later in a paper in June 1961.[1] The Gorenstein–Zierler decoder and the related work on BCH codes are described in a book Error Correcting Codes by W. Wesley Peterson (1961).[2] By 1963 (or possibly earlier), J. J. Stone (and others) recognized that Reed Solomon codes could use the BCH scheme of using a fixed generator polynomial, making such codes a special class of BCH codes,[3] but Reed Solomon codes based on the original encoding scheme, are not a class of BCH codes, and depending on the set of evaluation points, they are not even cyclic codes.
In 1969, an improved BCH scheme decoder was developed by Elwyn Berlekamp and James Massey, and has since been known as the Berlekamp–Massey decoding algorithm.
In 1975, another improved BCH scheme decoder was developed by Yasuo Sugiyama, based on the extended Euclidean algorithm.[4]
In 1977, Reed–Solomon codes were implemented in the Voyager program in the form of concatenated error correction codes. The first commercial application in mass-produced consumer products appeared in 1982 with the compact disc, where two interleaved Reed–Solomon codes are used. Today, Reed–Solomon codes are widely implemented in digital storage devices and digital communication standards, though they are being slowly replaced by Bose–Chaudhuri–Hocquenghem (BCH) codes. For example, Reed–Solomon codes are used in the Digital Video Broadcasting (DVB) standard DVB-S, in conjunction with a convolutional inner code, but BCH codes are used with LDPC in its successor, DVB-S2.
In 1986, an original scheme decoder known as the Berlekamp–Welch algorithm was developed.
In 1996, variations of original scheme decoders called list decoders or soft decoders were developed by Madhu Sudan and others, and work continues on these types of decoders – see Guruswami–Sudan list decoding algorithm.
In 2002, another original scheme decoder was developed by Shuhong Gao, based on the extended Euclidean algorithm.
Reed–Solomon coding is very widely used in mass storage systems to correctthe burst errors associated with media defects.
Reed–Solomon coding is a key component of the compact disc. It was the first use of strong error correction coding in a mass-produced consumer product, and DAT and DVD use similar schemes. In the CD, two layers of Reed–Solomon coding separated by a 28-way convolutional interleaver yields a scheme called Cross-Interleaved Reed–Solomon Coding (CIRC). The first element of a CIRC decoder is a relatively weak inner (32,28) Reed–Solomon code, shortened from a (255,251) code with 8-bit symbols. This code can correct up to 2 byte errors per 32-byte block. More importantly, it flags as erasures any uncorrectable blocks, i.e., blocks with more than 2 byte errors. The decoded 28-byte blocks, with erasure indications, are then spread by the deinterleaver to different blocks of the (28,24) outer code. Thanks to the deinterleaving, an erased 28-byte block from the inner code becomes a single erased byte in each of 28 outer code blocks. The outer code easily corrects this, since it can handle up to 4 such erasures per block.
The result is a CIRC that can completely correct error bursts up to 4000 bits, or about 2.5 mm on the disc surface. This code is so strong that most CD playback errors are almost certainly caused by tracking errors that cause the laser to jump track, not by uncorrectable error bursts.
DVDs use a similar scheme, but with much larger blocks, a (208,192) inner code, and a (182,172) outer code.
Reed–Solomon error correction is also used in parchive files which are commonly posted accompanying multimedia files on USENET. The distributed online storage service Wuala (discontinued in 2015) also used Reed–Solomon when breaking up files.
Almost all two-dimensional bar codes such as PDF-417, MaxiCode, Datamatrix, QR Code, and Aztec Code use Reed–Solomon error correction to allow correct reading even if a portion of the bar code is damaged. When the bar code scanner cannot recognize a bar code symbol, it will treat it as an erasure.
Reed–Solomon coding is less common in one-dimensional bar codes, but is used by the PostBar symbology.
Specialized forms of Reed–Solomon codes, specifically Cauchy-RS and Vandermonde-RS, can be used to overcome the unreliable nature of data transmission over erasure channels. The encoding process assumes a code of RS(N, K) which results in N codewords of length N symbols each storing K symbols of data, being generated, that are then sent over an erasure channel.
Any combination of K codewords received at the other end is enough to reconstruct all of the N codewords. The code rate is generally set to 1/2 unless the channel's erasure likelihood can be adequately modelled and is seen to be less. In conclusion, N is usually 2K, meaning that at least half of all the codewords sent must be received in order to reconstruct all of the codewords sent.
Reed–Solomon codes are also used in xDSL systems and CCSDS's Space Communications Protocol Specifications as a form of forward error correction.
One significant application of Reed–Solomon coding was to encode the digital pictures sent back by the Voyager program.
Voyager introduced Reed–Solomon coding concatenated with convolutional codes, a practice that has since become very widespread in deep space and satellite (e.g., direct digital broadcasting) communications.
Viterbi decoders tend to produce errors in short bursts. Correcting these burst errors is a job best done by short or simplified Reed–Solomon codes.
Modern versions of concatenated Reed–Solomon/Viterbi-decoded convolutional coding were and are used on the Mars Pathfinder, Galileo, Mars Exploration Rover and Cassini missions, where they perform within about 1–1.5 dB of the ultimate limit, the Shannon capacity.
These concatenated codes are now being replaced by more powerful turbo codes:
Years | Code | Mission(s) | |
---|---|---|---|
1958–present | Uncoded | Explorer, Mariner, many others | |
1968–1978 | convolutional codes (CC) (25, 1/2) | Pioneer, Venus | |
1969–1975 | Reed-Muller code (32, 6) | Mariner, Viking | |
1977–present | Voyager | ||
1977–present | RS(255, 223) + CC(7, 1/2) | Voyager, Galileo, many others | |
1989–2003 | RS(255, 223) + CC(7, 1/3) | Voyager | |
1989–2003 | RS(255, 223) + CC(14, 1/4) | Galileo | |
1996–present | RS + CC (15, 1/6) | Cassini, Mars Pathfinder, others | |
2004–present | Turbo codes | Messenger, Stereo, MRO, others | |
est. 2009 | Constellation, MSL |
The Reed–Solomon code is actually a family of codes, where every code is characterised by three parameters: an alphabet size
q
n
k
k<n\leqq
F
q
q
R=
k | |
n |
n=q
n=q-1
There are different encoding procedures for the Reed–Solomon code, and thus, there are different ways to describe the set of all codewords.In the original view of, every codeword of the Reed–Solomon code is a sequence of function values of a polynomial of degree less than
k
p
F
q
a1,...,an
Formally, the set
C
k
k-1
n-(k-1)=n-k+1
k-1
d=n-k+1
\delta=d/n=1-k/n+1/n=1-R+1/n\sim1-R
R=k/n
\delta+R\leq1+1/n
While the number of different polynomials of degree less than k and the number of different messages are both equal to
qk
a1,...,ak
In the original construction of, the message
m=(m0,...,mk-1)\inFk
pm
m
pm
n
a0,...,an-1
F
C:Fk\toFn
C
C(m)=Am
n x k
A
F
This matrix is a Vandermonde matrix over
F
A
There is an alternative encoding procedure that produces a systematic Reed–Solomon code. Here, we use a different polynomial
pm
pm
k
pm
m
ak,...,an
This variant is systematic since the first
k
pm(a0),...,pm(ak-1)
m0,...,mk-1
pm
A discrete Fourier transform is essentially the same as the encoding procedure; it uses the generator polynomial
pm
The inverse Fourier transform could be used to convert an error free set of n < q message values back into the encoding polynomial of k coefficients, with the constraint that in order for this to work, the set of evaluation points used to encode the message must be a set of increasing powers of α:
However, Lagrange interpolation performs the same conversion without the constraint on the set of evaluation points or the requirement of an error free set of message values and is used for systematic encoding, and in one of the steps of the Gao decoder.
In this view, the message is interpreted as the coefficients of a polynomial
p(x)
s(x)
n-1
n\leq-1
s(x)
s(x)
p(x)
k-1
g(x)
n-k
g(x)
\alpha
For a "narrow sense code",
i=1
The encoding procedure for the BCH view of Reed–Solomon codes can be modified to yield a systematic encoding procedure, in which each codeword contains the message as a prefix, and simply appends error correcting symbols as a suffix. Here, instead of sending
s(x)=p(x)g(x)
s(x)
k
p(x)
s(x)
s(x)
g(x)
p(x)
s(x)
p(x)
Formally, the construction is done by multiplying
p(x)
xt
t=n-k
g(x)
t
sr(x)
The remainder has degree at most
t-1
xt-1,xt-2,...,x1,x0
p(x) ⋅ xt
s(x)
k
p(x)
As a result, the codewords
s(x)
C
g(x)
The Reed–Solomon code is a [''n'', ''k'', ''n'' − ''k'' + 1] code; in other words, it is a linear block code of length n (over F) with dimension k and minimum Hamming distance The Reed–Solomon code is optimal in the sense that the minimum distance has the maximum value possible for a linear code of size (n, k); this is known as the Singleton bound. Such a code is also called a maximum distance separable (MDS) code.
The error-correcting ability of a Reed–Solomon code is determined by its minimum distance, or equivalently, by
n-k
(n-k)/2
E
S
The theoretical error bound can be described via the following formula for the AWGN channel for FSK:[7] and for other modulation schemes:where ,
Ps=1-(1-s)h
h=
m | |
log2M |
s
M
For practical uses of Reed–Solomon codes, it is common to use a finite field
F
2m
m
n=2m-1
n=28-1=255
k
k<n
k=223
n=255
(n,k)=(255,223)
The Reed–Solomon code properties discussed above make them especially well-suited to applications where errors occur in bursts. This is because it does not matter to the code how many bits in a symbol are in error — if multiple bits in a symbol are corrupted it only counts as a single error. Conversely, if a data stream is not characterized by error bursts or drop-outs but by random single bit errors, a Reed–Solomon code is usually a poor choice compared to a binary code.
The Reed–Solomon code, like the convolutional code, is a transparent code. This means that if the channel symbols have been inverted somewhere along the line, the decoders will still operate. The result will be the inversion of the original data. However, the Reed–Solomon code loses its transparency when the code is shortened. The "missing" bits in a shortened code need to be filled by either zeros or ones, depending on whether the data is complemented or not. (To put it another way, if the symbols are inverted, then the zero-fill needs to be inverted to a one-fill.) For this reason it is mandatory that the sense of the data (i.e., true or complemented) be resolved before Reed–Solomon decoding.
Whether the Reed–Solomon code is cyclic or not depends on subtle details of the construction. In the original view of Reed and Solomon, where the codewords are the values of a polynomial, one can choose the sequence of evaluation points in such a way as to make the code cyclic. In particular, if
\alpha
F
F
\alphai
i\in\{1,...,q-1\}
q=|F|
p
F
(p(\alpha1),...,p(\alphaq-1))
a\mapstop(\alphaa)
(p(\alpha2),...,p(\alphaq))
\alphaq=\alpha1
p
Designers are not required to use the "natural" sizes of Reed–Solomon code blocks. A technique known as "shortening" can produce a smaller code of any desired size from a larger code. For example, the widely used (255,223) code can be converted to a (160,128) code by padding the unused portion of the source block with 95 binary zeroes and not transmitting them. At the decoder, the same portion of the block is loaded locally with binary zeroes. The Delsarte–Goethals–Seidel[8] theorem illustrates an example of an application of shortened Reed–Solomon codes. In parallel to shortening, a technique known as puncturing allows omitting some of the encoded parity symbols.
The decoders described in this section use the BCH view of a codeword as a sequence of coefficients. They use a fixed generator polynomial known to both encoder and decoder.
Daniel Gorenstein and Neal Zierler developed a decoder that was described in a MIT Lincoln Laboratory report by Zierler in January 1960 and later in a paper in June 1961.[9] The Gorenstein–Zierler decoder and the related work on BCH codes are described in a book Error Correcting Codes by W. Wesley Peterson (1961).[10]
The transmitted message,
(c0,\ldots,ci,\ldots,cn-1)
As a result of the Reed-Solomon encoding procedure, s(x) is divisible by the generator polynomial g(x):where α is a primitive element.
Since s(x) is a multiple of the generator g(x), it follows that it "inherits" all its roots.Therefore,
The transmitted polynomial is corrupted in transit by an error polynomial e(x) to produce the received polynomial r(x).
Coefficient ei will be zero if there is no error at that power of x and nonzero if there is an error. If there are ν errors at distinct powers ik of x, then
The goal of the decoder is to find the number of errors (ν), the positions of the errors (ik), and the error values at those positions (eik). From those, e(x) can be calculated and subtracted from r(x) to get the originally sent message s(x).
The decoder starts by evaluating the polynomial as received at points
\alpha1...\alphan-k
s(\alphaj)=0
s(x)
\alphaj
The advantage of looking at the syndromes is that the message polynomial drops out. In other words, the syndromes only relate to the error, and are unaffected by the actual contents of the message being transmitted. If the syndromes are all zero, the algorithm stops here and reports that the message was not corrupted in transit.
For convenience, define the error locators Xk and error values Yk as:
Then the syndromes can be written in terms of these error locators and error values as
This definition of the syndrome values is equivalent to the previous since
(\alphaj)
ik | |
=\alpha
j*ik | |
=
ik | |
(\alpha |
)j=
j | |
X | |
k |
The syndromes give a system of equations in 2ν unknowns, but that system of equations is nonlinear in the Xk and does not have an obvious solution. However, if the Xk were known (see below), then the syndrome equations provide a linear system of equations that can easily be solved for the Yk error values.
Consequently, the problem is finding the Xk, because then the leftmost matrix would be known, and both sides of the equation could be multiplied by its inverse, yielding Yk
In the variant of this algorithm where the locations of the errors are already known (when it is being used as an erasure code), this is the end. The error locations (Xk) are already known by some other method (for example, in an FM transmission, the sections where the bitstream was unclear or overcome with interference are probabilistically determinable from frequency analysis). In this scenario, up to
n-k
The rest of the algorithm serves to locate the errors, and will require syndrome values up to
2v
v
There is a linear recurrence relation that gives rise to a system of linear equations. Solving those equations identifies those error locations Xk.
Define the error locator polynomial as
The zeros of are the reciprocals
-1 | |
X | |
k |
-1 | |
x=X | |
k |
(1-
-1 | |
X | |
k |
⋅ Xk)=1-1=0
Let
j
1\leqj\leq\nu
Yk
j+\nu | |
X | |
k |
Sum for k = 1 to ν and it will still be zero.
Collect each term into its own sum.
Extract the constant values of
Λ
These summations are now equivalent to the syndrome values, which we know and can substitute in! This therefore reduces to
Subtracting
Sj+\nu
Recall that j was chosen to be any integer between 1 and v inclusive, and this equivalence is true for any and all such values. Therefore, we have v linear equations, not just one. This system of linear equations can therefore be solved for the coefficients Λi of the error location polynomial:The above assumes the decoder knows the number of errors ν, but that number has not been determined yet. The PGZ decoder does not determine ν directly but rather searches for it by trying successive values. The decoder first assumes the largest value for a trial ν and sets up the linear system for that value. If the equations can be solved (i.e., the matrix determinant is nonzero), then that trial value is the number of errors. If the linear system cannot be solved, then the trial ν is reduced by one and the next smaller system is examined.
Use the coefficients Λi found in the last step to build the error location polynomial. The roots of the error location polynomial can be found by exhaustive search. The error locators Xk are the reciprocals of those roots. The order of coefficients of the error location polynomial can be reversed, in which case the roots of that reversed polynomial are the error locators
Xk
-1 | |
X | |
k |
Once the error locators Xk are known, the error values can be determined. This can be done by direct solution for Yk in the error equations matrix given above, or using the Forney algorithm.
Calculate ik by taking the log base
\alpha
Finally, e(x) is generated from ik and eik and then is subtracted from r(x) to get the originally sent message s(x), with errors corrected.
Consider the Reed - Solomon code defined in with and (this is used in PDF417 barcodes) for a RS(7,3) code. The generator polynomial isIf the message polynomial is, then a systematic codeword is encoded as follows.Errors in transmission might cause this to be received instead.The syndromes are calculated by evaluating r at powers of α.
Using Gaussian elimination:
The coefficients can be reversed to produce roots with positive exponents, but typically this isn't used:with the log of the roots corresponding to the error locations (right to left, location 0 is the last term in the codeword).
To calculate the error values, apply the Forney algorithm.
Subtracting
e1x3+e2x4=74x3+122x4
The Berlekamp - Massey algorithm is an alternate iterative procedure for finding the error locator polynomial. During each iteration, it calculates a discrepancy based on a current instance of Λ(x) with an assumed number of errors e:and then adjusts Λ(x) and e so that a recalculated Δ would be zero. The article Berlekamp - Massey algorithm has a detailed description of the procedure. In the following example, C(x) is used to represent Λ(x).
Using the same data as the Peterson Gorenstein Zierler example above:
n | Sn+1 | d | C | B | b | m | |
---|---|---|---|---|---|---|---|
0 | 732 | 732 | 197 x + 1 | 1 | 732 | 1 | |
1 | 637 | 846 | 173 x + 1 | 1 | 732 | 2 | |
2 | 762 | 412 | 634 x2 + 173 x + 1 | 173 x + 1 | 412 | 1 | |
3 | 925 | 576 | 329 x2 + 821 x + 1 | 173 x + 1 | 412 | 2 |
Another iterative method for calculating both the error locator polynomial and the error value polynomial is based on Sugiyama's adaptation of the extended Euclidean algorithm .
Define S(x), Λ(x), and Ω(x) for t syndromes and e errors:
The key equation is:
For t = 6 and e = 3:
The middle terms are zero due to the relationship between Λ and syndromes.
The extended Euclidean algorithm can find a series of polynomials of the form
where the degree of R decreases as i increases. Once the degree of Ri(x) < t/2, then
B(x) and Q(x) don't need to be saved, so the algorithm becomes:
R−1 := xt R0 := S(x) A−1 := 0 A0 := 1 i := 0 while degree of Ri ≥ t/2 i := i + 1 Q := Ri-2 / Ri-1 Ri := Ri-2 - Q Ri-1 Ai := Ai-2 - Q Ai-1to set low order term of Λ(x) to 1, divide Λ(x) and Ω(x) by Ai(0):Ai(0) is the constant (low order) term of Ai.
Using the same data as the Peterson–Gorenstein–Zierler example above:
i | Ri | Ai | |
---|---|---|---|
−1 | 001 x4 + 000 x3 + 000 x2 + 000 x + 000 | 000 | |
0 | 925 x3 + 762 x2 + 637 x + 732 | 001 | |
1 | 683 x2 + 676 x + 024 | 697 x + 396 | |
2 | 673 x + 596 | 608 x2 + 704 x + 544 |
A discrete Fourier transform can be used for decoding.[11] To avoid conflict with syndrome names, let c(x) = s(x) the encoded codeword. r(x) and e(x) are the same as above. Define C(x), E(x), and R(x) as the discrete Fourier transforms of c(x), e(x), and r(x). Since r(x) = c(x) + e(x), and since a discrete Fourier transform is a linear operator, R(x) = C(x) + E(x).
Transform r(x) to R(x) using discrete Fourier transform. Since the calculation for a discrete Fourier transform is the same as the calculation for syndromes, t coefficients of R(x) and E(x) are the same as the syndromes:
Use
R1
Rt
Let v = number of errors. Generate E(x) using the known coefficients
E1
Et
Then calculate C(x) = R(x) − E(x) and take the inverse transform (polynomial interpolation) of C(x) to produce c(x).
The Singleton bound states that the minimum distance d of a linear block code of size (n,k) is upper-bounded by . The distance d was usually understood to limit the error-correction capability to . The Reed–Solomon code achieves this bound with equality, and can thus correct up to errors. However, this error-correction bound is not exact.
In 1999, Madhu Sudan and Venkatesan Guruswami at MIT published "Improved Decoding of Reed–Solomon and Algebraic-Geometry Codes" introducing an algorithm that allowed for the correction of errors beyond half the minimum distance of the code. It applies to Reed–Solomon codes and more generally to algebraic geometric codes. This algorithm produces a list of codewords (it is a list-decoding algorithm) and is based on interpolation and factorization of polynomials over
GF(2m)
In 2023, building on three exciting works,[12] [13] coding theorists showed that Reed-Solomon codes defined over random evaluation points can actually achieve list decoding capacity (up to errors) over linear size alphabets with high probability. However, this result is combinatorial rather than algorithmic.
The algebraic decoding methods described above are hard-decision methods, which means that for every symbol a hard decision is made about its value. For example, a decoder could associate with each symbol an additional value corresponding to the channel demodulator's confidence in the correctness of the symbol. The advent of LDPC and turbo codes, which employ iterated soft-decision belief propagation decoding methods to achieve error-correction performance close to the theoretical limit, has spurred interest in applying soft-decision decoding to conventional algebraic codes. In 2003, Ralf Koetter and Alexander Vardy presented a polynomial-time soft-decision algebraic list-decoding algorithm for Reed–Solomon codes, which was based upon the work by Sudan and Guruswami.[14] In 2016, Steven J. Franke and Joseph H. Taylor published a novel soft-decision decoder.[15]
Here we present a simple MATLAB implementation for an encoder.
% Get the alpha alpha = gf(2, m, prim_poly);
% Get the Reed-Solomon generating polynomial g(x) g_x = genpoly(k, n, alpha);
% Multiply the information by X^(n-k), or just pad with zeros at the end to % get space to add the redundant information msg_padded = gf([msg zeros(1, n - k)], m, prim_poly);
% Get the remainder of the division of the extended message by the % Reed-Solomon generating polynomial g(x) [~, remainder] = deconv(msg_padded, g_x);
% Now return the message with the redundant information encoded = msg_padded - remainder;
end
% Find the Reed-Solomon generating polynomial g(x), by the way this is the% same as the rsgenpoly function on matlabfunction g = genpoly(k, n, alpha) g = 1; % A multiplication on the galois field is just a convolution for k = mod(1 : n - k, n) g = conv(g, [1 alpha .^ (k)]); endend
Now the decoding part:
% Get the alpha alpha = gf(2, m, prim_poly);
% Find the syndromes (Check if dividing the message by the generator % polynomial the result is zero) Synd = polyval(encoded, alpha .^ (1:n - k)); Syndromes = trim(Synd);
% If all syndromes are zeros (perfectly divisible) there are no errors if isempty(Syndromes.x) decoded = orig_vals(1:k); error_pos = []; error_mag = []; g = []; S = Synd; return; end
% Prepare for the euclidean algorithm (Used to find the error locating % polynomials) r0 = [1, zeros(1, 2 * max_errors)]; r0 = gf(r0, m, prim_poly); r0 = trim(r0); size_r0 = length(r0); r1 = Syndromes; f0 = gf([zeros(1, size_r0 - 1) 1], m, prim_poly); f1 = gf(zeros(1, size_r0), m, prim_poly); g0 = f1; g1 = f0;
% Do the euclidean algorithm on the polynomials r0(x) and Syndromes(x) in % order to find the error locating polynomial while true % Do a long division [quotient, remainder] = deconv(r0, r1); % Add some zeros quotient = pad(quotient, length(g1));
% Find quotient*g1 and pad c = conv(quotient, g1); c = trim(c); c = pad(c, length(g0));
% Update g as g0-quotient*g1 g = g0 - c;
% Check if the degree of remainder(x) is less than max_errors if all(remainder(1:end - max_errors)
% Update r0, r1, g0, g1 and remove leading zeros r0 = trim(r1); r1 = trim(remainder); g0 = g1; g1 = g; end
% Remove leading zeros g = trim(g);
% Find the zeros of the error polynomial on this galois field evalPoly = polyval(g, alpha .^ (n - 1 : - 1 : 0)); error_pos = gf(find(evalPoly
% If no error position is found we return the received work, because % basically is nothing that we could do and we return the received message if isempty(error_pos) decoded = orig_vals(1:k); error_mag = []; return; end
% Prepare a linear system to solve the error polynomial and find the error % magnitudes size_error = length(error_pos); Syndrome_Vals = Syndromes.x; b(:, 1) = Syndrome_Vals(1:size_error); for idx = 1 : size_error e = alpha .^ (idx * (n - error_pos.x)); err = e.x; er(idx, :) = err; end
% Solve the linear system error_mag = (gf(er, m, prim_poly) \ gf(b, m, prim_poly))'; % Put the error magnitude on the error vector errors(error_pos.x) = error_mag.x; % Bring this vector to the galois field errors_gf = gf(errors, m, prim_poly);
% Now to fix the errors just add with the encoded code decoded_gf = encoded(1:k) + errors_gf(1:k); decoded = decoded_gf.x;
end
% Remove leading zeros from Galois arrayfunction gt = trim(g) gx = g.x; gt = gf(gx(find(gx, 1) : end), g.m, g.prim_poly);end
% Add leading zerosfunction xpad = pad(x, k) len = length(x); if len < k xpad = [zeros(1, k - len) x]; endend
The decoders described in this section use the Reed Solomon original view of a codeword as a sequence of polynomial values where the polynomial is based on the message to be encoded. The same set of fixed values are used by the encoder and decoder, and the decoder recovers the encoding polynomial (and optionally an error locating polynomial) from the received message.
described a theoretical decoder that corrected errors by finding the most popular message polynomial. The decoder only knows the set of values
a1
an
(255,249)
In 1986, a decoder known as the Berlekamp–Welch algorithm was developed as a decoder that is able to recover the original message polynomial as well as an error "locator" polynomial that produces zeroes for the input values that correspond to errors, with time complexity
O(n3)
n
Using RS(7,3), GF(929), and the set of evaluation points ai = i − 1
If the message polynomial is
The codeword is
Errors in transmission might cause this to be received instead.
The key equations are:
Assume maximum number of errors: e = 2. The key equations become:
Using Gaussian elimination:
Recalculate where to correct resulting in the corrected codeword:
In 2002, an improved decoder was developed by Shuhong Gao, based on the extended Euclid algorithm.
Using the same data as the Berlekamp Welch example above:
R-1=
n | |
\prod | |
i=1 |
(x-ai)
R0=
\{ai,b(ai)\}
A-1=0
A0=1
i | Ri | Ai | |
---|---|---|---|
−1 | 001 x7 + 908 x6 + 175 x5 + 194 x4 + 695 x3 + 094 x2 + 720 x + 000 | 000 | |
0 | 055 x6 + 440 x5 + 497 x4 + 904 x3 + 424 x2 + 472 x + 001 | 001 | |
1 | 702 x5 + 845 x4 + 691 x3 + 461 x2 + 327 x + 237 | 152 x + 237 | |
2 | 266 x4 + 086 x3 + 798 x2 + 311 x + 532 | 708 x2 + 176 x + 532 |
divide Q(x) and E(x) by most significant coefficient of E(x) = 708. (Optional)
Recalculate where to correct resulting in the corrected codeword: