summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Weigt <juw@posteo.de>2026-01-20 11:03:43 +0100
committerJulian Weigt <juw@posteo.de>2026-02-04 15:56:59 +0100
commit8026d05da941092a1f7522c9eb07d44cd17c7b61 (patch)
tree0bf26f9d1260e554930bc9e8338e2cd2464c00ed
parent4e078ee11a5c984fe90d71187093becab0c97191 (diff)
Fix first two function values to be 1 0.
-rw-r--r--charf.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/charf.c b/charf.c
index 041cc39..ad2da3b 100644
--- a/charf.c
+++ b/charf.c
@@ -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;