From faaef032d866f956665653e58086af9872c3c093 Mon Sep 17 00:00:00 2001 From: Elizabeth Hunt Date: Wed, 11 Oct 2023 14:09:59 -0600 Subject: matrices --- src/matrix.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/matrix.c (limited to 'src/matrix.c') diff --git a/src/matrix.c b/src/matrix.c new file mode 100644 index 0000000..115e0a3 --- /dev/null +++ b/src/matrix.c @@ -0,0 +1,22 @@ +#include "lizfcm.h" +#include +#include + +void put_identity_diagonal(Matrix_double *m) { + assert(m->rows == m->cols); + + for (size_t y = 0; y < m->rows; ++y) + m->data[y]->data[y] = 1.0; +} + +void format_matrix_into(Matrix_double *m, char *s) { + sprintf(s, ""); + if (m->rows == 0) + sprintf(s, "empty"); + + for (size_t y = 0; y < m->rows; ++y) { + char row_s[256]; + format_vector_into(m->data[y], row_s); + sprintf(s, "%s %s \n", s, row_s); + } +} -- cgit v1.2.3-70-g09d2