aboutsummaryrefslogtreecommitdiff
path: root/src/solvers/h48/gendata_h48.h
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2024-08-30 07:52:04 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2024-08-30 07:52:04 +0200
commita7444e9ab414e1eb73451a806289a3f7c4f02047 (patch)
tree02219807113dde108e278f38f3dd5874f7e3dc18 /src/solvers/h48/gendata_h48.h
parent1983bacfbb84e2a410ebe663ac1fa7c1b22eb096 (diff)
parentc548499e68e473452592c9b0bf860f76bd8b94b8 (diff)
downloadnissy-core-a7444e9ab414e1eb73451a806289a3f7c4f02047.tar.gz
nissy-core-a7444e9ab414e1eb73451a806289a3f7c4f02047.zip
Merge branch 'master' of tronto.net:h48
Diffstat (limited to 'src/solvers/h48/gendata_h48.h')
-rw-r--r--src/solvers/h48/gendata_h48.h31
1 files changed, 21 insertions, 10 deletions
diff --git a/src/solvers/h48/gendata_h48.h b/src/solvers/h48/gendata_h48.h
index 2d222c9..fbb8b35 100644
--- a/src/solvers/h48/gendata_h48.h
+++ b/src/solvers/h48/gendata_h48.h
@@ -1,6 +1,7 @@
1#define H48_COORDMAX_NOEO ((int64_t)(COCSEP_CLASSES * _12c4 * _8c4)) 1#define H48_COORDMAX_NOEO ((int64_t)(COCSEP_CLASSES * _12c4 * _8c4))
2#define H48_COORDMAX(h) ((int64_t)(H48_COORDMAX_NOEO << (int64_t)(h))) 2#define H48_COORDMAX(h) ((int64_t)(H48_COORDMAX_NOEO << (int64_t)(h)))
3#define H48_TABLESIZE(h, k) ((size_t)H48_COORDMAX((h)) / ((size_t)8 / (size_t)(k))) 3#define H48_DIV(k) ((size_t)8 / (size_t)(k))
4#define H48_TABLESIZE(h, k) _div_round_up((size_t)H48_COORDMAX((h)), H48_DIV(k))
4 5
5#define H48_COEFF(k) (UINT32_C(32) / (uint32_t)(k)) 6#define H48_COEFF(k) (UINT32_C(32) / (uint32_t)(k))
6#define H48_INDEX(i, k) ((uint32_t)(i) / H48_COEFF(k)) 7#define H48_INDEX(i, k) ((uint32_t)(i) / H48_COEFF(k))
@@ -140,7 +141,7 @@ gendata_h48(gendata_h48_arg_t *arg)
140 cocsepsize = gendata_cocsep( 141 cocsepsize = gendata_cocsep(
141 (void *)arg->cocsepdata, arg->selfsim, arg->crep); 142 (void *)arg->cocsepdata, arg->selfsim, arg->crep);
142 arg->h48data = arg->cocsepdata + (cocsepsize / sizeof(uint32_t)); 143 arg->h48data = arg->cocsepdata + (cocsepsize / sizeof(uint32_t));
143 arg->info = arg->h48data + 144 arg->info = arg->h48data + 1 +
144 (H48_TABLESIZE(arg->h, arg->k) / sizeof(uint32_t)); 145 (H48_TABLESIZE(arg->h, arg->k) / sizeof(uint32_t));
145 146
146 if (arg->buf != NULL) 147 if (arg->buf != NULL)
@@ -341,18 +342,27 @@ gendata_h48k2(gendata_h48_arg_t *arg)
341 }; 342 };
342 343
343 i = 0; 344 i = 0;
345int jj = 0;
344 for (kv = h48map_nextkvpair(&shortcubes, &i); 346 for (kv = h48map_nextkvpair(&shortcubes, &i);
345 i != shortcubes.capacity; 347 i != shortcubes.capacity;
346 kv = h48map_nextkvpair(&shortcubes, &i) 348 kv = h48map_nextkvpair(&shortcubes, &i)
347 ) { 349 ) {
348 /* TODO maybe over all sim? */
349 dfsarg.cube = invcoord_h48(kv.key, arg->crep, 11); 350 dfsarg.cube = invcoord_h48(kv.key, arg->crep, 11);
351
352#if 1
350 gendata_h48k2_dfs(&dfsarg); 353 gendata_h48k2_dfs(&dfsarg);
354#else
355 /* It looks like this is not necessary, we get the same result */
356 _foreach_h48sim(
357 dfsarg.cube, arg->cocsepdata, arg->selfsim, arg->h,
358 gendata_h48k2_dfs(&dfsarg);
359 )
360#endif
361if ((++jj) % 1000 == 0) LOG("Done %d distance 8 cubes\n", jj);
351 } 362 }
352 363
353 h48map_destroy(&shortcubes); 364 h48map_destroy(&shortcubes);
354 365
355 /* TODO: move info update to dfs? */
356 memset(arg->info, 0, 5 * sizeof(arg->info[0])); 366 memset(arg->info, 0, 5 * sizeof(arg->info[0]));
357 arg->info[0] = base[arg->k]; 367 arg->info[0] = base[arg->k];
358 for (j = 0; j < H48_COORDMAX(arg->h); j++) { 368 for (j = 0; j < H48_COORDMAX(arg->h); j++) {
@@ -367,7 +377,7 @@ gendata_h48k2_return_size:
367_static void 377_static void
368gendata_h48k2_dfs(h48k2_dfs_arg_t *arg) 378gendata_h48k2_dfs(h48k2_dfs_arg_t *arg)
369{ 379{
370 uint8_t nmoves; 380 uint8_t nmoves, oldval, newval;
371 uint64_t val; 381 uint64_t val;
372 int64_t coord, fullcoord; 382 int64_t coord, fullcoord;
373 h48k2_dfs_arg_t nextarg; 383 h48k2_dfs_arg_t nextarg;
@@ -378,12 +388,13 @@ gendata_h48k2_dfs(h48k2_dfs_arg_t *arg)
378 388
379 val = h48map_value(arg->shortcubes, fullcoord); 389 val = h48map_value(arg->shortcubes, fullcoord);
380 390
381 if (arg->depth >= arg->base && arg->depth <= arg->base + 2) 391 if (arg->depth >= arg->base && arg->depth <= arg->base + 2) {
382 set_esep_pval( 392 oldval = get_esep_pval(arg->h48data, coord, arg->k);
383 arg->h48data, coord, arg->k, arg->depth - arg->base); 393 newval = _min(oldval, arg->depth - arg->base);
394 set_esep_pval(arg->h48data, coord, arg->k, newval);
395 }
384 396
385 if ((val < arg->shortdepth) || 397 if ((arg->depth > arg->shortdepth && val != MAP_UNSET_VAL) ||
386 (arg->depth > arg->shortdepth && val != MAP_UNSET) ||
387 (arg->depth >= arg->maxdepth || arg->depth >= arg->base + 2)) 398 (arg->depth >= arg->maxdepth || arg->depth >= arg->base + 2))
388 return; 399 return;
389 400

Generated with cgit - Back to sebastiano.tronto.net