diff options
| author | Soikk | 2022-08-31 20:48:37 +0200 |
|---|---|---|
| committer | Soikk | 2022-08-31 20:48:37 +0200 |
| commit | 76aff69027c11284e23a45883d209c391c98a898 (patch) | |
| tree | 96f008b59ccba02ba5cf18d72ccb858389a32c99 | |
| parent | 33f4cdb84a2b1dcb494d8adbc13d6eb0cc475740 (diff) | |
| download | soikk-matrix-76aff69027c11284e23a45883d209c391c98a898.tar.xz soikk-matrix-76aff69027c11284e23a45883d209c391c98a898.tar.zst | |
Fixed broken add function lol
| -rw-r--r-- | matrix.c | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -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){ |
