Skip to content

Commit

Permalink
Changed alist-to-pchk so it no longer requires zero padding of index …
Browse files Browse the repository at this point in the history
…lists.
  • Loading branch information
radfordneal committed Feb 5, 2012
1 parent 75b4fcc commit 0410fb5
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 21 deletions.
31 changes: 11 additions & 20 deletions alist-to-pchk.c
Expand Up @@ -44,6 +44,7 @@ int main
int *rw, *cw;
int i, j, k;
int tot, trans;
int nxt;

trans = 0;

Expand Down Expand Up @@ -98,42 +99,32 @@ int main

H = mod2sparse_allocate(M,N);

do { if (fscanf(af,"%d",&nxt)!=1) nxt = -1; } while (nxt==0);

tot = 0;

for (i = 0; i<M; i++)
{ for (k = 0; k<mxrw; k++)
{ if (fscanf(af,"%d",&j)!=1 || j<0 || j>N
|| k>=rw[i] && j!=0 || k<rw[i] && j==0)
{ for (k = 0; k<rw[i]; k++)
{ if (nxt<=0 || nxt>N || mod2sparse_find(H,i,nxt-1))
{ bad_alist_file();
}
if (j==0) continue;
if (mod2sparse_find(H,i,j-1))
{ bad_alist_file();
}
mod2sparse_insert(H,i,j-1);
mod2sparse_insert(H,i,nxt-1);
tot += 1;
do { if (fscanf(af,"%d",&nxt)!=1) nxt = -1; } while (nxt==0);
}
}

for (j = 0; j<N; j++)
{ for (k = 0; k<mxcw; k++)
{ if (fscanf(af,"%d",&i)!=1 || i<0 || i>M
|| k>=cw[j] && i!=0 || k<cw[j] && i==0)
{ bad_alist_file();
}
if (i==0) continue;
if (!mod2sparse_find(H,i-1,j))
{ for (k = 0; k<cw[j]; k++)
{ if (nxt<=0 || nxt>M || !mod2sparse_find(H,nxt-1,j))
{ bad_alist_file();
}
tot -= 1;
do { if (fscanf(af,"%d",&nxt)!=1) nxt = -1; } while (nxt==0);
}
}

if (tot!=0)
{ bad_alist_file();
}

if (fscanf(af,"%d",&i)==1 || !feof(af))
if (tot!=0 || nxt!=-1 || !feof(af))
{ bad_alist_file();
}

Expand Down
11 changes: 10 additions & 1 deletion pchk.html
Expand Up @@ -145,6 +145,13 @@ <H1> Creating a Parity Check Matrix </H1>
matrix in <TT><I>alist-file</I></TT> is stored in the
<TT><I>pchk-file</I></TT>.

<P>Any zeros indexes in the alist file are ignored, so that alist files
with zero padding (as required in the specification) are accepted,
but files without this zero padding are also accepted. Newlines
are ignored by <TT>alist-to-pchk</TT>, so no error is reported if
the set of indexes in a row or column description are not those
on a single line.


<P><A NAME="pchk-to-alist"><HR><B>pchk-to-alist</B>: Convert a parity
check matrix to alist format.
Expand All @@ -167,7 +174,9 @@ <H1> Creating a Parity Check Matrix </H1>
says that the list of indexes of 1s for each row or column should
be padded with zeros to the maximum number of indexes. By default,
<TT>pchk-to-alist</TT> does this, but output of these 0s can be
suppressed by specifying the <B>-z</B> option.
suppressed by specifying the <B>-z</B> option. (The <TT>alist-to-pchk</TT>
program will accept alist files produced with or without the <B>-z</B>
option.)


<P><A NAME="print-pchk"><HR><B>print-pchk</B>: Print a parity check matrix.
Expand Down
3 changes: 3 additions & 0 deletions release.html
Expand Up @@ -31,6 +31,9 @@ <H2>Release to come.</H2>
row and column indexes that pad up to the maximum number used.
<LI> Documented the previously undocumented -t options for pchk-to-alist
and alist-to-pchk.
<LI> Changed alist-to-pchk so that it no longer requires zero indexes
that pad out to the maximum needed for a row or column (thanks
to Monica Kolb for suggesting this).
<LI> Changed mod2word type in mod2dense.c to uint32_t, to avoid
wasted space when long is 64 bits (thanks to Mathieu Cunche
and Vincent Roca for suggesting this).
Expand Down

0 comments on commit 0410fb5

Please sign in to comment.