From: Soikk <76824648+Soikk@users.noreply.github.com> Date: Wed, 31 Aug 2022 18:48:37 +0000 (+0200) Subject: Fixed broken add function lol X-Git-Url: https://git.xolatile.top/?a=commitdiff_plain;h=76aff69027c11284e23a45883d209c391c98a898;p=soikk-matrix.git Fixed broken add function lol --- 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){