src/lib/zint/reedsol.c
void rs_init_gf(int poly)
{
	int m, b, p, v;

	// Find the top bit, and hence the symbol size
	for (b = 1, m = 0; b <= poly; b <<= 1)
		m++;
	b >>= 1;
	m--;
	gfpoly = poly;
	symsize = m;

	// Calculate the log/alog tables
	logmod = (1 << m) - 1;
	logt = (int *)malloc(sizeof(int) * (logmod + 1));
	alog = (int *)malloc(sizeof(int) * logmod);

	for (p = 1, v = 0; v < logmod; v++) {
		alog[v] = p;
		logt[p] = v;
		p <<= 1;
		if (p & b)
			p ^= poly;
	}
}
// rs_init_gf(poly) initialises the parameters for the Galois Field.
// The symbol size is determined from the highest bit set in poly
// This implementation will support sizes up to 30 bits (though that
// will result in very large log/antilog tables) - bit sizes of
// 8 or 4 are typical
//
// The poly is the bit pattern representing the GF characteristic
// polynomial.  e.g. for ECC200 (8-bit symbols) the polynomial is
// a**8 + a**5 + a**3 + a**2 + 1, which translates to 0x12d.
rs_init_gf(poly) initialises the parameters for the Galois Field.
The symbol size is determined from the highest bit set in poly
This implementation will support sizes up to 30 bits (though that
will result in very large log/antilog tables) - bit sizes of
8 or 4 are typical

The poly is the bit pattern representing the GF characteristic
polynomial.
rs_init_gf ( poly ) initialises the parameters for the Galois Field . The symbol size is determined from the highest bit set in poly This implementation will support sizes up to 30 bits ( though that will result in very large log / antilog tables ) - bit sizes of 8 or 4 are typical The poly is the bit pattern representing the GF characteristic polynomial .
void rs_init_gf(int poly)
{
	int m, b, p, v;
	for (b = 1, m = 0; b <= poly; b <<= 1)
		m++;
	b >>= 1;
	m--;
	gfpoly = poly;
	symsize = m;
	logmod = (1 << m) - 1;
	logt = (int *)malloc(sizeof(int) * (logmod + 1));
	alog = (int *)malloc(sizeof(int) * logmod);
	for (p = 1, v = 0; v < logmod; v++) {
		alog[v] = p;
		logt[p] = v;
		p <<= 1;
		if (p & b)
			p ^= poly;
	}
}
void rs_init_gf ( int poly ) { int m , b , p , v ; for ( b = 1 , m = 0 ; b <= poly ; b <<= 1 ) m ++ ; b >>= 1 ; m -- ; gfpoly = poly ; symsize = m ; logmod = ( 1 << m ) - 1 ; logt = ( int * ) malloc ( sizeof ( int ) * ( logmod + 1 ) ) ; alog = ( int * ) malloc ( sizeof ( int ) * logmod ) ; for ( p = 1 , v = 0 ; v < logmod ; v ++ ) { alog [ v ] = p ; logt [ p ] = v ; p <<= 1 ; if ( p & b ) p ^= poly ; } }
rs_init_gf(poly) initialises the parameters for the Galois Field.
rs_init_gf ( poly ) initialises the parameters for the Galois Field .
// Find the top bit, and hence the symbol size // Calculate the log/alog tables