in lattices/lattice_utils.cpp [170:201]
static void repeats_decode_64(
const std::vector<Repeat> & repeats,
int dim, uint64_t code, float *c)
{
uint64_t decoded = 0;
int nfree = dim;
for (auto r = repeats.begin(); r != repeats.end(); ++r) {
uint64_t max_comb = comb(nfree, r->n);
uint64_t code_comb = code % max_comb;
code /= max_comb;
int occ = 0;
int rank = nfree;
int next_rank = decode_comb_1 (&code_comb, r->n, rank);
uint64_t tosee = ((1UL << dim) - 1) ^ decoded;
for(;;) {
int i = 63 - __builtin_clzl(tosee);
tosee &= ~(1UL << i);
rank--;
if (rank == next_rank) {
decoded |= 1UL << i;
c[i] = r->val;
occ++;
if (occ == r->n) break;
next_rank = decode_comb_1 (
&code_comb, r->n - occ, next_rank);
}
}
nfree -= r->n;
}
}