summaryrefslogtreecommitdiff
path: root/src/matrix.c
diff options
context:
space:
mode:
authorElizabeth Hunt <elizabeth.hunt@simponic.xyz>2023-10-11 17:00:38 -0600
committerElizabeth Hunt <elizabeth.hunt@simponic.xyz>2023-10-11 17:00:38 -0600
commitadd2520e49da79357b7759d65f7c0863d88669b3 (patch)
tree90806fe6a03774ce65b0fd1269037452763994d2 /src/matrix.c
parent78bd8c4a95049fcd738156a6244635c822044915 (diff)
downloadcmath-add2520e49da79357b7759d65f7c0863d88669b3.tar.gz
cmath-add2520e49da79357b7759d65f7c0863d88669b3.zip
bug fixes and fix compilation on gcc
Diffstat (limited to 'src/matrix.c')
-rw-r--r--src/matrix.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/matrix.c b/src/matrix.c
index a23aad4..953d50f 100644
--- a/src/matrix.c
+++ b/src/matrix.c
@@ -1,5 +1,6 @@
#include "lizfcm.h"
#include <assert.h>
+#include <string.h>
#include <stdio.h>
void put_identity_diagonal(Matrix_double *m) {
@@ -69,14 +70,15 @@ void free_matrix(Matrix_double *m) {
}
void format_matrix_into(Matrix_double *m, char *s) {
- sprintf(s, "");
if (m->rows == 0)
- sprintf(s, "empty");
+ strcpy(s, "empty");
for (size_t y = 0; y < m->rows; ++y) {
- char *row_s = malloc(sizeof(char) * 256);
+ char row_s[256];
+ strcpy(row_s, "");
+
format_vector_into(m->data[y], row_s);
- sprintf(s, "%s %s \n", s, row_s);
- free(row_s);
+ strcat(s, row_s);
}
+ strcat(s, "\n");
}