diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2024-06-09 12:43:49 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2024-06-09 12:43:49 +0200 |
| commit | c5c5017a335208881e27fc8f72c1d0145a04622a (patch) | |
| tree | 7a1518e5b05f3fbde810fa3080c41099ba7d5ae8 /src/solve_h48.h | |
| parent | 28ad019d62583b7e89b4e76922aa73857d5876eb (diff) | |
| download | nissy-core-c5c5017a335208881e27fc8f72c1d0145a04622a.tar.gz nissy-core-c5c5017a335208881e27fc8f72c1d0145a04622a.zip | |
Remvoed cube_fast_t and more. More cleaning up to do.
Diffstat (limited to 'src/solve_h48.h')
| -rw-r--r-- | src/solve_h48.h | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/src/solve_h48.h b/src/solve_h48.h index abf7a86..8691d49 100644 --- a/src/solve_h48.h +++ b/src/solve_h48.h | |||
| @@ -20,14 +20,14 @@ | |||
| 20 | #define VISITED_MASK(i) (UINT32_C(1) << ((uint32_t)(i) % UINT32_C(8))) | 20 | #define VISITED_MASK(i) (UINT32_C(1) << ((uint32_t)(i) % UINT32_C(8))) |
| 21 | 21 | ||
| 22 | typedef struct { | 22 | typedef struct { |
| 23 | cube_fast_t cube; | 23 | cube_t cube; |
| 24 | uint8_t depth; | 24 | uint8_t depth; |
| 25 | uint8_t maxdepth; | 25 | uint8_t maxdepth; |
| 26 | uint16_t *n; | 26 | uint16_t *n; |
| 27 | uint32_t *buf32; | 27 | uint32_t *buf32; |
| 28 | uint8_t *visited; | 28 | uint8_t *visited; |
| 29 | uint64_t *selfsim; | 29 | uint64_t *selfsim; |
| 30 | cube_fast_t *rep; | 30 | cube_t *rep; |
| 31 | } dfsarg_cocsep_t; | 31 | } dfsarg_cocsep_t; |
| 32 | 32 | ||
| 33 | typedef struct { | 33 | typedef struct { |
| @@ -36,14 +36,14 @@ typedef struct { | |||
| 36 | uint32_t *cocsepdata; | 36 | uint32_t *cocsepdata; |
| 37 | uint32_t *buf32; | 37 | uint32_t *buf32; |
| 38 | uint64_t *selfsim; | 38 | uint64_t *selfsim; |
| 39 | cube_fast_t *crep; | 39 | cube_t *crep; |
| 40 | } bfsarg_esep_t; | 40 | } bfsarg_esep_t; |
| 41 | 41 | ||
| 42 | _static_inline int64_t coord_h48(cube_fast_t, const uint32_t *, uint8_t); | 42 | _static_inline int64_t coord_h48(cube_t, const uint32_t *, uint8_t); |
| 43 | _static_inline int64_t coord_h48_edges(cube_fast_t, int64_t, uint8_t, uint8_t); | 43 | _static_inline int64_t coord_h48_edges(cube_t, int64_t, uint8_t, uint8_t); |
| 44 | _static_inline cube_fast_t invcoord_h48(int64_t, const cube_fast_t *, uint8_t); | 44 | _static_inline cube_t invcoord_h48(int64_t, const cube_t *, uint8_t); |
| 45 | 45 | ||
| 46 | _static size_t gendata_cocsep(void *, uint64_t *, cube_fast_t *); | 46 | _static size_t gendata_cocsep(void *, uint64_t *, cube_t *); |
| 47 | _static uint32_t gendata_cocsep_dfs(dfsarg_cocsep_t *); | 47 | _static uint32_t gendata_cocsep_dfs(dfsarg_cocsep_t *); |
| 48 | _static size_t gendata_h48(void *, uint8_t, uint8_t); | 48 | _static size_t gendata_h48(void *, uint8_t, uint8_t); |
| 49 | _static uint64_t gendata_esep_bfs(bfsarg_esep_t *); | 49 | _static uint64_t gendata_esep_bfs(bfsarg_esep_t *); |
| @@ -54,7 +54,7 @@ _static_inline uint8_t get_esep_pval(const uint32_t *, int64_t); | |||
| 54 | _static_inline void set_esep_pval(uint32_t *, int64_t, uint8_t); | 54 | _static_inline void set_esep_pval(uint32_t *, int64_t, uint8_t); |
| 55 | 55 | ||
| 56 | _static_inline int64_t | 56 | _static_inline int64_t |
| 57 | coord_h48(cube_fast_t c, const uint32_t *cocsepdata, uint8_t h) | 57 | coord_h48(cube_t c, const uint32_t *cocsepdata, uint8_t h) |
| 58 | { | 58 | { |
| 59 | int64_t cocsep, coclass; | 59 | int64_t cocsep, coclass; |
| 60 | uint32_t data; | 60 | uint32_t data; |
| @@ -62,7 +62,7 @@ coord_h48(cube_fast_t c, const uint32_t *cocsepdata, uint8_t h) | |||
| 62 | 62 | ||
| 63 | DBG_ASSERT(h <= 11, -1, "coord_h48: h must be between 0 and 11\n"); | 63 | DBG_ASSERT(h <= 11, -1, "coord_h48: h must be between 0 and 11\n"); |
| 64 | 64 | ||
| 65 | cocsep = coord_fast_cocsep(c); | 65 | cocsep = coord_cocsep(c); |
| 66 | data = cocsepdata[cocsep]; | 66 | data = cocsepdata[cocsep]; |
| 67 | coclass = (int64_t)COCLASS(data); | 67 | coclass = (int64_t)COCLASS(data); |
| 68 | ttrep = (int64_t)TTREP(data); | 68 | ttrep = (int64_t)TTREP(data); |
| @@ -71,14 +71,14 @@ coord_h48(cube_fast_t c, const uint32_t *cocsepdata, uint8_t h) | |||
| 71 | } | 71 | } |
| 72 | 72 | ||
| 73 | _static_inline int64_t | 73 | _static_inline int64_t |
| 74 | coord_h48_edges(cube_fast_t c, int64_t coclass, uint8_t t, uint8_t h) | 74 | coord_h48_edges(cube_t c, int64_t coclass, uint8_t t, uint8_t h) |
| 75 | { | 75 | { |
| 76 | cube_fast_t d; | 76 | cube_t d; |
| 77 | int64_t esep, eo, edges; | 77 | int64_t esep, eo, edges; |
| 78 | 78 | ||
| 79 | d = transform_edges(c, t); | 79 | d = transform_edges(c, t); |
| 80 | esep = coord_fast_esep(d); | 80 | esep = coord_esep(d); |
| 81 | eo = coord_fast_eo(d); | 81 | eo = coord_eo(d); |
| 82 | edges = (esep << (int64_t)h) + (eo >> (11 - (int64_t)h)); | 82 | edges = (esep << (int64_t)h) + (eo >> (11 - (int64_t)h)); |
| 83 | 83 | ||
| 84 | return coclass * H48_ESIZE(h) + edges; | 84 | return coclass * H48_ESIZE(h) + edges; |
| @@ -89,12 +89,12 @@ This function does not necessarily return a cube whose coordinate is | |||
| 89 | the given value, because it works up to symmetry. This means that the | 89 | the given value, because it works up to symmetry. This means that the |
| 90 | returned cube is a transformed cube of one that gives the correct value. | 90 | returned cube is a transformed cube of one that gives the correct value. |
| 91 | */ | 91 | */ |
| 92 | _static_inline cube_fast_t | 92 | _static_inline cube_t |
| 93 | invcoord_h48(int64_t i, const cube_fast_t *crep, uint8_t h) { | 93 | invcoord_h48(int64_t i, const cube_t *crep, uint8_t h) { |
| 94 | cube_fast_t ret; | 94 | cube_t ret; |
| 95 | int64_t hh, coclass, ee, esep, eo; | 95 | int64_t hh, coclass, ee, esep, eo; |
| 96 | 96 | ||
| 97 | DBG_ASSERT(h <= 11, cubetofast(zero), | 97 | DBG_ASSERT(h <= 11, zero, |
| 98 | "invcoord_h48: h must be between 0 and 11\n"); | 98 | "invcoord_h48: h must be between 0 and 11\n"); |
| 99 | 99 | ||
| 100 | hh = (int64_t)h; | 100 | hh = (int64_t)h; |
| @@ -103,9 +103,9 @@ invcoord_h48(int64_t i, const cube_fast_t *crep, uint8_t h) { | |||
| 103 | esep = ee >> hh; | 103 | esep = ee >> hh; |
| 104 | eo = (ee & ((1 << hh) - 1)) << (11 - hh); | 104 | eo = (ee & ((1 << hh) - 1)) << (11 - hh); |
| 105 | 105 | ||
| 106 | ret = invcoord_fast_esep(esep); | 106 | ret = invcoord_esep(esep); |
| 107 | copy_corners_fast(&ret, crep[coclass]); | 107 | copy_corners(&ret, crep[coclass]); |
| 108 | set_eo_fast(&ret, eo); | 108 | set_eo(&ret, eo); |
| 109 | 109 | ||
| 110 | return ret; | 110 | return ret; |
| 111 | } | 111 | } |
| @@ -122,7 +122,7 @@ After the data as described above, more auxiliary information is appended: | |||
| 122 | of positions having that pruning value. | 122 | of positions having that pruning value. |
| 123 | */ | 123 | */ |
| 124 | _static size_t | 124 | _static size_t |
| 125 | gendata_cocsep(void *buf, uint64_t *selfsim, cube_fast_t *rep) | 125 | gendata_cocsep(void *buf, uint64_t *selfsim, cube_t *rep) |
| 126 | { | 126 | { |
| 127 | uint32_t *buf32, *info, cc; | 127 | uint32_t *buf32, *info, cc; |
| 128 | uint16_t n; | 128 | uint16_t n; |
| @@ -135,7 +135,7 @@ gendata_cocsep(void *buf, uint64_t *selfsim, cube_fast_t *rep) | |||
| 135 | memset(selfsim, 0, sizeof(uint64_t) * COCSEP_CLASSES); | 135 | memset(selfsim, 0, sizeof(uint64_t) * COCSEP_CLASSES); |
| 136 | 136 | ||
| 137 | arg = (dfsarg_cocsep_t) { | 137 | arg = (dfsarg_cocsep_t) { |
| 138 | .cube = cubetofast(solvedcube()), | 138 | .cube = solved, |
| 139 | .n = &n, | 139 | .n = &n, |
| 140 | .buf32 = buf32, | 140 | .buf32 = buf32, |
| 141 | .visited = visited, | 141 | .visited = visited, |
| @@ -175,10 +175,10 @@ gendata_cocsep_dfs(dfsarg_cocsep_t *arg) | |||
| 175 | uint32_t cc, class, ttrep, depth, olddepth; | 175 | uint32_t cc, class, ttrep, depth, olddepth; |
| 176 | uint64_t t, is; | 176 | uint64_t t, is; |
| 177 | int64_t i, j; | 177 | int64_t i, j; |
| 178 | cube_fast_t d; | 178 | cube_t d; |
| 179 | dfsarg_cocsep_t nextarg; | 179 | dfsarg_cocsep_t nextarg; |
| 180 | 180 | ||
| 181 | i = coord_fast_cocsep(arg->cube); | 181 | i = coord_cocsep(arg->cube); |
| 182 | olddepth = (uint8_t)(arg->buf32[i] & 0xFF); | 182 | olddepth = (uint8_t)(arg->buf32[i] & 0xFF); |
| 183 | if (olddepth < arg->depth || get_visited(arg->visited, i)) | 183 | if (olddepth < arg->depth || get_visited(arg->visited, i)) |
| 184 | return 0; | 184 | return 0; |
| @@ -190,7 +190,7 @@ gendata_cocsep_dfs(dfsarg_cocsep_t *arg) | |||
| 190 | 190 | ||
| 191 | for (t = 0, cc = 0; t < 48; t++) { | 191 | for (t = 0, cc = 0; t < 48; t++) { |
| 192 | d = transform_corners(arg->cube, t); | 192 | d = transform_corners(arg->cube, t); |
| 193 | j = coord_fast_cocsep(d); | 193 | j = coord_cocsep(d); |
| 194 | is = (i == j); | 194 | is = (i == j); |
| 195 | arg->selfsim[*arg->n] |= is << t; | 195 | arg->selfsim[*arg->n] |= is << t; |
| 196 | set_visited(arg->visited, j); | 196 | set_visited(arg->visited, j); |
| @@ -231,7 +231,7 @@ gendata_h48(void *buf, uint8_t h, uint8_t maxdepth) | |||
| 231 | bfsarg_esep_t arg; | 231 | bfsarg_esep_t arg; |
| 232 | int64_t sc, cc, tot, esep_max; | 232 | int64_t sc, cc, tot, esep_max; |
| 233 | uint64_t selfsim[COCSEP_CLASSES]; | 233 | uint64_t selfsim[COCSEP_CLASSES]; |
| 234 | cube_fast_t crep[COCSEP_CLASSES]; | 234 | cube_t crep[COCSEP_CLASSES]; |
| 235 | size_t cocsepsize, infosize; | 235 | size_t cocsepsize, infosize; |
| 236 | 236 | ||
| 237 | esep_max = (int64_t)ESEP_MAX(h); | 237 | esep_max = (int64_t)ESEP_MAX(h); |
| @@ -241,7 +241,7 @@ gendata_h48(void *buf, uint8_t h, uint8_t maxdepth) | |||
| 241 | info = buf32 + (ESEP_TABLESIZE(h, k) / sizeof(uint32_t)); | 241 | info = buf32 + (ESEP_TABLESIZE(h, k) / sizeof(uint32_t)); |
| 242 | memset(buf32, 0xFF, ESEP_TABLESIZE(h, k)); | 242 | memset(buf32, 0xFF, ESEP_TABLESIZE(h, k)); |
| 243 | 243 | ||
| 244 | sc = coord_h48(cubetofast(solved), cocsepdata, h); | 244 | sc = coord_h48(solved, cocsepdata, h); |
| 245 | set_esep_pval(buf32, sc, 0); | 245 | set_esep_pval(buf32, sc, 0); |
| 246 | info[1] = 1; | 246 | info[1] = 1; |
| 247 | arg = (bfsarg_esep_t) { | 247 | arg = (bfsarg_esep_t) { |
| @@ -281,7 +281,7 @@ gendata_esep_bfs(bfsarg_esep_t *arg) | |||
| 281 | uint8_t c, m, x; | 281 | uint8_t c, m, x; |
| 282 | uint32_t cc; | 282 | uint32_t cc; |
| 283 | int64_t i, j, k, t, cocsep_coord, sim, esep_max; | 283 | int64_t i, j, k, t, cocsep_coord, sim, esep_max; |
| 284 | cube_fast_t cube, moved, transd; | 284 | cube_t cube, moved, transd; |
| 285 | 285 | ||
| 286 | esep_max = (uint64_t)ESEP_MAX(arg->h); | 286 | esep_max = (uint64_t)ESEP_MAX(arg->h); |
| 287 | 287 | ||
