From 76aff69027c11284e23a45883d209c391c98a898 Mon Sep 17 00:00:00 2001 From: Soikk <76824648+Soikk@users.noreply.github.com> Date: Wed, 31 Aug 2022 20:48:37 +0200 Subject: [PATCH] Fixed broken add function lol --- matrix.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/matrix.c b/matrix.c index e10b467..7d898f1 100644 --- a/matrix.c +++ b/matrix.c @@ -54,11 +54,13 @@ matrix *fillMatrix(matrix *m, long double n){ } matrix *addMatrix(matrix *m, long double n){ - for(int i = 0; i < m->rows; ++i){ - for(int j = 0; j < m->cols; ++j){ - m->data[i][j] += n; + matrix *r = newMatrix(m->cols, m->rows); + for(int i = 0; i < r->rows; ++i){ + for(int j = 0; j < r->cols; ++j){ + r->data[i][j] = m->data[i][j] + n; } } + return r; } matrix *subtractMatrix(matrix *m, long double n){ -- 2.39.5