# ldpcDecoderConfig

Create LDPC decoder configuration

## Description

The `ldpcDecoderConfig` object is a configuration object for the `ldpcDecode` function. The object specifies the low-density parity-check (LDPC) matrix and read-only properties to provide information about the configured matrix.

## Creation

### Syntax

``decodercfg = ldpcDecoderConfig``
``decodercfg = ldpcDecoderConfig(H)``
``decodercfg = ldpcDecoderConfig(H,alg)``
``decodercfg = ldpcDecoderConfig(encodercfg)``
``decodercfg = ldpcDecoderConfig(encodercfg,alg)``

### Description

````decodercfg = ldpcDecoderConfig` creates an LDPC decoder configuration object that specifies a rate 5/6 LDPC code from the WLAN 802.11™ standard [1].```

example

````decodercfg = ldpcDecoderConfig(H)` configures the output object setting the `ParityCheckMatrix` property `H`.```
````decodercfg = ldpcDecoderConfig(H,alg)` configures the output object setting the `ParityCheckMatrix` property to `H` and the `Algorithm` property to `alg`.```
````decodercfg = ldpcDecoderConfig(encodercfg)` sets properties based on the input `ldpcEncoderConfig` configuration object, `encodercfg`.```
````decodercfg = ldpcDecoderConfig(encodercfg,alg)` sets properties based on the input `ldpcEncoderConfig` configuration object, `encodercfg`, and sets the `Algorithm` property to `alg`.Validation of the object settings is performed when the `ldpcDecode` function is called with the object as an input.```

## Properties

expand all

Parity-check matrix, specified as a sparse logical (NK)-by-N matrix, where N > K > 0. N is the LDPC codeword block length. K is the number of information bits in the LDPC codeword. The default is the parity-check matrix of rate 5/6 LDPC code with a block length of 648 as specified in the WLAN 802.11 standard [1]. Specifically, the default is the sparse logical 108-by-648 matrix `H` output by the `ldpcQuasiCyclicMatrix` function in this code.

```P = [ 17 13 8 21 9 3 18 12 10 0 4 15 19 2 5 10 26 19 13 13 1 0 -1 -1 3 12 11 14 11 25 5 18 0 9 2 26 26 10 24 7 14 20 4 2 -1 0 0 -1 22 16 4 3 10 21 12 5 21 14 19 5 -1 8 5 18 11 5 5 15 0 -1 0 0 7 7 14 14 4 16 16 24 24 10 1 7 15 6 10 26 8 18 21 14 1 -1 -1 0 ]; blockSize = 27; H = ldpcQuasiCyclicMatrix(blockSize,P); ```

Data Types: `logical`

LDPC decoding algorithm, specified as one of these values:

Data Types: `char` | `string`

Block length of the LDPC codeword (N), specified as a positive scalar. N equals the number of columns in the parity-check matrix.

Data Types: `double`

Number of information bits in the LDPC codeword (K), specified as a positive scalar. K equals the number of columns of the parity-check matrix minus the number of rows of the parity-check matrix.

Data Types: `double`

Number of parity-check bits in the LDPC codeword (NK), specified as a positive scalar. NK equals the number of rows in the parity-check matrix.

Data Types: `double`

Code rate of the LDPC code, specified as a positive scalar that is equal to `NumInformationBits`/`BlockLength`.

Data Types: `double`

Number of rows per layer, specified as a positive scalar. This property indicates the number of rows per layer when you use a layered decoding algorithm. Specifically, this property is the largest integer such that `ParityCheckMatrix` can be evenly split into consecutive submatrices in which at most one `1` exists in any column in any one of these submatrices.

`ParityCheckMatrix(1:NumRowsPerLayer,:)`

```ParityCheckMatrix((NumRowsPerLayer + 1):2*NumRowsPerLayer,:)```

```ParityCheckMatrix((2*NumRowsPerLayer + 1):3*NumRowsPerLayer,:)```

...

`ParityCheckMatrix`((end - `NumRowsPerLayer` + 1):end, :)

#### Dependencies

To enable this property set the `Algorithm` property to `'layered-bp'`, `'norm-min-sum'`, or `'offset-min-sum'`.

Data Types: `double`

## Examples

collapse all

Initialize parameters for the prototype matrix and block size to configure a rate 3/4 LDPC code specified in IEEE® 802.11. Create the parity-check matrix by using the `ldpcQuasiCyclicMatrix` function.

```P = [ 16 17 22 24 9 3 14 -1 4 2 7 -1 26 -1 2 -1 21 -1 1 0 -1 -1 -1 -1 25 12 12 3 3 26 6 21 -1 15 22 -1 15 -1 4 -1 -1 16 -1 0 0 -1 -1 -1 25 18 26 16 22 23 9 -1 0 -1 4 -1 4 -1 8 23 11 -1 -1 -1 0 0 -1 -1 9 7 0 1 17 -1 -1 7 3 -1 3 23 -1 16 -1 -1 21 -1 0 -1 -1 0 0 -1 24 5 26 7 1 -1 -1 15 24 15 -1 8 -1 13 -1 13 -1 11 -1 -1 -1 -1 0 0 2 2 19 14 24 1 15 19 -1 21 -1 2 -1 24 -1 3 -1 2 1 -1 -1 -1 -1 0 ]; blockSize = 27; pcmatrix = ldpcQuasiCyclicMatrix(blockSize,P);```

Create LDPC encoder and decoder configuration objects, displaying their properties.

`cfgLDPCEnc = ldpcEncoderConfig(pcmatrix)`
```cfgLDPCEnc = ldpcEncoderConfig with properties: ParityCheckMatrix: [162x648 logical] Read-only properties: BlockLength: 648 NumInformationBits: 486 NumParityCheckBits: 162 CodeRate: 0.7500 ```
`cfgLDPCDec = ldpcDecoderConfig(pcmatrix)`
```cfgLDPCDec = ldpcDecoderConfig with properties: ParityCheckMatrix: [162x648 logical] Algorithm: 'bp' Read-only properties: BlockLength: 648 NumInformationBits: 486 NumParityCheckBits: 162 CodeRate: 0.7500 ```

Transmit an LDPC-encoded, QPSK-modulated bit stream through an AWGN channel. Demodulate the signal, decode the received codewords, and then count bit errors. Use nested `for` loops to process multiple SNR settings and frames with and without LDPC forward error correction (FEC) coding of the transmitted data.

```M = 4; maxnumiter = 10; snr = [20 6 3]; numframes = 10; qpskmod = comm.PSKModulator(M,'BitInput',true); qpskmod2 = comm.PSKModulator(M); ber = comm.ErrorRate; ber2 = comm.ErrorRate; for ii = 1:length(snr) qpskdemod = comm.PSKDemodulator(M,'BitOutput',true, ... 'DecisionMethod','Approximate log-likelihood ratio', ... 'Variance',1/10^(snr(ii)/10)); qpskdemod2 = comm.PSKDemodulator(M); for counter = 1:numframes data = randi([0 1],cfgLDPCEnc.NumInformationBits,1,'int8'); % Transmit and receive with LDPC coding encodedData = ldpcEncode(data,cfgLDPCEnc); modSignal = qpskmod(encodedData); receivedSignal = awgn(modSignal,snr(ii)); demodSignal = qpskdemod(receivedSignal); receivedBits = ldpcDecode(demodSignal,cfgLDPCDec,maxnumiter); errStats = ber(data,receivedBits); % Transmit and receive with no LDPC coding noCoding = qpskmod2(data); rxNoCoding = awgn(noCoding,snr(ii)); rxBitsNoCoding = qpskdemod2(rxNoCoding); errStatsNoCoding = ber2(data,int8(rxBitsNoCoding)); end fprintf(['SNR = %2d\n Coded: Error rate = %1.2f, ' ... 'Number of errors = %d\n'], ... snr(ii),errStats(1),errStats(2)) fprintf(['Noncoded: Error rate = %1.2f, ' ... 'Number of errors = %d\n'], ... errStatsNoCoding(1),errStatsNoCoding(2)) end```
```SNR = 20 Coded: Error rate = 0.00, Number of errors = 0 ```
```Noncoded: Error rate = 0.00, Number of errors = 0 ```
```SNR = 6 Coded: Error rate = 0.00, Number of errors = 0 ```
```Noncoded: Error rate = 0.02, Number of errors = 196 ```
```SNR = 3 Coded: Error rate = 0.02, Number of errors = 353 ```
```Noncoded: Error rate = 0.07, Number of errors = 976 ```

## Algorithms

expand all

LDPC decoding using one of these message-passing algorithms.

## References

[1] IEEE Std 802.11-2016 (Revision of IEEE Std 802.11-2012). "Part 11: Wireless LAN Medium Access Control (MAC) and Physical Layer (PHY) Specifications." IEEE Standard for Information technology — Telecommunications and information exchange between systems. Local and metropolitan area networks — Specific requirements.

[2] Gallager, Robert G. Low-Density Parity-Check Codes. Cambridge, MA: MIT Press, 1963.

[3] Hocevar, D.E. "A reduced complexity decoder architecture via layered decoding of LDPC codes." In IEEE Workshop on Signal Processing Systems, 2004. SIPS 2004. doi: 10.1109/SIPS.2004.1363033

[4] Chen, Jinghu, R.M. Tanner, C. Jones, and Yan Li. "Improved min-sum decoding algorithms for irregular LDPC codes." In Proceedings. International Symposium on Information Theory, 2005. ISIT 2005. doi: 10.1109/ISIT.2005.1523374

## Version History

Introduced in R2021b