summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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){