diff options
| -rw-r--r-- | TODO.txt | 1 | ||||
| -rw-r--r-- | src/cube_portable.h | 10 | ||||
| -rw-r--r-- | test/102_gendata_h48/01_h_1.in | 1 | ||||
| -rw-r--r-- | test/102_gendata_h48/01_h_1.out | 23 | ||||
| -rw-r--r-- | test/102_gendata_h48/gendata_h48_tests.c | 8 |
5 files changed, 33 insertions, 10 deletions
| @@ -1,5 +1,4 @@ | |||
| 1 | TODO | 1 | TODO |
| 2 | - test h48 table by adding a parameter to stop computation at certain depth | ||
| 3 | - add back benchmark, test performance of table computation | 2 | - add back benchmark, test performance of table computation |
| 4 | - table generation is still slow, how to improve? profile! | 3 | - table generation is still slow, how to improve? profile! |
| 5 | selfsim could be a list of cubes (representatives) | 4 | selfsim could be a list of cubes (representatives) |
diff --git a/src/cube_portable.h b/src/cube_portable.h index cb4d8fc..e72c169 100644 --- 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. | |||
| 200 | _static_inline int64_t | 200 | _static_inline int64_t |
| 201 | coord_fast_esep(cube_fast_t c) | 201 | coord_fast_esep(cube_fast_t c) |
| 202 | { | 202 | { |
| 203 | int64_t i, j, k, l, ret1, ret2, bit1, bit2, is1; | 203 | int64_t i, j, jj, k, l, ret1, ret2, bit1, bit2, is1; |
| 204 | 204 | ||
| 205 | for (i = 0, j = 0, k = 4, l = 4, ret1 = 0, ret2 = 0; i < 12; i++) { | 205 | for (i = 0, j = 0, k = 4, l = 4, ret1 = 0, ret2 = 0; i < 12; i++) { |
| 206 | /* Simple version: | 206 | /* Simple version: |
| @@ -220,7 +220,8 @@ coord_fast_esep(cube_fast_t c) | |||
| 220 | ret1 += bit2 * binomial[11-i][k]; | 220 | ret1 += bit2 * binomial[11-i][k]; |
| 221 | k -= bit2; | 221 | k -= bit2; |
| 222 | 222 | ||
| 223 | ret2 += is1 * binomial[7-j][l]; | 223 | jj = j < 8; |
| 224 | ret2 += jj * is1 * binomial[7-(j*jj)][l]; | ||
| 224 | l -= is1; | 225 | l -= is1; |
| 225 | j += (1-bit2); | 226 | j += (1-bit2); |
| 226 | } | 227 | } |
| @@ -257,7 +258,7 @@ _static_inline cube_fast_t | |||
| 257 | invcoord_fast_esep(int64_t esep) | 258 | invcoord_fast_esep(int64_t esep) |
| 258 | { | 259 | { |
| 259 | cube_fast_t ret; | 260 | cube_fast_t ret; |
| 260 | int64_t i, j, k, l, s, v, w, is1, set1, set2; | 261 | int64_t i, j, jj, k, l, s, v, w, is1, set1, set2; |
| 261 | uint8_t bit2, bit1; | 262 | uint8_t bit2, bit1; |
| 262 | uint8_t slice[3] = {0}; | 263 | uint8_t slice[3] = {0}; |
| 263 | 264 | ||
| @@ -267,7 +268,8 @@ invcoord_fast_esep(int64_t esep) | |||
| 267 | 268 | ||
| 268 | for (i = 0, j = 0, k = 4, l = 4; i < 12; i++) { | 269 | for (i = 0, j = 0, k = 4, l = 4; i < 12; i++) { |
| 269 | v = binomial[11-i][k]; | 270 | v = binomial[11-i][k]; |
| 270 | w = binomial[7-j][l]; | 271 | jj = j < 8; |
| 272 | w = jj * binomial[7-(j*jj)][l]; | ||
| 271 | bit2 = set2 >= v; | 273 | bit2 = set2 >= v; |
| 272 | bit1 = set1 >= w; | 274 | bit1 = set1 >= w; |
| 273 | is1 = (1 - bit2) * bit1; | 275 | is1 = (1 - bit2) * bit1; |
diff --git a/test/102_gendata_h48/01_h_1.in b/test/102_gendata_h48/01_h_1.in new file mode 100644 index 0000000..d00491f --- /dev/null +++ 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 new file mode 100644 index 0000000..56b7066 --- /dev/null +++ b/test/102_gendata_h48/01_h_1.out | |||
| @@ -0,0 +1,23 @@ | |||
| 1 | 118687270 | ||
| 2 | |||
| 3 | cocsepdata: | ||
| 4 | Classes: 3393 | ||
| 5 | Max value: 9 | ||
| 6 | 0: 1 | ||
| 7 | 1: 6 | ||
| 8 | 2: 63 | ||
| 9 | 3: 468 | ||
| 10 | 4: 3068 | ||
| 11 | 5: 15438 | ||
| 12 | 6: 53814 | ||
| 13 | 7: 71352 | ||
| 14 | 8: 8784 | ||
| 15 | 9: 96 | ||
| 16 | |||
| 17 | h48: | ||
| 18 | 0: 1 | ||
| 19 | 1: 1 | ||
| 20 | 2: 4 | ||
| 21 | 3: 34 | ||
| 22 | 4: 377 | ||
| 23 | 5: 4113 | ||
diff --git a/test/102_gendata_h48/gendata_h48_tests.c b/test/102_gendata_h48/gendata_h48_tests.c index 35e6f42..9d96e75 100644 --- a/test/102_gendata_h48/gendata_h48_tests.c +++ b/test/102_gendata_h48/gendata_h48_tests.c | |||
| @@ -1,23 +1,20 @@ | |||
| 1 | #include "../test.h" | 1 | #include "../test.h" |
| 2 | 2 | ||
| 3 | #define MAXH 1 | ||
| 4 | #define MAXDEPTH 5 | 3 | #define MAXDEPTH 5 |
| 5 | #define COCSEPSIZE 1119792 | 4 | #define COCSEPSIZE 1119792 |
| 6 | #define ETABLESIZE(h) (((3393 * 495 * 70) >> 1) << (h)) | 5 | #define ETABLESIZE(h) (((3393 * 495 * 70) >> 1) << (h)) |
| 7 | #define SIZE (60000000 << MAXH) | ||
| 8 | |||
| 9 | uint32_t buf[SIZE/4]; | ||
| 10 | 6 | ||
| 11 | size_t gendata_h48(void *, uint8_t, uint8_t); | 7 | size_t gendata_h48(void *, uint8_t, uint8_t); |
| 12 | 8 | ||
| 13 | int main(void) { | 9 | int main(void) { |
| 14 | char str[STRLENMAX]; | 10 | char str[STRLENMAX]; |
| 15 | uint8_t h, i; | 11 | uint8_t h, i; |
| 16 | uint32_t *h48info; | 12 | uint32_t *buf, *h48info; |
| 17 | size_t result; | 13 | size_t result; |
| 18 | 14 | ||
| 19 | fgets(str, STRLENMAX, stdin); | 15 | fgets(str, STRLENMAX, stdin); |
| 20 | h = atoi(str); | 16 | h = atoi(str); |
| 17 | buf = (uint32_t *)malloc(sizeof(uint32_t) * (60000000 << h)); | ||
| 21 | result = gendata_h48(buf, h, MAXDEPTH); | 18 | result = gendata_h48(buf, h, MAXDEPTH); |
| 22 | h48info = buf + (ETABLESIZE(h) + COCSEPSIZE) / 4; | 19 | h48info = buf + (ETABLESIZE(h) + COCSEPSIZE) / 4; |
| 23 | 20 | ||
| @@ -33,5 +30,6 @@ int main(void) { | |||
| 33 | for (i = 0; i < MAXDEPTH+1; i++) | 30 | for (i = 0; i < MAXDEPTH+1; i++) |
| 34 | printf("%" PRIu32 ": %" PRIu32 "\n", i, h48info[i+1]); | 31 | printf("%" PRIu32 ": %" PRIu32 "\n", i, h48info[i+1]); |
| 35 | 32 | ||
| 33 | free(buf); | ||
| 36 | return 0; | 34 | return 0; |
| 37 | } | 35 | } |
