From a125e69c8ce0a2764b1e50b2dad0a4fa9d141ef4 Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Tue, 6 Sep 2022 18:00:40 +0200 Subject: Symcoord version of nissy. Interesting idea, but performance are actually slower. AT THIS STAGE NISSY IS NOT USABLE. --- src/utils.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/utils.c') diff --git a/src/utils.c b/src/utils.c index e0d3268..cbf951e 100644 --- a/src/utils.c +++ b/src/utils.c @@ -1,3 +1,5 @@ +#define UTILS_C + #include "utils.h" void @@ -159,24 +161,24 @@ is_perm(int *a, int n) { int *aux = malloc(n * sizeof(int)); int i; + bool ret = true; for (i = 0; i < n; i++) aux[i] = 0; for (i = 0; i < n; i++) { if (a[i] < 0 || a[i] >= n) - return false; + ret = false; else aux[a[i]] = 1; } for (i = 0; i < n; i++) if (!aux[i]) - return false; + ret = false; free(aux); - - return true; + return ret; } bool @@ -195,7 +197,7 @@ perm_sign(int *a, int n) { int i, j, ret = 0; - if (!is_perm(a,n)) + if (!is_perm(a, n)) return -1; for (i = 0; i < n; i++) @@ -211,7 +213,7 @@ perm_to_index(int *a, int n) int i, j, c, ret = 0; if (!is_perm(a, n)) - return -1; + return factorial(n); for (i = 0; i < n; i++) { c = 0; -- cgit v1.3