summaryrefslogtreecommitdiff
path: root/charf.c
diff options
context:
space:
mode:
authorJulian Weigt <juw@posteo.de>2026-01-16 16:48:41 +0100
committerJulian Weigt <juw@posteo.de>2026-02-04 15:55:54 +0100
commiteefbfcdfc2f2374dcba95a62c31f3162e2247853 (patch)
tree8a2a2911c7c9d7f1a82f6e0943653daf14b15c02 /charf.c
parentfe85dc4e65d2aea155fbe201ff6378fcc9af0718 (diff)
Print all results when finished, make printing prettier.
Diffstat (limited to 'charf.c')
-rw-r--r--charf.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/charf.c b/charf.c
index e9b3ba7..b635391 100644
--- a/charf.c
+++ b/charf.c
@@ -171,7 +171,7 @@ void format_result(char* s, int index, int k, EXPTYPE p, VALUETYPE r){
for(int i=d; i<N; i++) l += sprintf(s+l," ");
char rts[128];
root_to_string(rts,r,p);
- l += sprintf(s+l,"%dth der.: %s",k,rts);
+ l += sprintf(s+l,"|f^(%d)|_1/%2.1f: %s",k,inv_exptype_to_double(p),rts);
}
bool over_threshold_charf(double t, int k){
@@ -256,7 +256,7 @@ void print_records(int num_exponents[K+1], EXPTYPE exponents[K+1][P], VALUETYPE
}
}
-typedef struct { int num_exponents[K+1]; EXPTYPE exponents[K+1][P]; VALUETYPE (*records_ratio)[K+1][P]; int (*records_index)[K+1][P]; int num_thread; int* domain_current; } Args;
+typedef struct { int num_exponents[K+1]; EXPTYPE exponents[K+1][P]; VALUETYPE (*records_ratio)[K+1][P]; int (*records_index)[K+1][P]; int num_thread; int* domain_current; int* cont; } Args;
/*Goes through all functions indexed by those numbers which equal the thread number module NUM_THREADS.*/
void* compute_chunk(void* arguments){
@@ -272,7 +272,9 @@ void* compute_chunk(void* arguments){
printf("Start considering length: %d\n",d);
}
i += NUM_THREADS;
- }
+ }
+ (*(args -> cont))++;
+ if(*(args -> cont) >= NUM_THREADS) printf("Calculation finished. Press any button to stop.\n");
}
int main() {
@@ -290,6 +292,7 @@ int main() {
for(int k=0; k<=K; k++) for(int p=0; p<num_exponents[k]; p++) records_ratio[k][p] = int_to_valuetype(0);
int domain_current = 0;
int result_code;
+ int cont = 0;
for (int i = 0; i < NUM_THREADS; i++) {
printf("In main: Creating thread %d.\n", i);
@@ -299,13 +302,13 @@ int main() {
args[i].records_index = &records_index;
args[i].num_thread = i;
args[i].domain_current = &domain_current;
+ args[i].cont = &cont;
result_code = pthread_create(&threads[i], NULL, compute_chunk, args+i);
}
size_t sz = 1024;
char prmpt[] = "To exit enter q, quit or exit.\nTo print current records to terminal enter r.\nTo print current records to a file enter p.\nTo do so with tex formatting enter t.\n";
char buff[sz];
- bool cont = true;
do {
getLine(prmpt, buff, sz);
if( 0 == strcmp(buff,"q") || 0 == strcmp(buff,"quit") || 0 == strcmp(buff,"exit") ){
@@ -313,7 +316,7 @@ int main() {
exit(EXIT_SUCCESS);
}
else if( 0 == strcmp(buff,"r")) print_records(num_exponents,exponents,records_ratio,records_index);
- } while(cont);
+ } while(cont < NUM_THREADS);
// wait for each thread to complete
for (int i = 0; i < NUM_THREADS; i++) {