/******************************************************************************/
/* */
/* COMPUTE PARITY VECTORS */
/* 08/01/11 (dkc) */
/* */
/******************************************************************************/
#include <math.h>
unsigned int bitcnt(unsigned int a);
unsigned int pack(unsigned int a, unsigned int s, unsigned int l);
far unsigned int error[4];
far unsigned int output[8000];
far unsigned char flag[65536*8];
int main () {
unsigned int l=8; // length of parity vector
unsigned int n=4; // number of 1's in parity vector
unsigned int i,j,b,count,iters;
error[0]=0;
error[1]=0;
error[2]=0;
error[3]=0;
if (l>21) {
error[3]=1;
goto zskip;
}
count=0;
iters=1<<l;
for (i=0; i<8000; i++)
output[i]=0;
for (i=0;i<65536*8; i++)
flag[i]=0;
for (i=0; i<iters; i++) {
if (flag[i]!=0)
continue;
b=bitcnt(i);
if (b!=n)
continue;
output[count]=i; // parity vector
count=count+1;
if (count>7999) {
error[3]=1;
goto zskip;
}
for (j=1; j<l; j++) {
b=pack(i, l, j);
flag[b]=1;
}
}
zskip:
error[0]=count;
return(0);
}