Skip to content

Commit 2bfe83a

Browse files
committed
hmmhmmhmm
1 parent aa4c77a commit 2bfe83a

1 file changed

Lines changed: 24 additions & 29 deletions

File tree

src/debruijn26.c

Lines changed: 24 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ uint3x32_set (uint3x32 *const x,
5151
return x;
5252
}
5353

54-
static const_inline uint3
54+
static const_inline unsigned
5555
uint3x32_get (uint3x32 const *const x,
5656
unsigned const i)
5757
{
58-
return uint3((((uint16_t)x->value[(i+1U & 31U) * 3U >> 3U] << 8U)
59-
| x->value[(i & 31U) * 3U >> 3U]) >> (i & 7U) & 7U);
58+
return (((uint16_t)x->value[(i+1U & 31U) * 3U >> 3U] << 8U)
59+
| x->value[(i & 31U) * 3U >> 3U]) >> (i & 7U) & 7U;
6060
}
6161

6262
#else
@@ -86,11 +86,11 @@ uint3x32_set (uint3x32 *const x,
8686
return x;
8787
}
8888

89-
static const_inline uint3
89+
static const_inline unsigned
9090
uint3x32_get (uint3x32 const *const x,
9191
unsigned const i)
9292
{
93-
return uint3((*x >> (3U * i)) & 7U);
93+
return (*x >> (3U * i)) & 7U;
9494
}
9595
#endif
9696

@@ -203,7 +203,7 @@ main (int c,
203203
printf("%08" PRIx32 "%08" PRIx32 "%08" PRIx32 "\n",
204204
tmp.u32[2], tmp.u32[1], tmp.u32[0]);
205205
uint64_t seq = b26_seq_compose2(&bs);
206-
(void)fprintf(stderr, "0x%016" PRIx64 "\n", seq);
206+
(void)printf("0x%016" PRIx64 "\n", seq);
207207
}
208208
}
209209
}
@@ -214,36 +214,21 @@ main (int c,
214214
b26_data = b26_load(b26_bin_file, false);
215215
if (b26_data) {
216216
for (size_t i = 0; i < 67108834U; ++i) {
217-
struct b26_bits bs = {0};
218-
struct b26_bits_2 bs2 = {0};
219-
if (!b26_decompose2(b26_data[i], &bs2)) {
217+
struct b26_bits_2 bs = {0};
218+
if (!b26_decompose2(b26_data[i], &bs)) {
220219
(void)fprintf(stderr, "can't decompose2"
221220
" 0x%016" PRIx64 " (%zu)"
222221
"\n", b26_data[i], i);
223222
break;
224223
}
225-
if (!b26_decompose(b26_data[i], &bs)) {
226-
(void)fprintf(stderr, "can't decompose"
227-
" 0x%016" PRIx64 " (%zu)"
228-
"\n", b26_data[i], i);
229-
break;
230-
}
231-
uint64_t seq = b26_seq_compose(&bs, 0);
232-
uint64_t seq2 = b26_seq_compose2(&bs2);
233-
if (seq2 != b26_data[i]) {
224+
uint64_t seq = b26_seq_compose2(&bs);
225+
if (seq != b26_data[i]) {
234226
(void)fprintf(stderr, "can't compose2 "
235227
"0x%016" PRIx64 " (%zu)\n",
236228
b26_data[i], i);
237229
break;
238230
}
239-
if (seq != b26_data[i]) {
240-
(void)fprintf(stderr, "can't compose "
241-
"0x%016" PRIx64 " (%zu) "
242-
"from %016" PRIx64 "%016"
243-
PRIx64 "\n", b26_data[i],
244-
i, bs.u64[1], bs.u64[0]);
245-
break;
246-
}
231+
(void)printf("0x%016" PRIx64 "\n", seq);
247232
//printf("%016" PRIx64 "%016" PRIx64 "\n",
248233
// bs.u64[1], bs.u64[0]);
249234
}
@@ -340,12 +325,23 @@ b26_seq_compose2 (struct b26_bits_2 const *const bits)
340325
unsigned i = 32U;
341326
unsigned is_1 = bits->is_1;
342327
do {
343-
uint3 x = uint3x32_get(&bits->data, --i);
328+
unsigned n = uint3x32_get(&bits->data, --i);
344329
seq += is_1;
345-
seq <<= uint3_get(x);
330+
seq <<= n;
346331
seq -= is_1;
332+
printf("\033[%c;3%cm\xe2\x96%c", (char)('0'+is_1),
333+
(char)('0'+n+(n<6U)), (char)(0x80+n));
334+
is_1 ^= 1U;
335+
} while (i);
336+
puts("\033[m");
337+
i = 32U;
338+
is_1 = bits->is_1;
339+
do {
340+
unsigned n = uint3x32_get(&bits->data, --i);
341+
putchar('0' + (int)n);
347342
is_1 ^= 1U;
348343
} while (i);
344+
putchar('\n');
349345
return rol(seq, bits->wrap);
350346
}
351347

@@ -417,7 +413,6 @@ static bool
417413
b26_decompose2 (uint64_t seq,
418414
struct b26_bits_2 *const bits)
419415
{
420-
(void)printf("0x%016" PRIx64 "\n", seq);
421416
struct b26_bitcount bc = {0};
422417
unsigned nbit = count_msb_0(seq);
423418
unsigned is_1 = !nbit;

0 commit comments

Comments
 (0)