]> git.xolatile.top Git - soikk-matrix.git/commitdiff
Fixed broken add function lol
authorSoikk <76824648+Soikk@users.noreply.github.com>
Wed, 31 Aug 2022 18:48:37 +0000 (20:48 +0200)
committerSoikk <76824648+Soikk@users.noreply.github.com>
Wed, 31 Aug 2022 18:48:37 +0000 (20:48 +0200)
matrix.c

index e10b467d3e0f4a6785a5751ff381199d5184a9b2..7d898f128aee46d126cd830c6c05789cb86e847d 100644 (file)
--- 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){