Compare commits
2 Commits
f8eadd3523
...
6ac08cee1b
Author | SHA1 | Date |
---|---|---|
Miguel M | 6ac08cee1b | |
Miguel M | 2d7abc6dee |
29
src/main.c
29
src/main.c
|
@ -1,6 +1,7 @@
|
|||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "../includes/cg.h"
|
||||
#include "../includes/matrix.h"
|
||||
|
@ -34,9 +35,9 @@ static inline void ResetConditionalPermutations(
|
|||
|
||||
int main(int argc, char *argv[]) {
|
||||
if (argc < 5) {
|
||||
fprintf(
|
||||
stderr,
|
||||
"Usage:\n ./main.exe <A outputs> <B outputs> <A inputs> <B inputs>");
|
||||
fprintf(stderr,
|
||||
"Usage:\n ./main.exe <A outputs> <B outputs> <A inputs> <B "
|
||||
"inputs> [--cg]");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
@ -46,6 +47,11 @@ int main(int argc, char *argv[]) {
|
|||
ReadArguments(argv[3], &a_in, "A inputs");
|
||||
ReadArguments(argv[4], &b_in, "B inputs");
|
||||
|
||||
_Bool cg_format = 0;
|
||||
if (argc > 5 && strcmp(argv[5], "--cg") == 0) {
|
||||
cg_format = 1;
|
||||
}
|
||||
|
||||
size_t row_len = (a_out - 1) * (b_out - 1) * a_in * b_in +
|
||||
(a_out - 1) * a_in + (b_out - 1) * b_in + 1;
|
||||
matrix_t matrix = ParseMatrix(row_len);
|
||||
|
@ -87,9 +93,11 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
for (size_t i = 0; i < a_in; i++) {
|
||||
a_out_perms[i] = PermutationNewGenerator(a_out);
|
||||
PermutationReset(a_out_perms + i);
|
||||
}
|
||||
for (size_t i = 0; i < b_in; i++) {
|
||||
b_out_perms[i] = PermutationNewGenerator(b_out);
|
||||
PermutationReset(b_out_perms + i);
|
||||
}
|
||||
|
||||
// Start testing for equivalences.
|
||||
|
@ -179,16 +187,15 @@ int main(int argc, char *argv[]) {
|
|||
// Print every unique row
|
||||
for (size_t i = 0; i < row_count; i++) {
|
||||
if (!seen[i]) {
|
||||
#ifdef RELEASE
|
||||
PrintMatrixRow(&matrix, i);
|
||||
#else
|
||||
printf("%zu: ", i);
|
||||
PrintCg(a_out, b_out, a_in, b_in, matrix.head + i * matrix.row_len);
|
||||
#endif
|
||||
if (cg_format) {
|
||||
printf("%zu: ", i);
|
||||
PrintCg(a_out, b_out, a_in, b_in, matrix.head + i * matrix.row_len);
|
||||
} else {
|
||||
PrintMatrixRow(&matrix, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef RELEASE
|
||||
// Free all the mmeory so the sanitizer is happy.
|
||||
free(seen);
|
||||
free(cg_buf);
|
||||
|
@ -204,7 +211,5 @@ int main(int argc, char *argv[]) {
|
|||
}
|
||||
free(b_out_perms);
|
||||
MatrixFree(&matrix);
|
||||
#endif
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue