diff options
Diffstat (limited to '')
| -rw-r--r-- | TODO.txt | 2 | ||||
| -rw-r--r-- | src/solve_h48.h | 30 | ||||
| -rw-r--r-- | test/001_cube_conversion/cube_conversion_tests.c | 2 | ||||
| -rw-r--r-- | test/071_coord_eo/coord_eo_tests.c | 1 | ||||
| -rw-r--r-- | test/072_coord_co/coord_co_tests.c | 1 | ||||
| -rw-r--r-- | test/073_coord_csep/coord_csep_tests.c | 1 | ||||
| -rw-r--r-- | test/074_coord_esep/coord_esep_tests.c | 1 | ||||
| -rw-r--r-- | test/075_set_eo/set_eo_tests.c | 2 | ||||
| -rw-r--r-- | test/076_copy_corners/copy_corners_tests.c | 2 | ||||
| -rw-r--r-- | test/077_copy_edges/copy_edges_tests.c | 2 | ||||
| -rw-r--r-- | test/078_invcoord_esep/invcoord_esep_tests.c | 1 | ||||
| -rw-r--r-- | test/101_coord_invcoord_h48/00_all.in | 8 | ||||
| -rw-r--r-- | test/101_coord_invcoord_h48/00_all.out | 8 | ||||
| -rw-r--r-- | test/101_coord_invcoord_h48/coord_invcoord_h48_tests.c | 40 | ||||
| -rw-r--r-- | test/102_gendata_esep/00_all.in (renamed from test/101_gendata_esep/00_all.in) | 0 | ||||
| -rw-r--r-- | test/102_gendata_esep/00_all.out (renamed from test/101_gendata_esep/00_all.out) | 0 | ||||
| -rw-r--r-- | test/102_gendata_esep/gendata_esep_tests.c (renamed from test/101_gendata_esep/gendata_esep_tests.c) | 0 | ||||
| -rw-r--r-- | test/test.h | 2 |
18 files changed, 76 insertions, 27 deletions
| @@ -2,7 +2,7 @@ In progress: go back to nissy-style BFS for eosep data computation | |||
| 2 | - (done) compute selfsim and cocsep representatives | 2 | - (done) compute selfsim and cocsep representatives |
| 3 | - (done) implement set_eo_fast for invcoord_h48 | 3 | - (done) implement set_eo_fast for invcoord_h48 |
| 4 | - (done) for invcoord_h48 remove erep, implement inverse esep coord | 4 | - (done) for invcoord_h48 remove erep, implement inverse esep coord |
| 5 | - add unit tests for invcoord_h48 (compute tables, if needed) | 5 | - (done) add unit tests for invcoord_h48 (compute tables, if needed) |
| 6 | - change to BFS | 6 | - change to BFS |
| 7 | 7 | ||
| 8 | TODO pruning tables: | 8 | TODO pruning tables: |
diff --git a/src/solve_h48.h b/src/solve_h48.h index d4a018b..b04ae47 100644 --- a/src/solve_h48.h +++ b/src/solve_h48.h | |||
| @@ -8,13 +8,13 @@ | |||
| 8 | #define ESEP_VISITEDSIZE ((ESEP_TABLESIZE * 2U + 7U) / 8U) | 8 | #define ESEP_VISITEDSIZE ((ESEP_TABLESIZE * 2U + 7U) / 8U) |
| 9 | #define ESEP_INFOSIZE 25 /* TODO unknown yet */ | 9 | #define ESEP_INFOSIZE 25 /* TODO unknown yet */ |
| 10 | 10 | ||
| 11 | #define H48_ESIZE ((_12c4 * _8c4) << h) | 11 | #define H48_ESIZE(h) ((_12c4 * _8c4) << (h)) |
| 12 | 12 | ||
| 13 | #define _esep_ind(i) (i / 8U) | 13 | #define _esep_ind(i) (i / 8U) |
| 14 | #define _esep_shift(i) (4U * (i % 8U)) | 14 | #define _esep_shift(i) (4U * (i % 8U)) |
| 15 | #define _esep_mask(i) (((1U << 4U) - 1U) << _esep_shift(i)) | 15 | #define _esep_mask(i) (((1U << 4U) - 1U) << _esep_shift(i)) |
| 16 | #define _visited_ind(i) (i / 8U) | 16 | #define _visited_ind(i) (i / 8U) |
| 17 | #define _visited_mask(i) (1U << (i % 8U)) | 17 | #define _visited_mask(i) (1U << (i % 8U)) |
| 18 | 18 | ||
| 19 | typedef struct { | 19 | typedef struct { |
| 20 | cube_fast_t cube; | 20 | cube_fast_t cube; |
| @@ -70,22 +70,26 @@ coord_h48(cube_fast_t c, const uint32_t *cocsepdata, uint8_t h) | |||
| 70 | esep = coord_fast_esep(d); | 70 | esep = coord_fast_esep(d); |
| 71 | eo = coord_fast_eo(d); | 71 | eo = coord_fast_eo(d); |
| 72 | 72 | ||
| 73 | ret = (coclass * H48_ESIZE) + (esep << h) + (eo >> (11-h)); | 73 | ret = (coclass * H48_ESIZE(h)) + (esep << h) + (eo >> (11-h)); |
| 74 | 74 | ||
| 75 | return ret; | 75 | return ret; |
| 76 | } | 76 | } |
| 77 | 77 | ||
| 78 | /* | ||
| 79 | |||
| 80 | This function does not necessarily return a cube whose coordinate is | ||
| 81 | the given value, because it works up to symmetry. This means that the | ||
| 82 | returned cube is a transformed cube of one that gives the correct value. | ||
| 83 | */ | ||
| 78 | _static_inline cube_fast_t | 84 | _static_inline cube_fast_t |
| 79 | invcoord_h48(int64_t i, const cube_fast_t *crep, uint8_t h) | 85 | invcoord_h48(int64_t i, const cube_fast_t *crep, uint8_t h) { |
| 80 | { | 86 | cube_fast_t ret; int64_t coclass, ee, esep, eo; |
| 81 | cube_fast_t ret; | ||
| 82 | int64_t coclass, ee, esep, eo; | ||
| 83 | 87 | ||
| 84 | DBG_ASSERT(h <= 11, cubetofast(zero), | 88 | DBG_ASSERT(h <= 11, cubetofast(zero), |
| 85 | "invcoord_h48: h must be between 0 and 11\n"); | 89 | "invcoord_h48: h must be between 0 and 11\n"); |
| 86 | 90 | ||
| 87 | coclass = i / H48_ESIZE; | 91 | coclass = i / H48_ESIZE(h); |
| 88 | ee = i % H48_ESIZE; | 92 | ee = i % H48_ESIZE(h); |
| 89 | esep = ee >> h; | 93 | esep = ee >> h; |
| 90 | eo = (ee & ((1<<h)-1)) << (11-h); | 94 | eo = (ee & ((1<<h)-1)) << (11-h); |
| 91 | 95 | ||
diff --git a/test/001_cube_conversion/cube_conversion_tests.c b/test/001_cube_conversion/cube_conversion_tests.c index 589eb82..df03eb6 100644 --- a/test/001_cube_conversion/cube_conversion_tests.c +++ b/test/001_cube_conversion/cube_conversion_tests.c | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | #include "../test.h" | 1 | #include "../test.h" |
| 2 | 2 | ||
| 3 | cube_fast_t cubetofast(cube_t); | ||
| 4 | cube_t fasttocube(cube_fast_t); | ||
| 5 | bool equal(cube_t, cube_t); | 3 | bool equal(cube_t, cube_t); |
| 6 | 4 | ||
| 7 | int main(void) { | 5 | int main(void) { |
diff --git a/test/071_coord_eo/coord_eo_tests.c b/test/071_coord_eo/coord_eo_tests.c index 85128e0..5eec4fc 100644 --- a/test/071_coord_eo/coord_eo_tests.c +++ b/test/071_coord_eo/coord_eo_tests.c | |||
| @@ -1,7 +1,6 @@ | |||
| 1 | #include "../test.h" | 1 | #include "../test.h" |
| 2 | 2 | ||
| 3 | int64_t coord_fast_eo(cube_fast_t); | 3 | int64_t coord_fast_eo(cube_fast_t); |
| 4 | cube_fast_t cubetofast(cube_t); | ||
| 5 | 4 | ||
| 6 | int main(void) { | 5 | int main(void) { |
| 7 | char str[STRLENMAX]; | 6 | char str[STRLENMAX]; |
diff --git a/test/072_coord_co/coord_co_tests.c b/test/072_coord_co/coord_co_tests.c index bb061e5..8461324 100644 --- a/test/072_coord_co/coord_co_tests.c +++ b/test/072_coord_co/coord_co_tests.c | |||
| @@ -1,7 +1,6 @@ | |||
| 1 | #include "../test.h" | 1 | #include "../test.h" |
| 2 | 2 | ||
| 3 | int64_t coord_fast_co(cube_fast_t); | 3 | int64_t coord_fast_co(cube_fast_t); |
| 4 | cube_fast_t cubetofast(cube_t); | ||
| 5 | 4 | ||
| 6 | int main(void) { | 5 | int main(void) { |
| 7 | char str[STRLENMAX]; | 6 | char str[STRLENMAX]; |
diff --git a/test/073_coord_csep/coord_csep_tests.c b/test/073_coord_csep/coord_csep_tests.c index b36bf1a..c4113d3 100644 --- a/test/073_coord_csep/coord_csep_tests.c +++ b/test/073_coord_csep/coord_csep_tests.c | |||
| @@ -1,7 +1,6 @@ | |||
| 1 | #include "../test.h" | 1 | #include "../test.h" |
| 2 | 2 | ||
| 3 | int64_t coord_fast_csep(cube_fast_t); | 3 | int64_t coord_fast_csep(cube_fast_t); |
| 4 | cube_fast_t cubetofast(cube_t); | ||
| 5 | 4 | ||
| 6 | int main(void) { | 5 | int main(void) { |
| 7 | char str[STRLENMAX]; | 6 | char str[STRLENMAX]; |
diff --git a/test/074_coord_esep/coord_esep_tests.c b/test/074_coord_esep/coord_esep_tests.c index 8276dc0..fa21d67 100644 --- a/test/074_coord_esep/coord_esep_tests.c +++ b/test/074_coord_esep/coord_esep_tests.c | |||
| @@ -1,7 +1,6 @@ | |||
| 1 | #include "../test.h" | 1 | #include "../test.h" |
| 2 | 2 | ||
| 3 | int64_t coord_fast_esep(cube_fast_t); | 3 | int64_t coord_fast_esep(cube_fast_t); |
| 4 | cube_fast_t cubetofast(cube_t); | ||
| 5 | 4 | ||
| 6 | int main(void) { | 5 | int main(void) { |
| 7 | char str[STRLENMAX]; | 6 | char str[STRLENMAX]; |
diff --git a/test/075_set_eo/set_eo_tests.c b/test/075_set_eo/set_eo_tests.c index ef7215a..08c8ae8 100644 --- a/test/075_set_eo/set_eo_tests.c +++ b/test/075_set_eo/set_eo_tests.c | |||
| @@ -2,8 +2,6 @@ | |||
| 2 | 2 | ||
| 3 | int64_t coord_fast_eo(cube_fast_t); | 3 | int64_t coord_fast_eo(cube_fast_t); |
| 4 | void set_eo_fast(cube_fast_t *, int64_t); | 4 | void set_eo_fast(cube_fast_t *, int64_t); |
| 5 | cube_fast_t cubetofast(cube_t); | ||
| 6 | cube_t fasttocube(cube_fast_t); | ||
| 7 | 5 | ||
| 8 | int main(void) { | 6 | int main(void) { |
| 9 | char str[STRLENMAX]; | 7 | char str[STRLENMAX]; |
diff --git a/test/076_copy_corners/copy_corners_tests.c b/test/076_copy_corners/copy_corners_tests.c index fecf14a..fe59089 100644 --- a/test/076_copy_corners/copy_corners_tests.c +++ b/test/076_copy_corners/copy_corners_tests.c | |||
| @@ -1,8 +1,6 @@ | |||
| 1 | #include "../test.h" | 1 | #include "../test.h" |
| 2 | 2 | ||
| 3 | void copy_corners_fast(cube_fast_t *, cube_fast_t); | 3 | void copy_corners_fast(cube_fast_t *, cube_fast_t); |
| 4 | cube_fast_t cubetofast(cube_t); | ||
| 5 | cube_t fasttocube(cube_fast_t); | ||
| 6 | 4 | ||
| 7 | int main(void) { | 5 | int main(void) { |
| 8 | char str[STRLENMAX]; | 6 | char str[STRLENMAX]; |
diff --git a/test/077_copy_edges/copy_edges_tests.c b/test/077_copy_edges/copy_edges_tests.c index c3e70a3..b428f89 100644 --- a/test/077_copy_edges/copy_edges_tests.c +++ b/test/077_copy_edges/copy_edges_tests.c | |||
| @@ -1,8 +1,6 @@ | |||
| 1 | #include "../test.h" | 1 | #include "../test.h" |
| 2 | 2 | ||
| 3 | void copy_edges_fast(cube_fast_t *, cube_fast_t); | 3 | void copy_edges_fast(cube_fast_t *, cube_fast_t); |
| 4 | cube_fast_t cubetofast(cube_t); | ||
| 5 | cube_t fasttocube(cube_fast_t); | ||
| 6 | 4 | ||
| 7 | int main(void) { | 5 | int main(void) { |
| 8 | char str[STRLENMAX]; | 6 | char str[STRLENMAX]; |
diff --git a/test/078_invcoord_esep/invcoord_esep_tests.c b/test/078_invcoord_esep/invcoord_esep_tests.c index 167f452..17ea2ff 100644 --- a/test/078_invcoord_esep/invcoord_esep_tests.c +++ b/test/078_invcoord_esep/invcoord_esep_tests.c | |||
| @@ -2,7 +2,6 @@ | |||
| 2 | 2 | ||
| 3 | int64_t coord_fast_esep(cube_fast_t); | 3 | int64_t coord_fast_esep(cube_fast_t); |
| 4 | cube_fast_t invcoord_fast_esep(int64_t); | 4 | cube_fast_t invcoord_fast_esep(int64_t); |
| 5 | cube_fast_t cubetofast(cube_t); | ||
| 6 | 5 | ||
| 7 | int main(void) { | 6 | int main(void) { |
| 8 | char str[STRLENMAX]; | 7 | char str[STRLENMAX]; |
diff --git a/test/101_coord_invcoord_h48/00_all.in b/test/101_coord_invcoord_h48/00_all.in new file mode 100644 index 0000000..a2f9540 --- /dev/null +++ b/test/101_coord_invcoord_h48/00_all.in | |||
| @@ -0,0 +1,8 @@ | |||
| 1 | UB0 DF0 DB0 UF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 | ||
| 2 | UF0 UB0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 | ||
| 3 | UB0 UF0 DB0 DF0 UL0 UR0 DL0 DR0 FR0 FL0 BL0 BR0 UBL0 UFR0 DFL0 DBR0 UBR0 UFL0 DFR0 DBL0 | ||
| 4 | UL0 BL0 BR1 DL0 FR0 DF0 DB1 DR1 UB0 FL0 UF0 UR1 DFL0 UFR1 DBR1 UBR2 DBL2 DFR0 UFL1 UBL2 | ||
| 5 | UF0 UB0 DB0 DF0 FR0 UL0 DL0 BR0 DR0 FL0 BL0 UR0 DFR2 UBL0 DFL0 UBR2 UFL0 UFR1 DBR1 DBL0 | ||
| 6 | FL1 UB0 DB0 FR1 UR0 UL0 DL0 DR0 UF1 DF1 BL0 BR0 UFL1 UBL0 DFR1 DBR0 DFL2 UBR0 UFR2 DBL0 | ||
| 7 | FR0 BR0 BL0 FL0 UR0 UL0 DL0 DR0 DF0 UF0 UB0 DB0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 | ||
| 8 | UR0 UL0 DL0 DR0 UB0 UF0 DF0 DB0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 | ||
diff --git a/test/101_coord_invcoord_h48/00_all.out b/test/101_coord_invcoord_h48/00_all.out new file mode 100644 index 0000000..e84be4b --- /dev/null +++ b/test/101_coord_invcoord_h48/00_all.out | |||
| @@ -0,0 +1,8 @@ | |||
| 1 | 1 ok | ||
| 2 | 2 ok | ||
| 3 | 3 ok | ||
| 4 | 4 ok | ||
| 5 | 5 ok | ||
| 6 | 6 ok | ||
| 7 | 7 ok | ||
| 8 | 8 ok | ||
diff --git a/test/101_coord_invcoord_h48/coord_invcoord_h48_tests.c b/test/101_coord_invcoord_h48/coord_invcoord_h48_tests.c new file mode 100644 index 0000000..e7858df --- /dev/null +++ b/test/101_coord_invcoord_h48/coord_invcoord_h48_tests.c | |||
| @@ -0,0 +1,40 @@ | |||
| 1 | #include "../test.h" | ||
| 2 | |||
| 3 | #define COCSEP_CLASSES 3393U | ||
| 4 | |||
| 5 | size_t gendata_cocsep(void *, uint64_t *, cube_fast_t *); | ||
| 6 | int64_t coord_h48(cube_fast_t, const uint32_t *, uint8_t); | ||
| 7 | cube_fast_t invcoord_h48(int64_t, const cube_fast_t *, uint8_t); | ||
| 8 | cube_fast_t transform(cube_fast_t, uint8_t); | ||
| 9 | |||
| 10 | int main(void) { | ||
| 11 | char str[STRLENMAX]; | ||
| 12 | int i; | ||
| 13 | bool found; | ||
| 14 | uint8_t h, t; | ||
| 15 | uint32_t cocsepdata[300000]; | ||
| 16 | uint64_t selfsim[COCSEP_CLASSES]; | ||
| 17 | int64_t c, cc; | ||
| 18 | cube_t cube; | ||
| 19 | cube_fast_t fast, invc, rep[COCSEP_CLASSES]; | ||
| 20 | |||
| 21 | gendata_cocsep(cocsepdata, selfsim, rep); | ||
| 22 | |||
| 23 | i = 1; | ||
| 24 | h = 11; | ||
| 25 | while (fgets(str, STRLENMAX, stdin) != NULL) { | ||
| 26 | cube = readcube("H48", str); | ||
| 27 | fast = cubetofast(cube); | ||
| 28 | c = coord_h48(fast, cocsepdata, h); | ||
| 29 | invc = invcoord_h48(c, rep, h); | ||
| 30 | for (t = 0, found = false; t < 48; t++) { | ||
| 31 | fast = transform(invc, t); | ||
| 32 | cc = coord_h48(fast, cocsepdata, h); | ||
| 33 | found = found || cc == c; | ||
| 34 | } | ||
| 35 | printf("%d %s\n", i, found ? "ok" : "ERROR"); | ||
| 36 | i++; | ||
| 37 | } | ||
| 38 | |||
| 39 | return 0; | ||
| 40 | } | ||
diff --git a/test/101_gendata_esep/00_all.in b/test/102_gendata_esep/00_all.in index e69de29..e69de29 100644 --- a/test/101_gendata_esep/00_all.in +++ b/test/102_gendata_esep/00_all.in | |||
diff --git a/test/101_gendata_esep/00_all.out b/test/102_gendata_esep/00_all.out index deba01f..deba01f 100644 --- a/test/101_gendata_esep/00_all.out +++ b/test/102_gendata_esep/00_all.out | |||
diff --git a/test/101_gendata_esep/gendata_esep_tests.c b/test/102_gendata_esep/gendata_esep_tests.c index bc7ce25..bc7ce25 100644 --- a/test/101_gendata_esep/gendata_esep_tests.c +++ b/test/102_gendata_esep/gendata_esep_tests.c | |||
diff --git a/test/test.h b/test/test.h index 2086283..ab40bde 100644 --- a/test/test.h +++ b/test/test.h | |||
| @@ -26,3 +26,5 @@ bool issolvable(cube_t); | |||
| 26 | bool issolved(cube_t); | 26 | bool issolved(cube_t); |
| 27 | cube_t readcube(char *, char *); | 27 | cube_t readcube(char *, char *); |
| 28 | void writecube(char *, cube_t, char *); | 28 | void writecube(char *, cube_t, char *); |
| 29 | cube_t fasttocube(cube_fast_t); | ||
| 30 | cube_fast_t cubetofast(cube_t); | ||
