diff options
| -rw-r--r-- | charf.c | 16 |
1 files changed, 9 insertions, 7 deletions
@@ -16,7 +16,7 @@ #define MODE DOUBLEMODE #endif -#define NUM_THREADS 6 +#define NUM_THREADS 7 #if MODE == DOUBLEERRORMODE #include "double-error.h" @@ -155,19 +155,21 @@ void compute_maximalfunction(VALUETYPE* f, VALUETYPE* Mf, int D){ /*Generates all characteristic functions of length up N.*/ int generate_each_charf(VALUETYPE* f, int i){ int s=0; - int d=2; - while(d <= N){ + int d=0; + while(d+2 <= N){ /*number of strings of length d that are not all 0s or all 1s*/ - int powd = (1<<d)-2; + int powd = 1<<d; if(i-s >= powd){ s += powd; d++; } else { - int t = i-s+1; + int t = i-s; /*Set f to the values encoded in bit string t which is a value between 1 and powd = (1<<d)-2.*/ - for(int n=0; n<d; n++) f[n] = int_to_valuetype((t >> n) & 1); - return d; + f[0] = int_to_valuetype(1); + f[1] = int_to_valuetype(0); + for(int n=0; n<d; n++) f[2+n] = int_to_valuetype((t >> n) & 1); + return d+2; } } return -1; |
