Output format controlled by a flag
This commit is contained in:
parent
2d7abc6dee
commit
6ac08cee1b
27
src/main.c
27
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);
|
||||
|
@ -181,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);
|
||||
|
@ -206,7 +211,5 @@ int main(int argc, char *argv[]) {
|
|||
}
|
||||
free(b_out_perms);
|
||||
MatrixFree(&matrix);
|
||||
#endif
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue