# Notes on Modifying the LDPC Programs

Here are a few notes on how to modify the programs to add new types of channel, new decoding procedures, etc. You should also look at the module documentation.

## Adding a new type of channel

Channels are involved in two programs: transmit and decode. Adding another type of memoryless channel should be straightforward. Adding a channel with memory may involve more work. Here are the steps needed if no major reorganizations are required:

1. Decide on a syntax for specifying the new channel type and its parameters, and on an internal name for the channel type. Add the internal name as a possibility in the enumerated `channel_type` declared in `channel.h`. You may also need to declare new global variables to store parameters of the channel in `channel.h` and `channel.c`.
2. Modify the `channel_parse` and `channel_usage` procedures in `channel.c` to parse the specification of the new channel and display an appropriate usage message.
3. Decide on how the new channel's output is represented in a file (eg, for an erasure channel, what the symbol for an erasure is), and update `transmit.c` to write the new channel's output for each transmitted bit, after randomly generating any noise (see the documentation on random number generation).
4. Modify `decode.c` in three places to accommodate the new channel. The three sections of code to modify allocate space for data from the channel, read data from the channel, and set likelihood ratios based on the data read. The setting of likelihood ratios is based on the assumption that the channel is memoryless (ie, data received for different bits is independent). Adding a channel with memory would require changing this assumption, which would involve modifications to the decoding procedures too.
5. Document the new channel type in channel.html and decoding.html.

## Adding a new decoding procedure

A new decoding method can be implemented as follows:

1. Decide on a syntax for specifying the method and its parameters, using the trailing arguments to the `decode` program. Pick an internal name for the method, and add it as a possibility in the enumerated `decoding_method` type in `dec.h`. You may also need to declare new variables for the method's parameters in `dec.h` and `dec.c`.
2. Modify the argument parsing code in `decode.c` to handle specifications of the new method, and change the `usage` procedure to display the syntax for specifying the new method.
3. Write a setup procedure for your decoding method, putting it in `dec.c`, with a declaration in `dec.h`. At a minimum, this procedure should print headers for the table of detailed decoding information when the -T option was specified.
4. Write a decode procedure implementing your method, putting it in `dec.c`, with a declaration in `dec.h`. This procedure should output detailed trace information when the -T option was specified.
5. Modify `decode.c` in the appropriate places to call the setup procedure and the decode procedure you wrote.
6. Document the new decoding method in decoding.html and decode-detail.html.

## Adding a new method of making a low-density parity-check matrix

The make-ldpc program can be changed to add a new method for generating a LDPC code by modifying `make-ldpc.c`. A radically different method might better be implemented by writing a new program of similar structure.

## Adding a new encoding method

A new heuristic for finding a sparse LU decomposition can be implemented by changing make-gen.c to allow the new heuristic to be specified on the command line, changing the mod2sparse_decomp procedure in `mod2sparse.c` to implement the heuristic, and documenting the new heuristic in encoding.html, sparse-LU.html, and mod2sparse.html.

To implement a completely new encoding method, you will first need to define a new file format for a generator matrix, modify make-gen.c appropriately to write out this new format, and modify the `read_gen` procedure in `rcode.c` to read this format. You will need to implement the new method in a procedure in enc.c, and modify encode.c so that it will call this new procedure when the new method is used. The `enum_decode` procedure in dec.c will also need to be modified so it can call the new encoding method. Finally, you should document the new method in encoding.html

Back to index for LDPC software