From 30f57f8a87bc46a64527987d97bc37706076ba40 Mon Sep 17 00:00:00 2001 From: Julian Weigt Date: Wed, 7 Jan 2026 22:25:38 +0000 Subject: Print if and only if it beats previous record. --- charf.c | 90 ++++++++++++++++++++++++++++++++++++++++++---------------- double-error.c | 2 +- ratio.c | 5 +++- 3 files changed, 70 insertions(+), 27 deletions(-) diff --git a/charf.c b/charf.c index c6a32c3..d6da18b 100644 --- a/charf.c +++ b/charf.c @@ -31,16 +31,19 @@ /*maximum length of the support of f*/ static const int N=24; +/*maximal order of derivative*/ +static const int K=24; + /*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){ +void differentiate(VALUETYPE* f, VALUETYPE* df, int D, int k){ VALUETYPE df0[D]; /*Set zeroth derivative to be f.*/ for(int i=0; i.9) - //|| - //(k==2 && t>=.5) - //|| + ( + (k==1 && t>=1) + || + (k==2 && t>=.5) + || (k==3 && t>.53) - //|| - //(k==4 && t>=.5) + || + (k==4 && t>=.5) || (k==5 && t>=.58) || @@ -191,13 +196,36 @@ void compute(EXPTYPE p, int D, VALUETYPE* f){ (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])) ){ - printf("f: "); - for(int i=0; i num_thread; + VALUETYPE* records = args -> records; + int* domain_current = args -> domain_current; + /*exponent p of the L^p norm to consider*/ EXPTYPE p = int_to_exptype(1); VALUETYPE f[N]; int d = generate_function(f,i); while(d >= 0){ - compute(p,d,f); + if(d>*domain_current){ + *domain_current=d; + printf("Start considering length: %d\n",d); + } + compute(p,d,f,records); i += NUM_THREADS; d = generate_function(f,i); } } int main() { - /*exponent p of the L^p norm to consider*/ - EXPTYPE p = int_to_exptype(1); - pthread_t threads[NUM_THREADS]; - int args[NUM_THREADS]; + Args args[NUM_THREADS]; + VALUETYPE records[K+1]; + int domain_current = 0; + for(int k=0; k<=K; k++) records[k] = int_to_valuetype(0); int result_code; for (int i = 0; i < NUM_THREADS; i++) { printf("In main: Creating thread %d.\n", i); - args[i] = i; + args[i].records = records; + args[i].num_thread = i; + args[i].domain_current = &domain_current; result_code = pthread_create(&threads[i], NULL, compute_chunk, args+i); } diff --git a/double-error.c b/double-error.c index 7d11a92..672956f 100644 --- a/double-error.c +++ b/double-error.c @@ -40,7 +40,7 @@ double_error difference(double_error de1, double_error de2){ return sum(de1,de2m); } -bool is_greater(double_error de1, double_error de2){ return (de1.v > de2.v); } +bool is_greater(double_error de1, double_error de2){ return ((1+EPS)*(de1.v+de1.e) > de2.v-de2.e); } double_error maximum(double_error de1, double_error de2){ double_error de; diff --git a/ratio.c b/ratio.c index ad2b0ea..4b5c56b 100644 --- a/ratio.c +++ b/ratio.c @@ -84,7 +84,10 @@ rational difference(rational r1, rational r2){ return sum(r1,r2); } -bool is_greater(rational r1, rational r2){ return !(difference(r1,r2).s); } +bool is_greater(rational r1, rational r2){ + rational diff = difference(r1,r2); + return !diff.s && diff.n > 0; +} rational maximum(rational r1, rational r2){ if(is_greater(r1,r2)) return r1; -- cgit v1.2.3