commit b144ec8b96b5b71e409d2a692eac64b38120c9ba
parent 8bacac732dcb2c0118e47e1bb81be855f4a0bf58
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date: Mon, 20 May 2024 17:48:47 +0200
More tests for gendata h48
Diffstat:
5 files changed, 33 insertions(+), 10 deletions(-)
diff --git a/TODO.txt b/TODO.txt
@@ -1,5 +1,4 @@
TODO
- - test h48 table by adding a parameter to stop computation at certain depth
- add back benchmark, test performance of table computation
- table generation is still slow, how to improve? profile!
selfsim could be a list of cubes (representatives)
diff --git a/src/cube_portable.h b/src/cube_portable.h
@@ -200,7 +200,7 @@ It can be seen as the composition of two "subset index" coordinates.
_static_inline int64_t
coord_fast_esep(cube_fast_t c)
{
- int64_t i, j, k, l, ret1, ret2, bit1, bit2, is1;
+ int64_t i, j, jj, k, l, ret1, ret2, bit1, bit2, is1;
for (i = 0, j = 0, k = 4, l = 4, ret1 = 0, ret2 = 0; i < 12; i++) {
/* Simple version:
@@ -220,7 +220,8 @@ coord_fast_esep(cube_fast_t c)
ret1 += bit2 * binomial[11-i][k];
k -= bit2;
- ret2 += is1 * binomial[7-j][l];
+ jj = j < 8;
+ ret2 += jj * is1 * binomial[7-(j*jj)][l];
l -= is1;
j += (1-bit2);
}
@@ -257,7 +258,7 @@ _static_inline cube_fast_t
invcoord_fast_esep(int64_t esep)
{
cube_fast_t ret;
- int64_t i, j, k, l, s, v, w, is1, set1, set2;
+ int64_t i, j, jj, k, l, s, v, w, is1, set1, set2;
uint8_t bit2, bit1;
uint8_t slice[3] = {0};
@@ -267,7 +268,8 @@ invcoord_fast_esep(int64_t esep)
for (i = 0, j = 0, k = 4, l = 4; i < 12; i++) {
v = binomial[11-i][k];
- w = binomial[7-j][l];
+ jj = j < 8;
+ w = jj * binomial[7-(j*jj)][l];
bit2 = set2 >= v;
bit1 = set1 >= w;
is1 = (1 - bit2) * bit1;
diff --git a/test/102_gendata_h48/01_h_1.in b/test/102_gendata_h48/01_h_1.in
@@ -0,0 +1 @@
+1
diff --git a/test/102_gendata_h48/01_h_1.out b/test/102_gendata_h48/01_h_1.out
@@ -0,0 +1,23 @@
+118687270
+
+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: 377
+5: 4113
diff --git a/test/102_gendata_h48/gendata_h48_tests.c b/test/102_gendata_h48/gendata_h48_tests.c
@@ -1,23 +1,20 @@
#include "../test.h"
-#define MAXH 1
#define MAXDEPTH 5
#define COCSEPSIZE 1119792
#define ETABLESIZE(h) (((3393 * 495 * 70) >> 1) << (h))
-#define SIZE (60000000 << MAXH)
-
-uint32_t buf[SIZE/4];
size_t gendata_h48(void *, uint8_t, uint8_t);
int main(void) {
char str[STRLENMAX];
uint8_t h, i;
- uint32_t *h48info;
+ uint32_t *buf, *h48info;
size_t result;
fgets(str, STRLENMAX, stdin);
h = atoi(str);
+ buf = (uint32_t *)malloc(sizeof(uint32_t) * (60000000 << h));
result = gendata_h48(buf, h, MAXDEPTH);
h48info = buf + (ETABLESIZE(h) + COCSEPSIZE) / 4;
@@ -33,5 +30,6 @@ int main(void) {
for (i = 0; i < MAXDEPTH+1; i++)
printf("%" PRIu32 ": %" PRIu32 "\n", i, h48info[i+1]);
+ free(buf);
return 0;
}