#include #include #include #include #include #ifndef EXACT #define EXACT false #endif #define NUM_THREADS 6 #if EXACT #include "ratio.h" #define VALUETYPE rational #define EXPTYPE unsigned int #else #include "double.h" #define VALUETYPE double #define EXPTYPE double #endif /*length of the support of f*/ static const int N=16; /*order of the derivative to consider. Should not be larger than (D-N)/2 because then the support of f^{(K)} reaches outside of our domain.*/ static const int K=12; /*length of the domain, minimum N+2*K to make sure the support of f^{(k)} belongs to the domain*/ static const int D=N+2*K; /*given function df[0] on domain [0,D-1], compute derivatives f' until f^{(K)} and store them in df[1] to df[K]*/ void differentiate(VALUETYPE* f, VALUETYPE* df){ /*Set zeroth derivative to be f.*/ for(int i=0; i> i) & 1); //if(i%3==0) f[2*N+i+K/2] = 1; } double max = 1.0; unsigned int max_operations_per_variable = 1; VALUETYPE Mf[D]; compute_maximalfunction(f, Mf); max_operations_per_variable += (D-1)*(1+max_operations_per_variable); //sum of nominators and denominators max_operations_per_variable += 2*(1+max_operations_per_variable)+1; //division of nominator and denominator /*Allocate memory for derivatives.*/ VALUETYPE df[D]; VALUETYPE dMf[D]; /*Compute Kth derivative of f and Mf*/ differentiate(f,df); differentiate(Mf,dMf); max = max*(1<.4997) if(to_double(r)>.65) { printf("f: "); for(int i=0;ip); int* s = args->t; while(*s <= (1 << N)-1){ int t = *s; *s = t+1; compute(p,t); } return NULL; } int main() { /*exponent p of the L^p norm to consider*/ EXPTYPE p = 1; /*Iterate over all strings of 0s and 1s with length N. Those will represent f.*/ int t = 1; //for(int t=1; t<=(1 << N)-1; t++){ //compute(N,K,D,p,t); //} struct Args args = {&p, &t}; pthread_t threads[NUM_THREADS]; int result_code; for (int i = 0; i < NUM_THREADS; i++) { printf("In main: Creating thread %d.\n", i); result_code = pthread_create(&threads[i], NULL, perform_work, &args); assert(!result_code); } // wait for each thread to complete for (int i = 0; i < NUM_THREADS; i++) { result_code = pthread_join(threads[i], NULL); assert(!result_code); printf("In main: Thread %d has ended.\n", i); } return 0; }