diff options
author | Elizabeth Hunt <elizabeth.hunt@simponic.xyz> | 2023-10-18 12:49:39 -0600 |
---|---|---|
committer | Elizabeth Hunt <elizabeth.hunt@simponic.xyz> | 2023-10-18 12:49:39 -0600 |
commit | 9e7166a52e94d8e15bf2dbfe00026f21f76630a9 (patch) | |
tree | bb4d7114d5f91fa128375347ab4249a4c35408f2 /src/matrix.c | |
parent | 1b4d91e623a083690ac6554d1aeaa38b75469908 (diff) | |
download | cmath-9e7166a52e94d8e15bf2dbfe00026f21f76630a9.tar.gz cmath-9e7166a52e94d8e15bf2dbfe00026f21f76630a9.zip |
oct 16, 18 notes. add unit tests with utest, and bisection root finding methods
Diffstat (limited to 'src/matrix.c')
-rw-r--r-- | src/matrix.c | 13 |
1 files changed, 12 insertions, 1 deletions
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; +} |