summaryrefslogtreecommitdiff
path: root/matrix.c
diff options
context:
space:
mode:
authorSoikk2022-08-31 20:48:37 +0200
committerSoikk2022-08-31 20:48:37 +0200
commit76aff69027c11284e23a45883d209c391c98a898 (patch)
tree96f008b59ccba02ba5cf18d72ccb858389a32c99 /matrix.c
parent33f4cdb84a2b1dcb494d8adbc13d6eb0cc475740 (diff)
downloadsoikk-matrix-76aff69027c11284e23a45883d209c391c98a898.tar.xz
soikk-matrix-76aff69027c11284e23a45883d209c391c98a898.tar.zst
Fixed broken add function lol
Diffstat (limited to 'matrix.c')
-rw-r--r--matrix.c8
1 files 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){