From 6ceb2c20056d6cece59791686deeeac312fa6009 Mon Sep 17 00:00:00 2001 From: Julian Weigt Date: Sun, 18 Jan 2026 11:10:15 +0100 Subject: Use array for p independent of k and accordingly print grouped according to p. --- charf.c | 117 +++++++++++++++++++++++++++++++++++++++------------------------- 1 file changed, 71 insertions(+), 46 deletions(-) diff --git a/charf.c b/charf.c index 88a5d96..c33a88d 100644 --- a/charf.c +++ b/charf.c @@ -41,7 +41,7 @@ #define K 24 /*maximal number of exponents*/ -#define P 1 +#define P 2 /*given function df[0] on domain [0,M-1], compute derivatives f' until f^{(K)} and store f^{(K)} in df*/ void differentiate(VALUETYPE* f, VALUETYPE* df, int D, int k){ @@ -182,7 +182,7 @@ void format_result(char* s, int index, int k, EXPTYPE p, VALUETYPE r, int format int l = 0; char v[128]; root_to_latex(v,r,p); - l += sprintf(s+l,"$%d$ & $\\frac1{%1.0f}$ & %s",k,exptype_to_double(p),v); + l += sprintf(s+l,"$%d$ & %s",k,v); 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) ; } -int compute(int index, int num_exponents[K+1], EXPTYPE exponents[K+1][P], VALUETYPE (*records_ratio)[K+1][P], int (*records_index)[K+1][P]){ +int compute(int index, EXPTYPE exponents[P], VALUETYPE (*records_ratio)[K+1][P], int (*records_index)[K+1][P]){ VALUETYPE f[N]; int D = generate_function(f,index); /*Immediately abort if index is out of bounds.*/ @@ -224,7 +224,7 @@ int compute(int index, int num_exponents[K+1], EXPTYPE exponents[K+1][P], VALUET differentiate(dMf[(k+1)%2],dMf[k%2],D,1); } - for(int p=0; p= 0){ - d = compute(i, args -> num_exponents, args -> exponents, args -> records_ratio, args -> records_index); + d = compute(i, args -> exponents, args -> records_ratio, args -> records_index); if(d > *domain_current){ *domain_current = d; printf("Start considering length: %d\n",d); @@ -329,25 +358,21 @@ void* compute_chunk(void* arguments){ int main() { int num_exponents[K+1]; - EXPTYPE exponents[K+1][P]; - for(int k=0; k<=K; k++){ - num_exponents[k] = 1; - exponents[k][0] = int_to_exptype(1); - //exponents[k][1] = int_to_exptype(2); - } + EXPTYPE exponents[P]; + exponents[0] = int_to_exptype(1); + exponents[1] = int_to_exptype(2); pthread_t threads[NUM_THREADS]; Args args[NUM_THREADS]; VALUETYPE records_ratio[K+1][P]; int records_index[K+1][P]; - for(int k=0; k<=K; k++) for(int p=0; p