From 9e7166a52e94d8e15bf2dbfe00026f21f76630a9 Mon Sep 17 00:00:00 2001 From: Elizabeth Hunt Date: Wed, 18 Oct 2023 12:49:39 -0600 Subject: oct 16, 18 notes. add unit tests with utest, and bisection root finding methods --- src/matrix.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/matrix.c') diff --git a/src/matrix.c b/src/matrix.c index ac4d138..5766d94 100644 --- a/src/matrix.c +++ b/src/matrix.c @@ -37,7 +37,7 @@ Matrix_double **lu_decomp(Matrix_double *m) { Matrix_double *u = copy_matrix(m); Matrix_double *l_empt = InitMatrixWithSize(double, m->rows, m->cols, 0.0); Matrix_double *l = put_identity_diagonal(l_empt); - free(l_empt); + free_matrix(l_empt); Matrix_double **u_l = malloc(sizeof(Matrix_double *) * 2); @@ -140,3 +140,14 @@ void format_matrix_into(Matrix_double *m, char *s) { } strcat(s, "\n"); } + +int matrix_equal(Matrix_double *a, Matrix_double *b) { + if (a->cols != b->cols || a->rows != b->rows) + return false; + + for (size_t y = 0; y < a->rows; ++y) + if (!vector_equal(a->data[y], b->data[y])) { + return false; + } + return true; +} -- cgit v1.3