[python] QR code application of Reed-solomon codes (1)

    Note: This part of the blog mainly combines Mr. Zhou's PPT and the information found, trying to explain the mathematical principles and information theory principles of Reed-Solomon Codes, and discuss the application of Reed-Solomon Codes in QR codes.

    Reed-Solomon Codes (RS code), Reed Solomon code, also known as erasure code (meaning that it can tolerate lost data), is a recoverable code commonly used when storing data. The general principle is to set the data to n block, the RS code generates m blocks of check codes from n blocks of data. If k blocks (k<=m) are lost in the data blocks and check codes (n+m blocks in total), the remaining data blocks and check codes can be passed. Block restores the original data block.

    This series will be divided into two parts: "encoding principle" and "decoding principle", each of which will explain the mathematical principle first, and then link to the principle of information theory, and the QR code will be interspersed.

【Coding principle】

    The encoding process is the process of converting the original data into a code to prevent loss (corresponding to the format information of the QR code, that is, mask + error correction level). When encoding, the data is divided into data blocks with a word length of w (QR code is generally 8 bits as a word), the data block has a total of n blocks, and each input data is stored as a vector in the matrix, set as D = ( D1 , D2 .... Dn), after encoding, the data is also stored as a vector as (D1, D2, D3.....Dn,C1,C2,C3...Cm), that is, the encoded The vector only adds a row of vectors (C1, C2, C3...Cm) to the original matrix suffix, similar to the following figure:

             

           (In the figure, the 5*5 unit matrix in B is multiplied by the D matrix to get the D matrix, and the matrix starting at row n+1 in B is multiplied by the D matrix to obtain the C matrix.)

    Let's not discuss the specific reasons why the original data D is encoded into D+C through matrix transformation. First, we try to understand how it is expressed in a mathematical model and what the contents of the three matrices BCD represent.

    First, let’s talk about the mathematical principles in combination with the matrix in the above figure (will be elaborated later) (Mr. Zhou’s thinking is too strong, the matrix has only a few rows of ci variables and did not elaborate, so... I didn’t understand... only I can find another way to try to understand...):

    We set m check symbols, then there is a generator polynomial g(x), we set g(x)=(xa^0)(xa^1)...(xa^(m-1)) ;Set the original input code D to have n words, set it as a list mag_in, then add m 0s to the mag_in suffix, if it is the above picture, it will be mag_in = [d1,d2,d3,d4,d5], it becomes mag_in= [d1,d2,d3,d4,d5,0,0,0]. Then we turn the changed mag_in list into a polynomial, divide by the generator polynomial g(x) by synthetic division, and get a list of [d1,d2,d3,d4,d5,p1,p2,p3] , then what do the lists d and p after the comprehensive division process represent?

       Where di corresponds to di in the previous mag_in. If the product of k (any value of xa^) in g(x) is set as mul(k), then p3 represents the remainder of mag_in divided by mul(1), and p2 represents mag_in divided by mul(2) The remainder, p1 represents the remainder of mag_in divided by mul(3)... At this time, m=3, if m is uncertain, it will continue from this law, it should be k<=m, so p The number of is only m. Here we find that p1, p2, p3.....pm coincide with the matrices c1, c2, c3...cm in the above figure, which is also to add m [0] to the suffix when setting mag_in. ] is for the convenience of storing m pi, and also to prevent the remainder calculated at each step from overwriting the original data di during comprehensive division.

    The general principle of the picture is sauce purple. Next, we need to understand the generator polynomial g(x), as well as the finite field GF(2^m) represented by the power exponents a^0, a^1, etc. behind it, which will be updated tomorrow.


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325621351&siteId=291194637