From de4326889c83ebebc8d880e2b4331dfa9d462674 Mon Sep 17 00:00:00 2001 From: Julian Weigt Date: Fri, 9 Jan 2026 17:13:57 +0000 Subject: Improve formulations and abstraction in c code. --- charf.c | 85 ++++++++++++++--------------------------------------------------- 1 file changed, 18 insertions(+), 67 deletions(-) diff --git a/charf.c b/charf.c index 97bc2a5..17b4b08 100644 --- a/charf.c +++ b/charf.c @@ -58,7 +58,7 @@ void differentiate(VALUETYPE* f, VALUETYPE* df, int D, int k){ /*given function f on domain [0,D-1] compute pth root of integral of |f|^p*/ VALUETYPE integratep(VALUETYPE* f, EXPTYPE p, int D){ VALUETYPE integralp = int_to_valuetype(0); - for(int i=0;i=1) || (k==2 && t>=.5) || (k==3 && t>.53) || (k==4 && t>=.5) || (k==5 && t>=.58) || (k==6 && t>=.58) || (k==7 && t>=.69) || (k==8 && t>=.83) || (k==9 && t>=.8699) || (k==10 && t>=.919) || (k==11 && t>=.97) || (k==12 && t>=.97) || (k==13 && t>=.98) || (k==14 && t>=.98) || (k==15 && t>=.9817) || (k==16 && t>=.9817) || (k==17 && t>=.987) || (k==18 && t>=.991) || (k==19 && t>=.994) || (k==20 && t>=1.001) || (k==21 && t>=1.009) || (k==22 && t>=1.009) || (k==23 && t>=1.003) || (k==24 && t>=1.174) ; +} + void compute(EXPTYPE p, int D, VALUETYPE* f, VALUETYPE* records){ VALUETYPE Mf[N]; /*This is the only O(D^2) operation in here so makes a lot of sense to only compute once and avoid repeating it.*/ @@ -126,14 +130,13 @@ void compute(EXPTYPE p, int D, VALUETYPE* f, VALUETYPE* records){ VALUETYPE df[2][N]; VALUETYPE dMf[2][N]; - for(int i=0; i=1) - || - (k==2 && t>=.5) - || - (k==3 && t>.53) - || - (k==4 && t>=.5) - || - (k==5 && t>=.58) - || - (k==6 && t>=.58) - || - (k==7 && t>=.69) - || - (k==8 && t>=.83) - || - (k==9 && t>=.8699) - || - (k==10 && t>=.919) - || - (k==11 && t>=.97) - || - (k==12 && t>=.97) - || - (k==13 && t>=.98) - || - (k==14 && t>=.98) - || - (k==15 && t>=.9817) - || - (k==16 && t>=.9817) - || - (k==17 && t>=.987) - || - (k==18 && t>=.991) - || - (k==19 && t>=.994) - || - (k==20 && t>=1.001) - || - (k==21 && t>=1.009) - || - (k==22 && t>=1.009) - || - (k==23 && t>=1.003) - || - (k==24 && t>=1.174) - ) - && - (is_greater(r,records[k])) - ){ + if(over_threshold_charf(t,k) && is_greater(r,records[k])){ /*extra check for printing only because in error mode for some reason floats randomly seem to increase by tiny amounts*/ if(t>to_double(records[k])){ char s[256]; @@ -269,8 +220,8 @@ void* compute_chunk(void* arguments){ VALUETYPE f[N]; int d = generate_function(f,i); while(d >= 0){ - if(d>*domain_current){ - *domain_current=d; + if(d > *domain_current){ + *domain_current = d; printf("Start considering length: %d\n",d); } compute(p,d,f,records); -- cgit v1.2.3