bool symmetry_group_walker::nextsub (int g) { bool of = next_perm (perms[g]); if (of && g > 0) of = nextsub (g - 1); return of; }
static int weight_of_linear_combinations(MINDIST *MD, int l) //evaluate minimum-weight of all codevectors that are constructed //by linearcombinations of $l$ rows of matrix $S[1],...,S[M]$ //algorithm: create all possibilities for combining $l$ rows out of $k$ //possible matrix rows by constructing the $l$-element- //subsets over $\{1,...,k\}$; //create all possibilities for filling an $l$-element-subset by //$\{1,...,p\}$ while construct the p-adic numbers of $0,...,lc$ //($lc$ = number of possibilities for filling); //combining the two results gives all possibilities of linear- //combinations of $l$ matrix-rows; //out of this construct the codevectors and //calculate minimumweight //$l$ = \# rows taken for linearcombination // needed: weight(int *p, n, idx\_zero) { int n = MD->n; int k = MD->k; int q = MD->q; int M = MD->M; int d1; int d_l; /* minimum-weight by combining l rows */ int lc, dec, h; int i, j, z, w; int *v,*linc,*lcv; int *sub; /* for l = 1 the weight of a multiple of a generating codevector is equal to the weight of that codevector (p = prim) */ /* allocate array for l-subset of a k-set */ sub = (int *)calloc(k+1,sizeof (int)); d_l = n; if (l == 1) { for (z=1;z<=M;z++) { for (i=1;i<=k;i++) { if (MD->Size[z] > 0) { d1 = weight(MD->S[z][i], n, MD->idx_zero); MD->weight_computations++; if (d1 > 0) { d_l = MINIMUM(d_l,d1); if (MD->f_vv) { cout << "matrix " << z << " row " << i << " is "; for (j=1;j <=n;j++) cout << MD->S[z][i][j] << " "; cout << " of weight " << d1 << " minimum is " << d_l << endl; } } } // if } // next z } // next i free(sub); return(d_l); } /* construct codevectors by linear combinations of l rows of the generator matrices and calculate their weight */ else { /* allocate memory for help-pointers */ v = (int*)calloc(l+2,sizeof(int)); linc = (int*)calloc(k+2,sizeof(int)); lcv = (int*)calloc(n+2,sizeof(int)); lc = i_power_j(q-1, l); #if 0 lc = expo(p-1,l); /* number of possibilities to replace one * subset with entries 1,...,p-1 */ #endif /* If the l-subset is b_1,...,b_l, then form the linear combination of the rows b_i times v[i] */ for (dec = 1; dec <= lc; dec++) { padic(dec, v, l, q-1); /* for each systematic-generator-matrix S[z] */ for (z=1;z<=M;z++) { int K = MD->Size[z]; if (K<l) continue; /* initialize with set: 1,2,...,l */ for (i=1;i<=l;i++) sub[i] = i; /* for (i=1;i<=l;i++) printf("%d ",sub[i]); printf("\n"); */ do { /* for (i=1;i<=l;i++) printf("%d ",sub[i]); */ h = 1; for (j=1;j<=K;j++) { if (j == sub[h]) { linc[j] = v[h-1]+1; if (h != l) h = h+1; } /* if */ else linc[j] = 0; } /* j */ /* construct the corresponding codevector lcv */ vmmult(MD, linc, MD->S[z], lcv); /* calculate its weight and store if minimal */ w = weight(lcv, n, MD->idx_zero); MD->weight_computations++; d_l = MINIMUM(d_l,w); if (MD->f_vv) { for (i=1;i <=k;i++) cout << linc[i] << " "; cout << " : "; for (i=1;i <=n;i++) cout << lcv[i] << " "; cout << " of weight " << w << " minimum is " << d_l << endl; } } while (nextsub(K,l,sub)); /* next l-subset of K-set */ } /* z */ } /* dec */ free(v); free(linc); free(lcv); free(sub); return(d_l); } /* else */ }