diff options
| -rw-r--r-- | charf.c | 20 |
1 files changed, 18 insertions, 2 deletions
@@ -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; |
