/* ALIST-TO-PCHK.C - Convert a parity check matrix to alist format. */ /* 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 #include "alloc.h" #include "open.h" #include "mod2sparse.h" #include "mod2dense.h" #include "mod2convert.h" #include "rcode.h" void usage(void); /* MAIN PROGRAM. */ int main ( int argc, char **argv ) { char *alist_file, *pchk_file; FILE *af, *pf; int mxrw, mxcw; int *rw, *cw; int i, j, k; mod2entry *e; int trans; int nozeros; int last; trans = 0; nozeros = 0; for (;;) { if (argc>1 && strcmp(argv[1],"-t")==0) { trans = 1; argc -= 1; argv += 1; } else if (argc>1 && strcmp(argv[1],"-z")==0) { nozeros = 1; argc -= 1; argv += 1; } else { break; } } if (argc!=3) { usage(); } pchk_file = argv[1]; alist_file = argv[2]; read_pchk(pchk_file); if (trans) { mod2sparse *HT; HT = H; H = mod2sparse_allocate(N,M); mod2sparse_transpose(HT,H); M = mod2sparse_rows(H); N = mod2sparse_cols(H); } af = open_file_std(alist_file,"wb"); if (af==NULL) { fprintf(stderr,"Can't create alist file: %s\n",alist_file); exit(1); } fprintf(af,"%d %d\n",M,N); rw = (int *) chk_alloc (M, sizeof *rw); mxrw = 0; for (i = 0; imxrw) { mxrw = rw[i]; } } cw = (int *) chk_alloc (N, sizeof *cw); mxcw = 0; for (j = 0; jmxcw) { mxcw = cw[j]; } } fprintf(af,"%d %d\n",mxrw,mxcw); for (i = 0; i