From 11950a4a293963e7fe6e2860c9b19d896cc41396 Mon Sep 17 00:00:00 2001 From: Orestis <orestis.malaspinas@pm.me> Date: Fri, 7 Mar 2025 09:12:42 +0100 Subject: [PATCH] dates --- slides/Makefile | 3 +- slides/cours_16.md | 2 +- source_codes/complexity/.gitignore | 14 ++++++++++ source_codes/complexity/sum.c | 45 +++++++++++++++--------------- 4 files changed, 40 insertions(+), 24 deletions(-) diff --git a/slides/Makefile b/slides/Makefile index b341162..7fcd2e0 100644 --- a/slides/Makefile +++ b/slides/Makefile @@ -25,7 +25,8 @@ docker_clean: docker-compose.yml puppeteer: @echo "Setting chromium to $(CHROMIUM) for puppeteer" - @echo -e "{\n\"executablePath\":" \"$(CHROMIUM)\" ",\n\"args\": [\"--no-sandbox\"]\n}" > .puppeteer.json + # @echo -e "{\n\"executablePath\":" \"$(CHROMIUM)\" ",\n\"args\": [\"--no-sandbox\"]\n}" > .puppeteer.json + @echo "{\n\"executablePath\":" \"$(CHROMIUM)\" ",\n\"args\": [\"--no-sandbox\"]\n}" > .puppeteer.json index.md: gen_index.sh $(shell ./gen_index.sh) diff --git a/slides/cours_16.md b/slides/cours_16.md index a4a4433..222010e 100644 --- a/slides/cours_16.md +++ b/slides/cours_16.md @@ -1,6 +1,6 @@ --- title: "Arbres binaires" -date: "2024-03-07" +date: "2025-03-07" --- # Les arbres binaires diff --git a/source_codes/complexity/.gitignore b/source_codes/complexity/.gitignore index a391e6c..40bafa0 100644 --- a/source_codes/complexity/.gitignore +++ b/source_codes/complexity/.gitignore @@ -4,3 +4,17 @@ sum_one sum_one_opt sum_thousand sum_thousand_opt +search +sum +sum_one +sum_one_opt +sum_thousand +sum_thousand_opt +sum_one +sum_one_opt +sum_thousand +sum_thousand_opt +sum_one +sum_one_opt +sum_thousand +sum_thousand_opt diff --git a/source_codes/complexity/sum.c b/source_codes/complexity/sum.c index 44e9303..fbf04da 100644 --- a/source_codes/complexity/sum.c +++ b/source_codes/complexity/sum.c @@ -11,34 +11,35 @@ #endif void init(int n, double tab[]) { - for (int i = 0; i < n; ++i) { - tab[i] = (double)rand() / (double)RAND_MAX; - } + for (int i = 0; i < n; ++i) { + tab[i] = (double)rand() / (double)RAND_MAX; + } } double sum(int n, double tab[]) { - double s = tab[0]; - for (int i = 1; i < n; ++i) { - s += tab[i] * tab[i] * tab[i] * tab[i]; - } - return s; + double s = tab[0]; + for (int i = 1; i < n; ++i) { + s += tab[i] * tab[i] * tab[i] * tab[i]; + } + return s; } int main() { - double tab[SIZE]; - init(SIZE, tab); + double tab[SIZE]; + init(SIZE, tab); - struct timespec tstart = {0, 0}, tend = {0, 0}; - clock_gettime(CLOCK_MONOTONIC, &tstart); - double s = 0; - for (int i = 0; i < NUM_TIMES; ++i) { - s += sum(SIZE, tab); - } - clock_gettime(CLOCK_MONOTONIC, &tend); - printf("the computation took about %.5f seconds\n", - (((double)tend.tv_sec + 1e-9 * tend.tv_nsec) - - ((double)tstart.tv_sec + 1e-9 * tstart.tv_nsec)) / - NUM_TIMES); + struct timespec tstart = {0, 0}, tend = {0, 0}; + clock_gettime(CLOCK_MONOTONIC, &tstart); + double s = 0; + for (int i = 0; i < NUM_TIMES; ++i) { + s += sum(SIZE, tab); + } + clock_gettime(CLOCK_MONOTONIC, &tend); + printf("the computation took about %.15f seconds\n", + (((double)tend.tv_sec + 1e-9 * tend.tv_nsec) - + ((double)tstart.tv_sec + 1e-9 * tstart.tv_nsec)) / + NUM_TIMES); + printf("%lf\n", s); - return 0; + return 0; } -- GitLab