diff options
| author | Julian Weigt <juw@posteo.de> | 2026-01-20 11:03:43 +0100 |
|---|---|---|
| committer | Julian Weigt <juw@posteo.de> | 2026-02-04 15:56:59 +0100 |
| commit | 8026d05da941092a1f7522c9eb07d44cd17c7b61 (patch) | |
| tree | 0bf26f9d1260e554930bc9e8338e2cd2464c00ed /charf.c | |
| parent | 4e078ee11a5c984fe90d71187093becab0c97191 (diff) | |
Fix first two function values to be 1 0.
Diffstat (limited to 'charf.c')
| -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; |
