40 const int steps =
p->
steps;
41 const int wmin =
p->
wmin;
42 const int wmax =
p->
wmax;
44 const int debug =
p->
debug;
46 const int nvar = spaH0->
cols;
47 if(((!classical)&&(spaL0==NULL)) ||
48 ((classical)&&(spaL0!=NULL))){
49 printf(
"L0 %s NULL classical=%d\n",spaL0==NULL ?
"=" :
"!=", classical);
50 ERROR(
"L0 should be non-NULL only for classical code!\n");
62 printf(
"# running do_RW_dist() with steps=%d wmin=%d wmax=%d classical=%d nvar=%d\n",
63 steps, wmin, wmax, classical, nvar);
68 rci_t *ee = malloc(nvar*
sizeof(rci_t));
71 ERROR(
"memory allocation failed!\n");
74 mzp_t * perm=mzp_init(nvar);
75 mzp_t * pivs=mzp_init(nvar);
76 mzp_t * pivs_srtd=mzp_init(nvar);
77 mzp_t * skip_pivs=mzp_init(nvar);
78 if((!pivs) || (!perm))
79 ERROR(
"memory allocation failed!\n");
81 for (
int ii=0; ii< steps; ii++){
88 for(
int i=0; i< nvar; i++){
89 int col=perm->values[i];
90 int ret=gauss_one(mH, col, rank);
92 pivs->values[rank++]=col;
96 pivs_srtd = mzp_copy(pivs_srtd,pivs);
97 qsort(pivs_srtd->values, rank,
sizeof(pivs->values[0]), cmp_rci_t);
99 for(
int i=0; i < rank; i++){
101 end = pivs_srtd->values[i];
102 for(
int j = beg; j < end; j++)
103 skip_pivs->values[num++] = j;
105 for(
int j = end + 1 ; j < nvar; j++)
106 skip_pivs->values[num++] = j;
109 if (num + rank != nvar)
110 ERROR(
"mismatch: rank=%d and num=%d do not add to nvar=%d\n",rank,num,nvar);
112 skip_pivs->length = num;
119 mHT = mzd_transpose(mHT,mH);
128 for (
int ir=0; ir< k; ir++){
130 const int col = ee[cnt++] = skip_pivs->values[ir];
131 int limit = nvar + 1;
132 int cur_d = (minW <= nvar) ? minW : 0;
135 limit = minint(limit, cur_d +
p->
dW + 1);
137 limit = minint(limit, cur_d);
141 for(
int ix=0; ix<rank; ix++){
142 if(mzd_read_bit(mH,ix,col))
143 ee[cnt++] = pivs->values[ix];
155 int res = mzd_find_pivot(mH, ix, col, &ix, &ic);
156 if((res)&&(ic==col)){
157 ee[cnt++] = pivs->values[ix++];
166 word * rawrow = mzd_row(mHT,col);
169 j=nextelement(rawrow,mHT->width,j);
172 ee[cnt++] = pivs->values[j++];
177 qsort(ee, cnt,
sizeof(rci_t), cmp_rci_t);
180 if(sparse_syndrome_non_zero(spaH0, cnt, ee)){
181 printf(
"# cw of weight %d: [",cnt);
182 for(
int i=0; i<cnt;i++)
183 printf(
"%d%s",ee[i],i+1==cnt?
" ":
"]\n");
184 ERROR(
"this should not happen: cw not orthogonal to H");
193 nz = sparse_syndrome_non_zero(spaL0, cnt, ee);
199 printf(
"# step=%d row=%d minW=%d found cw of W=%d: [",ii,ir,minW,cnt);
200 const int max = ((cnt<25) || (debug&2048)) ? cnt : 25 ;
201 for(
int i=0; i< max; i++)
202 printf(
"%d%s", ee[i], i+1!=max?
" ": (cnt==max ?
"]\n" :
"...]\n"));
219 printf(
"# round=%d of %d minW=%d\n", ii+1, steps, minW);
241 if (
p->
min_w == INT_MAX) {
244 if (wmax > 0 &&
p->
min_w > wmax) {
cw_vec_t * codeword_add_maybe(params_t *const p, const int arr[], int weight)
Add a candidate codeword to the hash table if it meets weight limits.
long long int nzlist_write(const char fnam[], const char comment[], params_t *p)
Write the found codewords from the hash table to a .nz file.
void var_init(int argc, char **argv, params_t *const p)
Initialize parameters and load matrices from command line arguments.
mzp_t * perm_p_trans(mzp_t *q, const mzp_t *p, const rci_t start)
Apply transposed pivot permutation p to permutation q in-place.