From 0042fb6e41e5201b39f57351ad33e7f940095775 Mon Sep 17 00:00:00 2001 From: Julian Weigt Date: Wed, 21 Jan 2026 11:21:24 +0100 Subject: Remove duplicates that come from multiple copies or translations from each function generation. --- charf.c | 50 ++++++++++++++++++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 16 deletions(-) (limited to 'charf.c') diff --git a/charf.c b/charf.c index 4ffbb54..27d4a4a 100644 --- a/charf.c +++ b/charf.c @@ -155,24 +155,42 @@ 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=0; - while(d+2 <= N){ - /*number of strings of length d that are not all 0s or all 1s*/ - int powd = 1<= powd){ - s += powd; - d++; - } - else { - int t = i-s; - /*Set f to the values encoded in bit string t which is a value between 1 and powd = (1<> n) & 1); - return d+2; + int d=2; + /*number of strings of length d that begin with 1 but are not all 1*/ + for(s=0; i-s >= (1<<(d-1))-1; d++) s += (1<<(d-1))-1; + + if(d>N) return -1; + + /*t starts with 1 and then comes i-s.*/ + int t = (1 << d-1) + i-s; + + /*Indicates if we want to consider this t.*/ + bool is_representative = true; + + /*Check if t encodes a function that is made up of translations of a shorter function.*/ + for(int r = 1; r < d; r++){ + if(d % r == 0){ + bool is_r_copy = true; + int ones = 0; + for(int o = 0; o>n*r) & ones ) != tail ) is_r_copy = false; + if(is_r_copy) is_representative = false; } } - return -1; + + /*Check if t encodes the strictly largest of its equivalent translates.*/ + /*Such t which may equal its translates have already been filtered out by the previous step because they are copies of at least two shorter functions.*/ + int ones = 0; + for(int o = 0; o>(d-n)) & ones) ) is_representative = false; + + /*Set f to the values encoded in bit string t which is a value between 1 and powd = (1<> (d-n-1)) & 1); + return d; + } + else return 0; } int generate_triangle(VALUETYPE* f, int i){ -- cgit v1.2.3