/* ENC.C - Encoding procedures. */ /* Copyright (c) 1995-2012 by Radford M. Neal. * * Permission is granted for anyone to copy, use, modify, and distribute * these programs and accompanying documents for any purpose, provided * this copyright notice is retained and prominently displayed, and note * is made of any changes made to these programs. These 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