Lexicographic code: Difference between revisions

Content deleted Content added
No edit summary
Line 789:
| volume = 48
| year = 2002}}</ref>
 
== Implementation ==
Following C generate lexicographic code and parameters are set for the Golay code (N=24, D=8).
<syntaxhighlight lang="c">
#include <stdio.h>
#include <stdlib.h>
int main() { /* GOLAY CODE generation */
int i, j, k;
int _pc[1<<16] = {0}; // PopCount Macro
for (i=0; i < (1<<16); i++)
for (j=0; j < 16; j++)
_pc[i] += (i>>j)&1;
#define pc(X) (_pc[(X)&0xffff] + _pc[((X)>>16)&0xffff])
#define N 24 // N bits
#define D 8 // D bits distance
unsigned int * z = malloc(1<<28);
for (i=j=0; i < (1<<N); i++)
{ // Scan all previous
for(k=j-1; k >= 0; k--) // lexicodes.
if( pc( z[k]^i ) < D) // Reverse cheking
break; // is way faster...
if (k == -1) { // Add new lexicode
for (k=0; k < N; k++) // & print it
printf("%d", (i>>k)&1);
printf(" : %d\n", j);
z[j++] = i;
}
}
}
</syntaxhighlight>
 
== Combinatorial game theory ==