/* linker: */
#include <assert.h>
+//#include <math.h>
#include <stdio.h>
#include <stdlib.h>
/* constants */
-#define MAXSIZE 16;
-
-/* types */
-
-typedef struct {
- int n;
- double *mat;
-} matrix_t;
+//#define N 32
+#define N 10
/* static variables */
int nb_threads = 1;
+/* types */
+
+typedef struct {
+ int n;
+ double *mat;
+} matrix_t;
+
/* usage function */
int usage (int ret)
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[])
}
/* main process */
+ while (1) {
+ matrix_t *matrix = alloc_matrix (N);
+ generate_matrix (matrix);
+ double det = determinant (matrix);
+ printf ("det: %g\n", det);
+ }
return 0;
}