From 45fd7ef76536fdf78810e63f978bd3fc0be43537 Mon Sep 17 00:00:00 2001 From: Julian Weigt Date: Fri, 16 Jan 2026 16:15:22 +0100 Subject: - Introduce matrix that contains derivatives and exponents of interest. - Use appropriate function arguments (arrays vs pointers). --- charf.c | 129 +++++++++++++++++++++++++++++++++++++++------------------------- 1 file changed, 79 insertions(+), 50 deletions(-) (limited to 'charf.c') diff --git a/charf.c b/charf.c index 7f4f2af..bb8720f 100644 --- a/charf.c +++ b/charf.c @@ -33,10 +33,13 @@ #endif /*maximum length of the support of f*/ -static const int N=24; +#define N 24 /*maximal order of derivative*/ -static const int K=24; +#define K 24 + +/*maximal number of exponents*/ +#define P 1 /*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){ @@ -159,23 +162,28 @@ int generate_function(VALUETYPE* f, int i){ //return generate_triangle(f,i); } -void format_result(char* s, EXPTYPE p, int D, int index, int k, VALUETYPE r){ +void format_result(char* s, int index, int k, EXPTYPE p, VALUETYPE r){ VALUETYPE f[N]; int d = generate_function(f,index); sprintf(s,"f: "); int l = 3; - 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) ; } -bool compute(EXPTYPE p, int D, VALUETYPE* f, int index, VALUETYPE* records_ratio, int* records_index){ +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]){ + VALUETYPE f[N]; + int D = generate_function(f,index); + /*Immediately abort if index is out of bounds.*/ + if(D <= 0) return D; + 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.*/ compute_maximalfunction(f,Mf,D); @@ -199,93 +207,112 @@ bool compute(EXPTYPE p, int D, VALUETYPE* f, int index, VALUETYPE* records_ratio differentiate(dMf[(k+1)%2],dMf[k%2],D,1); } - /*Print derivatives*/ - /* - for(int k=0; k<=K; k++){ - printf("f %d: ",k); - for(int i=0; i num_thread; - VALUETYPE* records_ratio = args -> records_ratio; - int* records_index = args -> records_index; 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); + int d = 0; while(d >= 0){ + d = compute(i, args -> num_exponents, args -> exponents, args -> records_ratio, args -> records_index); if(d > *domain_current){ *domain_current = d; printf("Start considering length: %d\n",d); } - compute(p,d,f,i,records_ratio,records_index); i += NUM_THREADS; - d = generate_function(f,i); } } 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); + } + pthread_t threads[NUM_THREADS]; Args args[NUM_THREADS]; - VALUETYPE records_ratio[K+1]; - int records_index[K+1]; + VALUETYPE records_ratio[K+1][P]; + int records_index[K+1][P]; + for(int k=0; k<=K; k++) for(int p=0; p