commit dd6078288b5d7af4a4c0cdd1377a2976af569c9a
parent 4b5ab5d1808949661b4b449af914f3659596ef73
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date: Wed, 11 Sep 2024 10:25:39 +0200
Better way to read tables for solver
Diffstat:
2 files changed, 23 insertions(+), 11 deletions(-)
diff --git a/src/solvers/h48/gendata_h48.h b/src/solvers/h48/gendata_h48.h
@@ -71,10 +71,6 @@ typedef struct {
h48map_t *shortcubes;
} h48k2_dfs_arg_t;
-STATIC_INLINE uint8_t get_h48_pval(const uint8_t *, int64_t, uint8_t);
-STATIC_INLINE void set_h48_pval(uint8_t *, int64_t, uint8_t, uint8_t);
-STATIC_INLINE uint8_t get_h48_bound(cube_t, uint32_t, uint8_t, uint8_t, uint8_t *);
-
STATIC uint64_t gen_h48short(gendata_h48short_arg_t *);
STATIC size_t gendata_h48(gendata_h48_arg_t *);
STATIC size_t gendata_h48h0k4(gendata_h48_arg_t *);
@@ -86,6 +82,13 @@ STATIC_INLINE void gendata_h48k2_mark(cube_t, int8_t, h48k2_dfs_arg_t *);
STATIC_INLINE bool gendata_h48k2_dfs_stop(cube_t, uint8_t, h48k2_dfs_arg_t *);
STATIC void gendata_h48k2_dfs(h48k2_dfs_arg_t *arg);
+STATIC uint32_t *get_cocsepdata_ptr(const void *);
+STATIC uint8_t *get_h48data_ptr(const void *);
+
+STATIC_INLINE uint8_t get_h48_pval(const uint8_t *, int64_t, uint8_t);
+STATIC_INLINE void set_h48_pval(uint8_t *, int64_t, uint8_t, uint8_t);
+STATIC_INLINE uint8_t get_h48_bound(cube_t, uint32_t, uint8_t, uint8_t, uint8_t *);
+
STATIC uint64_t
gen_h48short(gendata_h48short_arg_t *arg)
{
@@ -529,3 +532,15 @@ get_h48_bound(cube_t cube, uint32_t cdata, uint8_t h, uint8_t k, uint8_t *table)
coord = coord_h48_edges(cube, COCLASS(cdata), TTREP(cdata), h);
return get_h48_pval(table, coord, k);
}
+
+STATIC uint32_t *
+get_cocsepdata_ptr(const void *data)
+{
+ return (uint32_t *)((char *)data + INFOSIZE);
+}
+
+STATIC uint8_t *
+get_h48data_ptr(const void *data)
+{
+ return (uint8_t *)data + COCSEP_FULLSIZE + INFOSIZE;
+}
diff --git a/src/solvers/h48/solve.h b/src/solvers/h48/solve.h
@@ -192,8 +192,8 @@ solve_h48(
.maxsolutions = maxsolutions,
.h = h,
.k = k,
- .cocsepdata = (uint32_t *)((char *)data + INFOSIZE),
- .h48data = (uint8_t *)data + COCSEP_FULLSIZE,
+ .cocsepdata = get_cocsepdata_ptr(data),
+ .h48data = get_h48data_ptr(data),
.nextsol = &solutions
};
@@ -276,15 +276,12 @@ solve_h48stats(
)
{
int i;
- size_t cocsepsize;
dfsarg_solveh48stats_t arg;
- cocsepsize = gendata_cocsep(NULL, NULL, NULL);
-
arg = (dfsarg_solveh48stats_t) {
.cube = cube,
- .cocsepdata = (uint32_t *)((char *)data + INFOSIZE),
- .h48data = (uint8_t *)data + cocsepsize,
+ .cocsepdata = get_cocsepdata_ptr(data),
+ .h48data = get_h48data_ptr(data),
.s = solutions
};