Fixed allocation size of cg_buf
This mistake was responsible for the weird overruns of `seen`. Seems to be at least partially working, need to check that permuting the players reduces the remaining 3 lines.
This commit is contained in:
parent
9cd4c8c1b1
commit
1ad3a4c813
33
src/main.c
33
src/main.c
|
@ -52,8 +52,10 @@ int main(int argc, char *argv[]) {
|
|||
size_t row_count = matrix.len / matrix.row_len;
|
||||
|
||||
data_t *p_buf = malloc(a_out * b_out * a_in * b_in * sizeof(data_t));
|
||||
data_t *cg_buf =
|
||||
malloc((a_out - 1) * (b_out - 1) * a_in * b_in * sizeof(data_t));
|
||||
data_t *cg_buf = malloc((((a_out - 1) * (b_out - 1) * a_in * b_in +
|
||||
(a_out - 1) * a_in + (b_out - 1) * b_in) +
|
||||
1) *
|
||||
sizeof(data_t));
|
||||
_Bool *seen = calloc(row_count, sizeof(_Bool));
|
||||
|
||||
if (p_buf == NULL) {
|
||||
|
@ -69,8 +71,6 @@ int main(int argc, char *argv[]) {
|
|||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
// This is a lot of separate allocations, but this section isn't expected to
|
||||
// be hot.
|
||||
permutation_generator_t a_in_perm = PermutationNewGenerator(a_in);
|
||||
permutation_generator_t b_in_perm = PermutationNewGenerator(b_in);
|
||||
permutation_generator_t *a_out_perms =
|
||||
|
@ -129,19 +129,6 @@ int main(int argc, char *argv[]) {
|
|||
a_out_perms, b_out_perms);
|
||||
FromPToCg(a_out, b_out, a_in, b_in, cg_buf, p_buf);
|
||||
|
||||
// printf("--------------\n");
|
||||
// PrintPermutation(&a_in_perm);
|
||||
// PrintPermutation(&b_in_perm);
|
||||
// for (size_t i = 0; i < a_in; i++) {
|
||||
// printf("A=%zu: ", i);
|
||||
// PrintPermutation(a_out_perms + i);
|
||||
//}
|
||||
// for (size_t i = 0; i < b_in; i++) {
|
||||
// printf("B=%zu: ", i);
|
||||
// PrintPermutation(b_out_perms + i);
|
||||
//}
|
||||
// PrintCg(a_out, b_out, a_in, b_in, cg_buf);
|
||||
|
||||
_Bool equivalent = 1;
|
||||
for (size_t i = 0; i < row_len; i++) {
|
||||
if (lhs[i] != cg_buf[i]) {
|
||||
|
@ -151,11 +138,7 @@ int main(int argc, char *argv[]) {
|
|||
}
|
||||
|
||||
if (equivalent) {
|
||||
printf("%zu equivalent to %zu\n", rhs_i, lhs_i);
|
||||
seen[rhs_i] = 1;
|
||||
for (size_t i = 0; i < row_count; i++) {
|
||||
printf("%s,", seen[i] ? "true" : "false");
|
||||
}
|
||||
goto skip_permutations;
|
||||
}
|
||||
|
||||
|
@ -177,10 +160,10 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
// Print every unique row
|
||||
for (size_t i = 0; i < row_count; i++) {
|
||||
printf("%s,", seen[i] ? "true" : "false");
|
||||
// if (!seen[i]) {
|
||||
// PrintMatrixRow(&matrix, i);
|
||||
//}
|
||||
if (!seen[i]) {
|
||||
PrintMatrixRow(&matrix, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
|
Loading…
Reference in New Issue