From c599e6b5c5bb1890311caf169d58eea97a12c9d6 Mon Sep 17 00:00:00 2001 From: Julian Weigt Date: Wed, 7 Jan 2026 19:56:16 +0000 Subject: Kinda add flexibility to vary K or p within one call. --- charf.c | 35 +++++++++++++---------------------- 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/charf.c b/charf.c index 0508cc4..6c8943b 100644 --- a/charf.c +++ b/charf.c @@ -31,11 +31,8 @@ /*length of the support of f*/ static const int N=16; -/*order of the derivative to consider.*/ -static const int K=3; - -/*given function df[0] on domain [0,M-1], compute derivatives f' until f^{(K)} and store them in df[1] to df[K]*/ -void differentiate(VALUETYPE* f, VALUETYPE* df, int D){ +/*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){ VALUETYPE df0[D]; /*Set zeroth derivative to be f.*/ for(int i=0; ip; - int i = args->i; + int i = *((int*)arguments); + int K = 3; + EXPTYPE p = to_exptype(1); VALUETYPE f[N]; int d = generate_function(f,i); while(d >= 0){ - compute(p,d,f); + compute(K,p,d,f); i += NUM_THREADS; d = generate_function(f,i); } @@ -214,13 +205,13 @@ int main() { EXPTYPE p = to_exptype(1); pthread_t threads[NUM_THREADS]; - Args args[NUM_THREADS]; + int args[NUM_THREADS]; int result_code; for (int i = 0; i < NUM_THREADS; i++) { printf("In main: Creating thread %d.\n", i); - args[i] = (Args){.p=p, .i=i}; - result_code = pthread_create(&threads[i], NULL, compute_chunk, &(args[i])); + args[i] = i; + result_code = pthread_create(&threads[i], NULL, compute_chunk, args+i); } // wait for each thread to complete -- cgit v1.2.3