68 ERROR(
"memory allocation fail");
69 for(
int i=0; i < syn->
wei; i++)
74 for(
int j=0 ; j < err->
wei; j++)
84 static inline void two_vec_print(
const two_vec_t *
const it){
86 printf(
"two_vec_print(): null structure!\n");
89 printf(
"# two_vec: w_e=%d e=[",it->
w_e);
90 for(
int i=0; i < it->
w_e; i++)
91 printf(
" %d",it->
err[i]);
92 printf(
" ]%s w_s=%d s=[",it->
w_s>20?
"\n#":
" ",it->w_s);
93 for(
int i=0; i < it->
w_s; i++)
94 printf(
" %d",it->
syn[i]);
107 static inline int by_syndrome(
void *a,
void *b){
112 else if (pa->
w_s > pb->
w_s)
115 for(
int i=0; i < pa->
w_s; i++){
116 if (pa->
syn[i] < pb->
syn[i])
118 else if (pa->
syn[i] > pb->
syn[i])
134 static inline int by_error(
void *a,
void *b){
139 else if (pa->
w_e > pb->
w_e)
142 for(
int i=0; i < pa->
w_e; i++){
143 if (pa->
err[i] < pb->
err[i])
145 else if (pa->
err[i] > pb->
err[i])
166 __attribute__ ((unused))
const int debug){
168 const size_t keylen = syn->
wei *
sizeof(int);
169 if(p_swei[err->
wei] > syn->
wei){
172 printf(
"# swei[%d]=%d -> %d change\n# err: ",
179 p_swei[err->
wei]=syn->
wei;
184 printf(
"p_swei[%d]=%d swei=%d not small enough\n",err->
wei,p_swei[err->
wei],syn->
wei);
193 entry = two_vec_init(syn, err);
204 printf(
"already in the hash:\n");
structure to hold two sparse vectors (syndrome,error) in a hash
#define HASH_ADD(hh, head, fieldname, keylen_in, add)
#define HASH_FIND(hh, head, keyptr, keylen, out)
struct TWO_VEC_T two_vec_t
structure to hold two sparse vectors (syndrome,error) in a hash
void one_vec_print(const one_vec_t *const pvec)
Print a one_vec_t structure (indices and weight) to stdout.
struct ONE_VEC_T one_vec_t