diff options
| author | Julian Weigt <juw@posteo.de> | 2026-01-09 17:04:30 +0000 |
|---|---|---|
| committer | Julian Weigt <juw@posteo.de> | 2026-02-04 15:55:51 +0100 |
| commit | 545a4dc4292b47bdff4b568eaafeaabea2fbb2e8 (patch) | |
| tree | bece2d2901db5f379c2f11d398f84cf4e097f38a | |
| parent | de4326889c83ebebc8d880e2b4331dfa9d462674 (diff) | |
Add triangle function as other example.
| -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; |
