diff options
author | Elizabeth Hunt <elizabeth.hunt@simponic.xyz> | 2023-10-11 14:09:59 -0600 |
---|---|---|
committer | Elizabeth Hunt <elizabeth.hunt@simponic.xyz> | 2023-10-11 14:09:59 -0600 |
commit | faaef032d866f956665653e58086af9872c3c093 (patch) | |
tree | a3eb7311af47755c8ad50e7d8e0af4d892c5c200 /src | |
parent | 1ce75ab5fe461ddd3823403754f5b4c543016abc (diff) | |
download | cmath-faaef032d866f956665653e58086af9872c3c093.tar.gz cmath-faaef032d866f956665653e58086af9872c3c093.zip |
matrices
Diffstat (limited to 'src')
-rw-r--r-- | src/matrix.c | 22 |
1 files changed, 22 insertions, 0 deletions
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 <assert.h> +#include <stdio.h> + +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); + } +} |