From: Laurent Mazet Date: Tue, 7 Oct 2025 21:57:54 +0000 (+0200) Subject: first functional code X-Git-Url: https://secure.softndesign.org/git/?a=commitdiff_plain;h=4ed9b75af070ef64d3fd6d9d4e9fb31769a485a1;p=benchmarks.git first functional code --- diff --git a/load.c b/load.c index f2a2d0f..3726d33 100644 --- a/load.c +++ b/load.c @@ -3,19 +3,14 @@ /* linker: */ #include +//#include #include #include /* constants */ -#define MAXSIZE 16; - -/* types */ - -typedef struct { - int n; - double *mat; -} matrix_t; +//#define N 32 +#define N 10 /* static variables */ @@ -24,6 +19,13 @@ char *version = "0.1"; int nb_threads = 1; +/* types */ + +typedef struct { + int n; + double *mat; +} matrix_t; + /* usage function */ int usage (int ret) @@ -108,10 +110,22 @@ double determinant (matrix_t *matrix) get_matrix (matrix, 0, l, &val); det += sign * val * determinant (comatrix); } + free_matrix (comatrix); return det; } +void generate_matrix (matrix_t *matrix) +{ + double base = 10 * drand48 () - 5; + for (int i = 0; i < matrix->n; i++) { + for (int j = 0; j < matrix->n; j++) { + double val = base * (rand () - RAND_MAX / 2) / (double)RAND_MAX; + set_matrix (matrix, i, j, val); + } + } +} + /* main function */ int main (int argc, char *argv[]) @@ -155,6 +169,12 @@ int main (int argc, char *argv[]) } /* main process */ + while (1) { + matrix_t *matrix = alloc_matrix (N); + generate_matrix (matrix); + double det = determinant (matrix); + printf ("det: %g\n", det); + } return 0; }