From 545a4dc4292b47bdff4b568eaafeaabea2fbb2e8 Mon Sep 17 00:00:00 2001 From: Julian Weigt Date: Fri, 9 Jan 2026 17:04:30 +0000 Subject: Add triangle function as other example. --- charf.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'charf.c') diff --git a/charf.c b/charf.c index 17b4b08..6a35d3f 100644 --- a/charf.c +++ b/charf.c @@ -184,8 +184,8 @@ void compute(EXPTYPE p, int D, VALUETYPE* f, VALUETYPE* records){ } } -/*Writes into f the values of the function indexed by i. Returns the size of the support of f, or -1 if there is no function with that index.*/ -int generate_function(VALUETYPE* f, int i){ +/*Generates all characteristic functions of length up N.*/ +int generate_each_charf(VALUETYPE* f, int i){ int s=0; int d=1; while(d <= N){ @@ -203,7 +203,23 @@ int generate_function(VALUETYPE* f, int i){ } } return -1; +} + +int generate_triangle(VALUETYPE* f, int i){ + int j = i+1; + if(j <= N/2){ + for(int n=0; n < N; n++) f[n] = int_to_valuetype(0); + for(int n=0; n < j; n++) f[n] = int_to_valuetype(j-n); + for(int n=1; n < j; n++) f[N-n] = int_to_valuetype(j-n); + return N; + } + else return -1; +} +/*Writes into f the values of the function indexed by i. Returns the size of the support of f, or -1 if there is no function with that index.*/ +int generate_function(VALUETYPE* f, int i){ + return generate_each_charf(f,i); + //return generate_triangle(f,i); } typedef struct { VALUETYPE* records; int num_thread; int* domain_current; } Args; -- cgit v1.2.3