Tutorial – the sum-product algorithm for decoding of LDPC codes Use a small parity-check matrix H and make sure that the sum-product algorithm works appropriately before simulating communication systems with larger and more complex LDPC codes (i.e. codes corresponding to a large matrix H). Use for example the small matrix H (which we considered during the lecture): 1 1 H 0 0 0 0 1 1 1 0 1 0 0 1 0 1 1 0 0 1 0 1 1 0 1 0 1 0 0 1 0 1 which corresponds to the factor graph: Start by constructing the codeword c that we want to transmit. For all linear block codes, the all zero codeword is a valid codeword, hence we assume that we want to transmit the message (the structure of the parity check matrix H above indicates that the information message consists of 4 elements and the codeword of 8 elements): m = [0 0 0 0] which corresponds to the codeword c = mG = [0 0 0 0 0 0 0 0] With respect to this assumption, we do not need the generator matrix G (which would be the case if the elements of m would be different). For example, assume that BPSK modulation is used and that all codeword bits are assigned values +1 or -1 before transmission over the channel (these values +1 and -1 are related to the location of the codeword symbols in the signal space after BPSK modulation). After modulation and with respect to the mapping [0,1] → [-1,+1], the all zero codeword corresponds to: c_mod = [-1 -1 -1 -1 -1 -1 -1 -1] Now, assume that c_mod is sent over a noisy channel which yields the received codeword r at the receiver: r = [-2.5467 0.2358 -1.3929 -3.0287 -1.8290 -1.1768 -1.9434 -0.1152] Given r and the description of the sum-product algorithm (see the documentation on the course website), the output of the steps 1-5 should approximately be as follows: Output of Step 1 (see equation (3)): Assume transmission over an AWGN channel with normalized channel variance N0/2 = 1. v = -2r / (N0/2)2 = [5.0935 -0.4716 2.7859 6.0574 3.6580 2.3535 3.8867 0.2305] Output of Step 2 (1st iteration) (see equation (4)): (The first time the variables send their probability of being in a specific state, the messages simply correspond to the values v from Step 1, since no messages have been received from the checks which will be the case for the subsequent iterations.) From Variable 1 to Check 1 = 5.0935 From Variable 1 to Check 2 = 5.0935 From Variable 2 to Check 3 = -0.4716 From Variable 2 to Check 4 = -0.4716 From Variable 3 to Check 1 = 2.7859 From Variable 3 to Check 3 = 2.7859 From Variable 4 to Check 2 = 6.0574 From Variable 4 to Check 4 = 6.0574 From Variable 5 to Check 1 = 3.6580 From Variable 5 to Check 4 = 3.6580 From Variable 6 to Check 2 = 2.3535 From Variable 6 to Check 3 = 2.3535 From Variable 7 to Check 1 = 3.8867 From Variable 7 to Check 3 = 3.8867 From Variable 8 to Check 2 = 0.2305 From Variable 8 to Check 4 = 0.2305 Output of Step 3 (1st iteration) (see equation (8)): Satisfaction of Check 1 = 201.7455 Satisfaction of Check 2 = 16.7372 Satisfaction of Check 3 = -12.0177 Satisfaction of Check 4 = -2.4086 Since not all satisfaction values of the checks are > 0, we do not have a valid codeword and hence the iteration continues. Output of Step 4 (1st iteration) (see equation (5)): From Check 1 to Variable 1 = 2.2290 From Check 2 to Variable 1 = 0.1893 From Check 3 to Variable 2 = 1.7387 From Check 4 to Variable 2 = 0.2178 From Check 1 to Variable 3 = 2.9490 From Check 3 to Variable 3 = -0.3715 From Check 2 to Variable 4 = 0.1879 From Check 4 to Variable 4 = -0.0505 From Check 1 to Variable 5 = 2.4284 From Check 4 to Variable 5 = -0.0529 From Check 2 to Variable 6 = 0.2266 From Check 3 to Variable 6 = -0.3980 From Check 1 to Variable 7 = 2.3708 From Check 3 to Variable 7 = -0.3415 From Check 2 to Variable 8 = 2.2689 From Check 4 to Variable 8 = -0.4449 Output of Step 2 (2nd iteration) (see equation (4)): (This time we take messages from the checks into account.) From Variable 1 to Check 1 = 5.2828 From Variable 1 to Check 2 = 7.3224 From Variable 2 to Check 3 = -0.2538 From Variable 2 to Check 4 = 1.2671 From Variable 3 to Check 1 = 2.4144 From Variable 3 to Check 3 = 5.7348 From Variable 4 to Check 2 = 6.0069 From Variable 4 to Check 4 = 6.2453 From Variable 5 to Check 1 = 3.6051 From Variable 5 to Check 4 = 6.0865 From Variable 6 to Check 2 = 1.9556 From Variable 6 to Check 3 = 2.5801 From Variable 7 to Check 1 = 3.5452 From Variable 7 to Check 3 = 6.2575 From Variable 8 to Check 2 = -0.2144 From Variable 8 to Check 4 = 2.4994 Output of Step 3 (2nd iteration) (see equation (8)): Satisfaction of Check 1 = 163.0174 Satisfaction of Check 2 = -18.4419 Satisfaction of Check 3 = -23.4991 Satisfaction of Check 4 = 120.3822 Since not all satisfaction values of the checks are > 0, we do not have a valid codeword and hence the iteration continues. Output of Step 4 (2nd iteration) (see equation (5)): From Check 1 to Variable 1 = 1.9331 From Check 2 to Variable 1 = -0.1602 From Check 3 to Variable 2 = 2.5148 From Check 4 to Variable 2 = 2.4497 From Check 1 to Variable 3 = 2.7959 From Check 3 to Variable 3 = -0.2169 From Check 2 to Variable 4 = -0.1608 From Check 4 to Variable 4 = 1.0285 From Check 1 to Variable 5 = 2.0957 From Check 4 to Variable 5 = 1.0293 From Check 2 to Variable 6 = -0.2131 From Check 3 to Variable 6 = -0.2512 From Check 1 to Variable 7 = 2.1092 From Check 3 to Variable 7 = -0.2163 From Check 2 to Variable 8 = 1.9342 From Check 4 to Variable 8 = 1.2535 Output of Step 2 (3rd iteration): From Variable 1 to Check 1 = 4.9333 From Variable 1 to Check 2 = 7.0265 From Variable 2 to Check 3 = 1.9781 From Variable 2 to Check 4 = 2.0432 From Variable 3 to Check 1 = 2.5690 From Variable 3 to Check 3 = 5.5817 From Variable 4 to Check 2 = 7.0859 From Variable 4 to Check 4 = 5.8966 From Variable 5 to Check 1 = 4.6874 From Variable 5 to Check 4 = 5.7537 From Variable 6 to Check 2 = 2.1023 From Variable 6 to Check 3 = 2.1405 From Variable 7 to Check 1 = 3.6704 From Variable 7 to Check 3 = 5.9960 From Variable 8 to Check 2 = 1.4840 From Variable 8 to Check 4 = 2.1647 Output of Step 3 (3rd iteration) (see equation (8)): Satisfaction of Check 1 = 218.0386 Satisfaction of Check 2 = 155.3315 Satisfaction of Check 3 = 141.7045 Satisfaction of Check 4 = 150.0543 All satisfaction values of the checks are > 0, we have found a valid codeword! The next step is to obtain the binary representation of the codeword and the message. Output of Step 5: We form the resulting output values as (see equation (6)) v’ = [6.8664 4.4929 5.3648 6.9251 6.7831 1.8893 5.7796 3.4181] and the hard decisions with respect to these values give us the received codeword (see equation (7)) c = [0 0 0 0 0 0 0 0]. Finally, given the assumption that the first part of the codeword corresponds to the message m, we get m as m = [0 0 0 0]. Comparing the received message sequence to the transmitted message, we observe that no error occurred (however, recall that the algorithm can converge to a codeword that is valid but not equal to the transmitted codeword, and thus the received message may contain errors although the sum-product algorithm stops iterating due to a fulfilled stopping criterion). HINT: The sum-product algorithm consists of an inverse hyperbolic tangent (i.e. tanh-1) computation. Since tanh-1(x) approaches +/- infinity as x goes to +/- 1, there is a potential risk of error in MATLAB due to limitations of the numerical precision. Hence, in order to avoid that MATLAB returns +/- infinity when making the tanh-1 computation, it is suitable to include a limitation similar to the pseudo code (note: tanh-1(0.9999) ≈ 5): if (-0.9999 < x) & (x < 0.9999) % perform the atanh computation as specified in the % sum-product algorithm else atanh_computation = 5*sign(tanh-1(x)); end
© Copyright 2026 Paperzz