From 61e03f9f4eecf3d5811b11c44c9ef778f0a93bc7 Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Sun, 14 Jul 2024 21:28:37 +0200 Subject: Found a sneaky bug (it's all a mess now) --- Makefile | 2 +- TODO.txt | 9 ++ src/solve_h48.h | 40 ++++-- test/101_cocsep_selfsim/00_all.in | 2 - test/101_cocsep_selfsim/00_all.out | 2 - test/101_cocsep_selfsim/cocsep_selfsim_tests.c | 38 ----- test/101_cocsep_transform_invariant/00_solved.in | 1 + test/101_cocsep_transform_invariant/00_solved.out | 0 test/101_cocsep_transform_invariant/01_U.in | 1 + test/101_cocsep_transform_invariant/01_U.out | 0 .../101_cocsep_transform_invariant/02_scrambled.in | 1 + .../02_scrambled.out | 0 .../cocsep_transform_invariant.c | 33 +++++ test/102_cocsep_selfsim/00_all.in | 2 + test/102_cocsep_selfsim/00_all.out | 2 + test/102_cocsep_selfsim/cocsep_selfsim_tests.c | 38 +++++ test/102_coord_invcoord_h48/00_all.in | 8 -- test/102_coord_invcoord_h48/00_all.out | 8 -- .../coord_invcoord_h48_tests.c | 36 ----- test/103_cocsep_ttrep/00_all.in | 0 test/103_cocsep_ttrep/00_all.out | 0 test/103_cocsep_ttrep/cocsep_ttrep_tests.c | 33 +++++ test/103_gendata_h48_h0/00_h_0.in | 0 test/103_gendata_h48_h0/00_h_0.out | 23 ---- test/103_gendata_h48_h0/gendata_h48_tests.c | 33 ----- test/104_h48set/00_small.in | 6 - test/104_h48set/00_small.out | 3 - test/104_h48set/01_large.in | 153 --------------------- test/104_h48set/01_large.out | 83 ----------- test/104_h48set/h48set_tests.c | 64 --------- test/110_coord_invcoord_h48/00_all.in | 8 ++ test/110_coord_invcoord_h48/00_all.out | 8 ++ .../coord_invcoord_h48_tests.c | 36 +++++ test/111_gendata_h48_h0/00_h_0.in | 0 test/111_gendata_h48_h0/00_h_0.out | 23 ++++ test/111_gendata_h48_h0/gendata_h48_tests.c | 33 +++++ test/112_h48set/00_small.in | 6 + test/112_h48set/00_small.out | 3 + test/112_h48set/01_large.in | 153 +++++++++++++++++++++ test/112_h48set/01_large.out | 83 +++++++++++ test/112_h48set/h48set_tests.c | 64 +++++++++ 41 files changed, 569 insertions(+), 469 deletions(-) delete mode 100644 test/101_cocsep_selfsim/00_all.in delete mode 100644 test/101_cocsep_selfsim/00_all.out delete mode 100644 test/101_cocsep_selfsim/cocsep_selfsim_tests.c create mode 100644 test/101_cocsep_transform_invariant/00_solved.in create mode 100644 test/101_cocsep_transform_invariant/00_solved.out create mode 100644 test/101_cocsep_transform_invariant/01_U.in create mode 100644 test/101_cocsep_transform_invariant/01_U.out create mode 100644 test/101_cocsep_transform_invariant/02_scrambled.in create mode 100644 test/101_cocsep_transform_invariant/02_scrambled.out create mode 100644 test/101_cocsep_transform_invariant/cocsep_transform_invariant.c create mode 100644 test/102_cocsep_selfsim/00_all.in create mode 100644 test/102_cocsep_selfsim/00_all.out create mode 100644 test/102_cocsep_selfsim/cocsep_selfsim_tests.c delete mode 100644 test/102_coord_invcoord_h48/00_all.in delete mode 100644 test/102_coord_invcoord_h48/00_all.out delete mode 100644 test/102_coord_invcoord_h48/coord_invcoord_h48_tests.c create mode 100644 test/103_cocsep_ttrep/00_all.in create mode 100644 test/103_cocsep_ttrep/00_all.out create mode 100644 test/103_cocsep_ttrep/cocsep_ttrep_tests.c delete mode 100644 test/103_gendata_h48_h0/00_h_0.in delete mode 100644 test/103_gendata_h48_h0/00_h_0.out delete mode 100644 test/103_gendata_h48_h0/gendata_h48_tests.c delete mode 100644 test/104_h48set/00_small.in delete mode 100644 test/104_h48set/00_small.out delete mode 100644 test/104_h48set/01_large.in delete mode 100644 test/104_h48set/01_large.out delete mode 100644 test/104_h48set/h48set_tests.c create mode 100644 test/110_coord_invcoord_h48/00_all.in create mode 100644 test/110_coord_invcoord_h48/00_all.out create mode 100644 test/110_coord_invcoord_h48/coord_invcoord_h48_tests.c create mode 100644 test/111_gendata_h48_h0/00_h_0.in create mode 100644 test/111_gendata_h48_h0/00_h_0.out create mode 100644 test/111_gendata_h48_h0/gendata_h48_tests.c create mode 100644 test/112_h48set/00_small.in create mode 100644 test/112_h48set/00_small.out create mode 100644 test/112_h48set/01_large.in create mode 100644 test/112_h48set/01_large.out create mode 100644 test/112_h48set/h48set_tests.c diff --git a/Makefile b/Makefile index 8ff5f47..5130940 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ clean: rm -rf *.o run test: debugcube.o - CC="${CC} ${DBGFLAGS}" ./test/test.sh + CC="${CC} -D${CUBETYPE} ${DBGFLAGS}" ./test/test.sh tool: cube.o mkdir -p tools/results diff --git a/TODO.txt b/TODO.txt index 46c1656..6ca924a 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,3 +1,12 @@ +Bug in cocsepdata + - Add tests for ttrep + - check that ttrep indeed brings to representative + - Fix? + - Once fixed, fix other tests + - maybe add longtest, e.g. as a tool? + - Clean up mixed bfs fromdone / fromnew, use as new for h0k4 + - Re-do stats + Check stats for all tables using H48stats solver - try DFS for h0 solver - compare results, the bfs method could be wrong diff --git a/src/solve_h48.h b/src/solve_h48.h index 26cbc73..c3316e1 100644 --- a/src/solve_h48.h +++ b/src/solve_h48.h @@ -244,7 +244,7 @@ invcoord_h48(int64_t i, const cube_t *crep, uint8_t h) /* Each element of the cocsep table is a uint32_t used as follows: - Lowest 8-bit block: pruning value - - Second-lower 8-bit block: "ttrep" (transformation to representative) + - Second-lowest 8-bit block: "ttrep" (transformation to representative) - Top 16-bit block: symcoord value After the data as described above, more auxiliary information is appended: - A uint32_t representing the number of symmetry classes @@ -331,7 +331,7 @@ gendata_cocsep_dfs(dfsarg_cocsep_t *arg) if (arg->selfsim != NULL) arg->selfsim[*arg->n] |= is << t; set_visited(arg->visited, j); - tinv = inverse_trans(t); + tinv = inverse_trans(t) * (1-is); olddepth = (uint8_t)(arg->buf32[j] & 0xFF); cc += olddepth == 0xFF; @@ -425,13 +425,12 @@ gendata_h48h0k4_bfs(bfsarg_esep_t *arg) TODO: the new method gives a slightly different answer. If the new method is correct, then the old bfs method is wrong. Which one is it? Try also DFS and compare results (it could be faster). -/* +*/ if (2 * arg->done < (int64_t)ESEP_MAX(0)) return gendata_h48h0k4_bfs_fromdone(arg); else return gendata_h48h0k4_bfs_fromnew(arg); -*/ - return gendata_h48h0k4_bfs_fromdone(arg); +// return gendata_h48h0k4_bfs_fromnew(arg); } _static int64_t @@ -439,7 +438,8 @@ gendata_h48h0k4_bfs_fromdone(bfsarg_esep_t *arg) { uint8_t c, m, x; uint32_t cc; - int64_t i, j, k, t, cocsep_coord, sim; + int64_t i, j, k, t, cocsep_coord; + uint64_t sim; cube_t cube, moved, transd; for (i = 0, cc = 0; i < (int64_t)ESEP_MAX(0); i++) { @@ -461,10 +461,29 @@ gendata_h48h0k4_bfs_fromdone(bfsarg_esep_t *arg) set_esep_pval(arg->buf32, j, arg->depth); cc += x != arg->depth; cocsep_coord = j / H48_ESIZE(0); - sim = arg->selfsim[cocsep_coord] >> 1; - for (t = 1; t < 48 && sim; t++, sim >>= 1) { - if (!(sim & 1)) + sim = arg->selfsim[cocsep_coord] >> UINT64_C(1); + for (t = 1; t < 48 && sim; t++, sim >>= UINT64_C(1)) { + if (!(sim & UINT64_C(1))) { + transd = transform(moved, t); + k = coord_h48(transd, arg->cocsepdata, 0); + if (k != j) { +LOG("t=%" PRId64 ", tinv=%" PRIu8 "\n", t, inverse_trans(t)); +int64_t ccm = coord_cocsep(moved); +int64_t repm = coord_cocsep(arg->crep[j/H48_ESIZE(0)]); +LOG("moved: full %" PRId64 ", cocsep %" PRId64 ", rep %" PRId64 ", ttrep %" PRId32 "\n", j, ccm, repm, TTREP(arg->cocsepdata[ccm])); +int64_t cct = coord_cocsep(transd); +int64_t rept = coord_cocsep(arg->crep[k/H48_ESIZE(0)]); +LOG("moved: full %" PRId64 ", cocsep %" PRId64 ", rep %" PRId64 ", ttrep %" PRId32 "\n", j, cct, rept, TTREP(arg->cocsepdata[cct])); +/* + char q[150]; + writecube_H48(moved, q); + LOG("%s\n", q) + writecube_H48(transd, q); + LOG("%s\n", q) +*/ + } continue; + } transd = transform(moved, t); k = coord_h48(transd, arg->cocsepdata, 0); x = get_esep_pval(arg->buf32, k); @@ -497,7 +516,10 @@ gendata_h48h0k4_bfs_fromnew(bfsarg_esep_t *arg) j = coord_h48(moved, arg->cocsepdata, 0); x = get_esep_pval(arg->buf32, j); if (x < arg->depth) +{ +if (x < arg->depth -1) LOG("WAT %" PRIu8 " while scanning %" PRIu8 "\n",x, arg->depth); goto neighbor_found; +} } continue; neighbor_found: diff --git a/test/101_cocsep_selfsim/00_all.in b/test/101_cocsep_selfsim/00_all.in deleted file mode 100644 index 07bda04..0000000 --- a/test/101_cocsep_selfsim/00_all.in +++ /dev/null @@ -1,2 +0,0 @@ -UF0 UB0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 -UF0 UB0 DB0 DF0 FR0 UL0 DL0 BR0 DR0 FL0 BL0 UR0 DFR2 UBL0 DFL0 UBR2 UFL0 UFR1 DBR1 DBL0 diff --git a/test/101_cocsep_selfsim/00_all.out b/test/101_cocsep_selfsim/00_all.out deleted file mode 100644 index cc96363..0000000 --- a/test/101_cocsep_selfsim/00_all.out +++ /dev/null @@ -1,2 +0,0 @@ -0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 -0 1 2 3 24 25 26 27 diff --git a/test/101_cocsep_selfsim/cocsep_selfsim_tests.c b/test/101_cocsep_selfsim/cocsep_selfsim_tests.c deleted file mode 100644 index 9d9a8b2..0000000 --- a/test/101_cocsep_selfsim/cocsep_selfsim_tests.c +++ /dev/null @@ -1,38 +0,0 @@ -/* - * This test is tricky, we only have two cases for now: the solved cube - * and the cube that is one quarter-turn-move off (all such cases are - * equivalent due to symmetry). Adding more tests requires figuring out - * by hand which one is the first position in its class to be reached. - * Note that the .out file need a space before each newline. - */ -#include "../test.h" - -#define COCSEP_CLASSES 3393 - -size_t gendata_cocsep(void *, uint64_t *, cube_t *); -int64_t coord_cocsep(cube_t); - -void run(void) { - char str[STRLENMAX]; - uint32_t buf[300000], data; - int64_t coord, coclass; - uint64_t selfsim[COCSEP_CLASSES], sim, t; - cube_t cube, rep[COCSEP_CLASSES]; - - gendata_cocsep(buf, selfsim, rep); - - /* All cases in the same test so we do not generate data many times */ - - while (fgets(str, STRLENMAX, stdin) != NULL) { - cube = readcube("H48", str); - coord = coord_cocsep(cube); - data = buf[coord]; - coclass = (data & (0xFFFU << 16)) >> 16; - sim = selfsim[coclass]; - for (t = 0; t < 48 && sim; t++, sim >>= 1) { - if (sim & 1) - printf("%" PRId64 " ", t); - } - printf("\n"); - } -} diff --git a/test/101_cocsep_transform_invariant/00_solved.in b/test/101_cocsep_transform_invariant/00_solved.in new file mode 100644 index 0000000..dff224d --- /dev/null +++ b/test/101_cocsep_transform_invariant/00_solved.in @@ -0,0 +1 @@ +UF0 UB0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 diff --git a/test/101_cocsep_transform_invariant/00_solved.out b/test/101_cocsep_transform_invariant/00_solved.out new file mode 100644 index 0000000..e69de29 diff --git a/test/101_cocsep_transform_invariant/01_U.in b/test/101_cocsep_transform_invariant/01_U.in new file mode 100644 index 0000000..b5b36ad --- /dev/null +++ b/test/101_cocsep_transform_invariant/01_U.in @@ -0,0 +1 @@ +UR0 UL0 DB0 DF0 UB0 UF0 DL0 DR0 FR0 FL0 BL0 BR0 UBR0 UFL0 DFL0 DBR0 UFR0 UBL0 DFR0 DBL0 diff --git a/test/101_cocsep_transform_invariant/01_U.out b/test/101_cocsep_transform_invariant/01_U.out new file mode 100644 index 0000000..e69de29 diff --git a/test/101_cocsep_transform_invariant/02_scrambled.in b/test/101_cocsep_transform_invariant/02_scrambled.in new file mode 100644 index 0000000..f6e1f48 --- /dev/null +++ b/test/101_cocsep_transform_invariant/02_scrambled.in @@ -0,0 +1 @@ +DL1 BR0 DR0 UR1 DF0 FL1 BL0 UL0 FR0 UF0 DB1 UB0 UFR0 DBL1 DBR0 UFL1 DFR1 DFL1 UBL2 UBR0 diff --git a/test/101_cocsep_transform_invariant/02_scrambled.out b/test/101_cocsep_transform_invariant/02_scrambled.out new file mode 100644 index 0000000..e69de29 diff --git a/test/101_cocsep_transform_invariant/cocsep_transform_invariant.c b/test/101_cocsep_transform_invariant/cocsep_transform_invariant.c new file mode 100644 index 0000000..b0286e5 --- /dev/null +++ b/test/101_cocsep_transform_invariant/cocsep_transform_invariant.c @@ -0,0 +1,33 @@ +#include "../test.h" + +#define COCLASS_MASK (UINT32_C(0xFFFF) << UINT32_C(16)) +#define COCLASS(x) (((x) & COCLASS_MASK) >> UINT32_C(16)) + +#define COCSEP_CLASSES 3393 + +size_t gendata_cocsep(void *, uint64_t *, cube_t *); +cube_t transform(cube_t, uint8_t); +int64_t coord_cocsep(cube_t); + +void run(void) { + uint8_t t; + uint32_t buf[300000]; + uint64_t selfsim[COCSEP_CLASSES]; + int64_t coord, tcoord; + char str[STRLENMAX]; + cube_t cube, transd, rep[COCSEP_CLASSES]; + + fgets(str, STRLENMAX, stdin); + cube = readcube("H48", str); + + gendata_cocsep(buf, selfsim, rep); + + coord = (int64_t)COCLASS(buf[coord_cocsep(cube)]); + for (t = 0; t < 48; t++) { + transd = transform(cube, t); + tcoord = (int64_t)COCLASS(buf[coord_cocsep(transd)]); + if (coord != tcoord) + printf("Error: expected %" PRId64 + " but got %" PRId64 "\n", coord, tcoord); + } +} diff --git a/test/102_cocsep_selfsim/00_all.in b/test/102_cocsep_selfsim/00_all.in new file mode 100644 index 0000000..07bda04 --- /dev/null +++ b/test/102_cocsep_selfsim/00_all.in @@ -0,0 +1,2 @@ +UF0 UB0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 +UF0 UB0 DB0 DF0 FR0 UL0 DL0 BR0 DR0 FL0 BL0 UR0 DFR2 UBL0 DFL0 UBR2 UFL0 UFR1 DBR1 DBL0 diff --git a/test/102_cocsep_selfsim/00_all.out b/test/102_cocsep_selfsim/00_all.out new file mode 100644 index 0000000..cc96363 --- /dev/null +++ b/test/102_cocsep_selfsim/00_all.out @@ -0,0 +1,2 @@ +0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 +0 1 2 3 24 25 26 27 diff --git a/test/102_cocsep_selfsim/cocsep_selfsim_tests.c b/test/102_cocsep_selfsim/cocsep_selfsim_tests.c new file mode 100644 index 0000000..7211e2e --- /dev/null +++ b/test/102_cocsep_selfsim/cocsep_selfsim_tests.c @@ -0,0 +1,38 @@ +/* + * This test is tricky, we only have two cases for now: the solved cube + * and the cube that is one quarter-turn-move off (all such cases are + * equivalent due to symmetry). Adding more tests requires figuring out + * by hand which one is the first position in its class to be reached. + * Note that the .out files need a space before each newline. + */ +#include "../test.h" + +#define COCSEP_CLASSES 3393 + +size_t gendata_cocsep(void *, uint64_t *, cube_t *); +int64_t coord_cocsep(cube_t); + +void run(void) { + char str[STRLENMAX]; + uint32_t buf[300000], data; + int64_t coord, coclass; + uint64_t selfsim[COCSEP_CLASSES], sim, t; + cube_t cube, rep[COCSEP_CLASSES]; + + gendata_cocsep(buf, selfsim, rep); + + /* All cases in the same test so we do not generate data many times */ + + while (fgets(str, STRLENMAX, stdin) != NULL) { + cube = readcube("H48", str); + coord = coord_cocsep(cube); + data = buf[coord]; + coclass = (data & (0xFFFU << 16)) >> 16; + sim = selfsim[coclass]; + for (t = 0; t < 48 && sim; t++, sim >>= 1) { + if (sim & 1) + printf("%" PRId64 " ", t); + } + printf("\n"); + } +} diff --git a/test/102_coord_invcoord_h48/00_all.in b/test/102_coord_invcoord_h48/00_all.in deleted file mode 100644 index a2f9540..0000000 --- a/test/102_coord_invcoord_h48/00_all.in +++ /dev/null @@ -1,8 +0,0 @@ -UB0 DF0 DB0 UF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 -UF0 UB0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 -UB0 UF0 DB0 DF0 UL0 UR0 DL0 DR0 FR0 FL0 BL0 BR0 UBL0 UFR0 DFL0 DBR0 UBR0 UFL0 DFR0 DBL0 -UL0 BL0 BR1 DL0 FR0 DF0 DB1 DR1 UB0 FL0 UF0 UR1 DFL0 UFR1 DBR1 UBR2 DBL2 DFR0 UFL1 UBL2 -UF0 UB0 DB0 DF0 FR0 UL0 DL0 BR0 DR0 FL0 BL0 UR0 DFR2 UBL0 DFL0 UBR2 UFL0 UFR1 DBR1 DBL0 -FL1 UB0 DB0 FR1 UR0 UL0 DL0 DR0 UF1 DF1 BL0 BR0 UFL1 UBL0 DFR1 DBR0 DFL2 UBR0 UFR2 DBL0 -FR0 BR0 BL0 FL0 UR0 UL0 DL0 DR0 DF0 UF0 UB0 DB0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 -UR0 UL0 DL0 DR0 UB0 UF0 DF0 DB0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 diff --git a/test/102_coord_invcoord_h48/00_all.out b/test/102_coord_invcoord_h48/00_all.out deleted file mode 100644 index e84be4b..0000000 --- a/test/102_coord_invcoord_h48/00_all.out +++ /dev/null @@ -1,8 +0,0 @@ -1 ok -2 ok -3 ok -4 ok -5 ok -6 ok -7 ok -8 ok diff --git a/test/102_coord_invcoord_h48/coord_invcoord_h48_tests.c b/test/102_coord_invcoord_h48/coord_invcoord_h48_tests.c deleted file mode 100644 index 77dea81..0000000 --- a/test/102_coord_invcoord_h48/coord_invcoord_h48_tests.c +++ /dev/null @@ -1,36 +0,0 @@ -#include "../test.h" - -#define COCSEP_CLASSES 3393 - -size_t gendata_cocsep(void *, uint64_t *, cube_t *); -int64_t coord_h48(cube_t, const uint32_t *, uint8_t); -cube_t invcoord_h48(int64_t, const cube_t *, uint8_t); -cube_t transform(cube_t, uint8_t); - -void run(void) { - char str[STRLENMAX]; - int i; - bool found; - uint8_t h, t; - uint32_t cocsepdata[300000]; - uint64_t selfsim[COCSEP_CLASSES]; - int64_t c, cc; - cube_t cube, invc, rep[COCSEP_CLASSES]; - - gendata_cocsep(cocsepdata, selfsim, rep); - - i = 1; - h = 11; - while (fgets(str, STRLENMAX, stdin) != NULL) { - cube = readcube("H48", str); - c = coord_h48(cube, cocsepdata, h); - invc = invcoord_h48(c, rep, h); - for (t = 0, found = false; t < 48; t++) { - cube = transform(invc, t); - cc = coord_h48(cube, cocsepdata, h); - found = found || cc == c; - } - printf("%d %s\n", i, found ? "ok" : "ERROR"); - i++; - } -} diff --git a/test/103_cocsep_ttrep/00_all.in b/test/103_cocsep_ttrep/00_all.in new file mode 100644 index 0000000..e69de29 diff --git a/test/103_cocsep_ttrep/00_all.out b/test/103_cocsep_ttrep/00_all.out new file mode 100644 index 0000000..e69de29 diff --git a/test/103_cocsep_ttrep/cocsep_ttrep_tests.c b/test/103_cocsep_ttrep/cocsep_ttrep_tests.c new file mode 100644 index 0000000..78f8014 --- /dev/null +++ b/test/103_cocsep_ttrep/cocsep_ttrep_tests.c @@ -0,0 +1,33 @@ +#include "../test.h" + +#define COCSEP_CLASSES 3393 + +uint8_t inverse_trans(uint8_t); +cube_t transform_corners(cube_t); +int64_t coord_cocsep(cube_t); +size_t gendata_cocsep(void *, uint64_t *, cube_t *); + +void run(void) { + uint8_t t, tinv; + uint32_t buf[300000], tt; + uint64_t selfsim[COCSEP_CLASSES]; + int64_t i, j; + cube_t rep[COCSEP_CLASSES], c, d; + + gendata_cocsep(buf, selfsim, rep); + + for (i = 0; i < COCSEP_CLASSES; i++) { + c = rep[i]; + for (t = 0; t < 48; t++) { + tinv = inverse_trans(t); + d = transform_corners(c); + j = coord_cocsep(d); + tt = (buf[j] & (0xFF << 8)) >> 8; + if (tt != tinv) + printf("cocsep %" PRId64 " <- %" PRId64 ": " + "expected t %" PRIu8 " (inverse of %" + PRIu8 "), got %" PRIu32 "\n", + i, j, tinv, t, tt); + } + } +} diff --git a/test/103_gendata_h48_h0/00_h_0.in b/test/103_gendata_h48_h0/00_h_0.in deleted file mode 100644 index e69de29..0000000 diff --git a/test/103_gendata_h48_h0/00_h_0.out b/test/103_gendata_h48_h0/00_h_0.out deleted file mode 100644 index cc5cf9b..0000000 --- a/test/103_gendata_h48_h0/00_h_0.out +++ /dev/null @@ -1,23 +0,0 @@ -59903605 - -cocsepdata: -Classes: 3393 -Max value: 9 -0: 1 -1: 6 -2: 63 -3: 468 -4: 3068 -5: 15438 -6: 53814 -7: 71352 -8: 8784 -9: 96 - -h48: -0: 1 -1: 1 -2: 4 -3: 34 -4: 329 -5: 3587 diff --git a/test/103_gendata_h48_h0/gendata_h48_tests.c b/test/103_gendata_h48_h0/gendata_h48_tests.c deleted file mode 100644 index e9de3c0..0000000 --- a/test/103_gendata_h48_h0/gendata_h48_tests.c +++ /dev/null @@ -1,33 +0,0 @@ -#include "../test.h" - -#define MAXDEPTH 5 -#define COCSEPSIZE 1119792 -#define ETABLESIZE ((3393 * 495 * 70) >> 1) - -int64_t gendata_h48h0k4(void *, uint8_t); - -void run(void) { - char str[STRLENMAX]; - uint8_t i; - uint32_t *buf, *h48info; - size_t result; - - fgets(str, STRLENMAX, stdin); - buf = (uint32_t *)malloc(sizeof(uint32_t) * 60000000); - result = gendata_h48h0k4(buf, MAXDEPTH); - h48info = buf + (ETABLESIZE + COCSEPSIZE) / 4; - - printf("%zu\n\n", result); - - printf("cocsepdata:\n"); - printf("Classes: %" PRIu32 "\n", buf[COCSEPSIZE/4-12]); - printf("Max value: %" PRIu32 "\n", buf[COCSEPSIZE/4-11]); - for (i = 0; i < 10; i++) - printf("%" PRIu32 ": %" PRIu32 "\n", i, buf[COCSEPSIZE/4-10+i]); - - printf("\nh48:\n"); - for (i = 0; i < MAXDEPTH+1; i++) - printf("%" PRIu32 ": %" PRIu32 "\n", i, h48info[i+1]); - - free(buf); -} diff --git a/test/104_h48set/00_small.in b/test/104_h48set/00_small.in deleted file mode 100644 index d788d5b..0000000 --- a/test/104_h48set/00_small.in +++ /dev/null @@ -1,6 +0,0 @@ -11 -7 -3 -34 -45 -34 diff --git a/test/104_h48set/00_small.out b/test/104_h48set/00_small.out deleted file mode 100644 index 29c08e5..0000000 --- a/test/104_h48set/00_small.out +++ /dev/null @@ -1,3 +0,0 @@ -2 -34 -45 diff --git a/test/104_h48set/01_large.in b/test/104_h48set/01_large.in deleted file mode 100644 index a70ef9a..0000000 --- a/test/104_h48set/01_large.in +++ /dev/null @@ -1,153 +0,0 @@ -307 -293 -150 -100053 -100045 -100007 -100007 -100011 -100072 -100033 -100015 -100013 -100068 -100047 -100046 -100000 -100076 -100021 -100019 -100015 -100049 -100052 -100071 -100058 -100009 -100060 -100030 -100051 -100069 -100011 -100051 -100014 -100031 -100017 -100076 -100016 -100030 -100037 -100011 -100002 -100029 -100022 -100038 -100075 -100066 -100051 -100020 -100039 -100029 -100087 -100099 -100041 -100042 -100026 -100060 -100006 -100010 -100079 -100046 -100086 -100010 -100036 -100047 -100069 -100041 -100074 -100090 -100092 -100020 -100096 -100046 -100028 -100072 -100096 -100025 -100001 -100067 -100044 -100063 -100026 -100062 -100091 -100012 -100073 -100051 -100010 -100096 -100043 -100025 -100077 -100089 -100005 -100024 -100091 -100046 -100053 -100058 -100065 -100051 -100056 -100025 -100093 -100088 -100033 -100073 -100048 -100059 -100027 -100045 -100012 -100059 -100084 -100017 -100048 -100004 -100051 -100016 -100088 -100033 -100064 -100060 -100043 -100084 -100026 -100051 -100060 -100069 -100015 -100014 -100038 -100068 -100038 -100097 -100017 -100013 -100053 -100019 -100018 -100081 -100071 -100025 -100014 -100016 -100011 -100069 -100079 -100063 -100070 -100072 -100095 -100042 -100008 -100022 diff --git a/test/104_h48set/01_large.out b/test/104_h48set/01_large.out deleted file mode 100644 index 6632336..0000000 --- a/test/104_h48set/01_large.out +++ /dev/null @@ -1,83 +0,0 @@ -82 -100000 -100001 -100002 -100004 -100005 -100006 -100007 -100008 -100009 -100010 -100011 -100012 -100013 -100014 -100015 -100016 -100017 -100018 -100019 -100020 -100021 -100022 -100024 -100025 -100026 -100027 -100028 -100029 -100030 -100031 -100033 -100036 -100037 -100038 -100039 -100041 -100042 -100043 -100044 -100045 -100046 -100047 -100048 -100049 -100051 -100052 -100053 -100056 -100058 -100059 -100060 -100062 -100063 -100064 -100065 -100066 -100067 -100068 -100069 -100070 -100071 -100072 -100073 -100074 -100075 -100076 -100077 -100079 -100081 -100084 -100086 -100087 -100088 -100089 -100090 -100091 -100092 -100093 -100095 -100096 -100097 -100099 diff --git a/test/104_h48set/h48set_tests.c b/test/104_h48set/h48set_tests.c deleted file mode 100644 index d9310a9..0000000 --- a/test/104_h48set/h48set_tests.c +++ /dev/null @@ -1,64 +0,0 @@ -#include "../test.h" - -char str[STRLENMAX]; - -typedef struct { - int64_t n; - int64_t capacity; - int64_t mod; - int64_t *table; -} h48set_t; - -void h48set_create(h48set_t *, int64_t, int64_t); -void h48set_clear(h48set_t *); -void h48set_destroy(h48set_t *); -int64_t h48set_lookup(h48set_t *, int64_t); -void h48set_insert(h48set_t *, int64_t); -bool h48set_contains(h48set_t *, int64_t); -int64_t h48set_save(h48set_t *, int64_t *); - -int compare(const void *x, const void *y) { - int64_t a = *(int64_t *)x; - int64_t b = *(int64_t *)y; - - if (a > b) return 1; - if (a == b) return 0; - return -1; -} - -int64_t readl(void) { - fgets(str, STRLENMAX, stdin); - return atoll(str); -} - -void run(void) { - h48set_t set; - int64_t n, i, k, capacity, mod, *a, *b; - - capacity = readl(); - mod = readl(); - n = readl(); - - a = malloc(n * sizeof(int64_t)); - b = malloc(n * sizeof(int64_t)); - for (i = 0; i < n; i++) - a[i] = readl(); - - h48set_create(&set, capacity, mod); - for (i = 0; i < n; i++) - h48set_insert(&set, a[i]); - - k = h48set_save(&set, b); - qsort(b, k, sizeof(int64_t), compare); - - printf("%" PRId64 "\n", k); - for (i = 0; i < k; i++) - printf("%" PRId64 "\n", b[i]); - for (i = 0; i < n; i++) - if (!h48set_contains(&set, a[i])) - printf("Set does not contain %" PRId64 "\n", a[i]); - - h48set_destroy(&set); - free(a); - free(b); -} diff --git a/test/110_coord_invcoord_h48/00_all.in b/test/110_coord_invcoord_h48/00_all.in new file mode 100644 index 0000000..a2f9540 --- /dev/null +++ b/test/110_coord_invcoord_h48/00_all.in @@ -0,0 +1,8 @@ +UB0 DF0 DB0 UF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 +UF0 UB0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 +UB0 UF0 DB0 DF0 UL0 UR0 DL0 DR0 FR0 FL0 BL0 BR0 UBL0 UFR0 DFL0 DBR0 UBR0 UFL0 DFR0 DBL0 +UL0 BL0 BR1 DL0 FR0 DF0 DB1 DR1 UB0 FL0 UF0 UR1 DFL0 UFR1 DBR1 UBR2 DBL2 DFR0 UFL1 UBL2 +UF0 UB0 DB0 DF0 FR0 UL0 DL0 BR0 DR0 FL0 BL0 UR0 DFR2 UBL0 DFL0 UBR2 UFL0 UFR1 DBR1 DBL0 +FL1 UB0 DB0 FR1 UR0 UL0 DL0 DR0 UF1 DF1 BL0 BR0 UFL1 UBL0 DFR1 DBR0 DFL2 UBR0 UFR2 DBL0 +FR0 BR0 BL0 FL0 UR0 UL0 DL0 DR0 DF0 UF0 UB0 DB0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 +UR0 UL0 DL0 DR0 UB0 UF0 DF0 DB0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 diff --git a/test/110_coord_invcoord_h48/00_all.out b/test/110_coord_invcoord_h48/00_all.out new file mode 100644 index 0000000..e84be4b --- /dev/null +++ b/test/110_coord_invcoord_h48/00_all.out @@ -0,0 +1,8 @@ +1 ok +2 ok +3 ok +4 ok +5 ok +6 ok +7 ok +8 ok diff --git a/test/110_coord_invcoord_h48/coord_invcoord_h48_tests.c b/test/110_coord_invcoord_h48/coord_invcoord_h48_tests.c new file mode 100644 index 0000000..77dea81 --- /dev/null +++ b/test/110_coord_invcoord_h48/coord_invcoord_h48_tests.c @@ -0,0 +1,36 @@ +#include "../test.h" + +#define COCSEP_CLASSES 3393 + +size_t gendata_cocsep(void *, uint64_t *, cube_t *); +int64_t coord_h48(cube_t, const uint32_t *, uint8_t); +cube_t invcoord_h48(int64_t, const cube_t *, uint8_t); +cube_t transform(cube_t, uint8_t); + +void run(void) { + char str[STRLENMAX]; + int i; + bool found; + uint8_t h, t; + uint32_t cocsepdata[300000]; + uint64_t selfsim[COCSEP_CLASSES]; + int64_t c, cc; + cube_t cube, invc, rep[COCSEP_CLASSES]; + + gendata_cocsep(cocsepdata, selfsim, rep); + + i = 1; + h = 11; + while (fgets(str, STRLENMAX, stdin) != NULL) { + cube = readcube("H48", str); + c = coord_h48(cube, cocsepdata, h); + invc = invcoord_h48(c, rep, h); + for (t = 0, found = false; t < 48; t++) { + cube = transform(invc, t); + cc = coord_h48(cube, cocsepdata, h); + found = found || cc == c; + } + printf("%d %s\n", i, found ? "ok" : "ERROR"); + i++; + } +} diff --git a/test/111_gendata_h48_h0/00_h_0.in b/test/111_gendata_h48_h0/00_h_0.in new file mode 100644 index 0000000..e69de29 diff --git a/test/111_gendata_h48_h0/00_h_0.out b/test/111_gendata_h48_h0/00_h_0.out new file mode 100644 index 0000000..cc5cf9b --- /dev/null +++ b/test/111_gendata_h48_h0/00_h_0.out @@ -0,0 +1,23 @@ +59903605 + +cocsepdata: +Classes: 3393 +Max value: 9 +0: 1 +1: 6 +2: 63 +3: 468 +4: 3068 +5: 15438 +6: 53814 +7: 71352 +8: 8784 +9: 96 + +h48: +0: 1 +1: 1 +2: 4 +3: 34 +4: 329 +5: 3587 diff --git a/test/111_gendata_h48_h0/gendata_h48_tests.c b/test/111_gendata_h48_h0/gendata_h48_tests.c new file mode 100644 index 0000000..e9de3c0 --- /dev/null +++ b/test/111_gendata_h48_h0/gendata_h48_tests.c @@ -0,0 +1,33 @@ +#include "../test.h" + +#define MAXDEPTH 5 +#define COCSEPSIZE 1119792 +#define ETABLESIZE ((3393 * 495 * 70) >> 1) + +int64_t gendata_h48h0k4(void *, uint8_t); + +void run(void) { + char str[STRLENMAX]; + uint8_t i; + uint32_t *buf, *h48info; + size_t result; + + fgets(str, STRLENMAX, stdin); + buf = (uint32_t *)malloc(sizeof(uint32_t) * 60000000); + result = gendata_h48h0k4(buf, MAXDEPTH); + h48info = buf + (ETABLESIZE + COCSEPSIZE) / 4; + + printf("%zu\n\n", result); + + printf("cocsepdata:\n"); + printf("Classes: %" PRIu32 "\n", buf[COCSEPSIZE/4-12]); + printf("Max value: %" PRIu32 "\n", buf[COCSEPSIZE/4-11]); + for (i = 0; i < 10; i++) + printf("%" PRIu32 ": %" PRIu32 "\n", i, buf[COCSEPSIZE/4-10+i]); + + printf("\nh48:\n"); + for (i = 0; i < MAXDEPTH+1; i++) + printf("%" PRIu32 ": %" PRIu32 "\n", i, h48info[i+1]); + + free(buf); +} diff --git a/test/112_h48set/00_small.in b/test/112_h48set/00_small.in new file mode 100644 index 0000000..d788d5b --- /dev/null +++ b/test/112_h48set/00_small.in @@ -0,0 +1,6 @@ +11 +7 +3 +34 +45 +34 diff --git a/test/112_h48set/00_small.out b/test/112_h48set/00_small.out new file mode 100644 index 0000000..29c08e5 --- /dev/null +++ b/test/112_h48set/00_small.out @@ -0,0 +1,3 @@ +2 +34 +45 diff --git a/test/112_h48set/01_large.in b/test/112_h48set/01_large.in new file mode 100644 index 0000000..a70ef9a --- /dev/null +++ b/test/112_h48set/01_large.in @@ -0,0 +1,153 @@ +307 +293 +150 +100053 +100045 +100007 +100007 +100011 +100072 +100033 +100015 +100013 +100068 +100047 +100046 +100000 +100076 +100021 +100019 +100015 +100049 +100052 +100071 +100058 +100009 +100060 +100030 +100051 +100069 +100011 +100051 +100014 +100031 +100017 +100076 +100016 +100030 +100037 +100011 +100002 +100029 +100022 +100038 +100075 +100066 +100051 +100020 +100039 +100029 +100087 +100099 +100041 +100042 +100026 +100060 +100006 +100010 +100079 +100046 +100086 +100010 +100036 +100047 +100069 +100041 +100074 +100090 +100092 +100020 +100096 +100046 +100028 +100072 +100096 +100025 +100001 +100067 +100044 +100063 +100026 +100062 +100091 +100012 +100073 +100051 +100010 +100096 +100043 +100025 +100077 +100089 +100005 +100024 +100091 +100046 +100053 +100058 +100065 +100051 +100056 +100025 +100093 +100088 +100033 +100073 +100048 +100059 +100027 +100045 +100012 +100059 +100084 +100017 +100048 +100004 +100051 +100016 +100088 +100033 +100064 +100060 +100043 +100084 +100026 +100051 +100060 +100069 +100015 +100014 +100038 +100068 +100038 +100097 +100017 +100013 +100053 +100019 +100018 +100081 +100071 +100025 +100014 +100016 +100011 +100069 +100079 +100063 +100070 +100072 +100095 +100042 +100008 +100022 diff --git a/test/112_h48set/01_large.out b/test/112_h48set/01_large.out new file mode 100644 index 0000000..6632336 --- /dev/null +++ b/test/112_h48set/01_large.out @@ -0,0 +1,83 @@ +82 +100000 +100001 +100002 +100004 +100005 +100006 +100007 +100008 +100009 +100010 +100011 +100012 +100013 +100014 +100015 +100016 +100017 +100018 +100019 +100020 +100021 +100022 +100024 +100025 +100026 +100027 +100028 +100029 +100030 +100031 +100033 +100036 +100037 +100038 +100039 +100041 +100042 +100043 +100044 +100045 +100046 +100047 +100048 +100049 +100051 +100052 +100053 +100056 +100058 +100059 +100060 +100062 +100063 +100064 +100065 +100066 +100067 +100068 +100069 +100070 +100071 +100072 +100073 +100074 +100075 +100076 +100077 +100079 +100081 +100084 +100086 +100087 +100088 +100089 +100090 +100091 +100092 +100093 +100095 +100096 +100097 +100099 diff --git a/test/112_h48set/h48set_tests.c b/test/112_h48set/h48set_tests.c new file mode 100644 index 0000000..d9310a9 --- /dev/null +++ b/test/112_h48set/h48set_tests.c @@ -0,0 +1,64 @@ +#include "../test.h" + +char str[STRLENMAX]; + +typedef struct { + int64_t n; + int64_t capacity; + int64_t mod; + int64_t *table; +} h48set_t; + +void h48set_create(h48set_t *, int64_t, int64_t); +void h48set_clear(h48set_t *); +void h48set_destroy(h48set_t *); +int64_t h48set_lookup(h48set_t *, int64_t); +void h48set_insert(h48set_t *, int64_t); +bool h48set_contains(h48set_t *, int64_t); +int64_t h48set_save(h48set_t *, int64_t *); + +int compare(const void *x, const void *y) { + int64_t a = *(int64_t *)x; + int64_t b = *(int64_t *)y; + + if (a > b) return 1; + if (a == b) return 0; + return -1; +} + +int64_t readl(void) { + fgets(str, STRLENMAX, stdin); + return atoll(str); +} + +void run(void) { + h48set_t set; + int64_t n, i, k, capacity, mod, *a, *b; + + capacity = readl(); + mod = readl(); + n = readl(); + + a = malloc(n * sizeof(int64_t)); + b = malloc(n * sizeof(int64_t)); + for (i = 0; i < n; i++) + a[i] = readl(); + + h48set_create(&set, capacity, mod); + for (i = 0; i < n; i++) + h48set_insert(&set, a[i]); + + k = h48set_save(&set, b); + qsort(b, k, sizeof(int64_t), compare); + + printf("%" PRId64 "\n", k); + for (i = 0; i < k; i++) + printf("%" PRId64 "\n", b[i]); + for (i = 0; i < n; i++) + if (!h48set_contains(&set, a[i])) + printf("Set does not contain %" PRId64 "\n", a[i]); + + h48set_destroy(&set); + free(a); + free(b); +} -- cgit v1.3