/* ENC.C - Encoding procedures. */ /* Copyright (c) 2000, 2001 by Radford M. Neal * * Permission is granted for anyone to copy, use, modify, or distribute this * program and accompanying programs and documents for any purpose, provided * this copyright notice is retained and prominently displayed, along with * a note saying that the original programs are available from Radford Neal's * web page, and note is made of any changes made to the programs. The * programs and documents are distributed without any warranty, express or * implied. As the programs were written for research purposes only, they have * not been tested to the degree that would be advisable in any important * application. All use of these programs is entirely at the user's own risk. */ #include #include #include #include "rand.h" #include "alloc.h" #include "mod2sparse.h" #include "mod2dense.h" #include "mod2convert.h" #include "rcode.h" #include "enc.h" /* The procedures in this module obtain the generator matrix to use for encoding from the global variables declared in rcode.h */ /* ENCODE A BLOCK USING A SPARSE REPRESENTATION OF THE GENERATOR MATRIX. */ void sparse_encode ( char *sblk, char *cblk ) { int i, j; mod2entry *e; char *x, *y; x = chk_alloc (M, sizeof *x); y = chk_alloc (M, sizeof *y); /* Multiply the vector of source bits by the systematic columns of the parity check matrix, giving x. Also copy these bits to the coded block. */ for (i = 0; i