@@ 172-182 (lines=11) @@ | ||
169 | /** |
|
170 | * @param float|int $value |
|
171 | */ |
|
172 | public function divideByScalar($value): self |
|
173 | { |
|
174 | $newMatrix = []; |
|
175 | for ($i = 0; $i < $this->rows; ++$i) { |
|
176 | for ($j = 0; $j < $this->columns; ++$j) { |
|
177 | $newMatrix[$i][$j] = $this->matrix[$i][$j] / $value; |
|
178 | } |
|
179 | } |
|
180 | ||
181 | return new self($newMatrix, false); |
|
182 | } |
|
183 | ||
184 | /** |
|
185 | * @param float|int $value |
|
@@ 187-197 (lines=11) @@ | ||
184 | /** |
|
185 | * @param float|int $value |
|
186 | */ |
|
187 | public function multiplyByScalar($value): self |
|
188 | { |
|
189 | $newMatrix = []; |
|
190 | for ($i = 0; $i < $this->rows; ++$i) { |
|
191 | for ($j = 0; $j < $this->columns; ++$j) { |
|
192 | $newMatrix[$i][$j] = $this->matrix[$i][$j] * $value; |
|
193 | } |
|
194 | } |
|
195 | ||
196 | return new self($newMatrix, false); |
|
197 | } |
|
198 | ||
199 | /** |
|
200 | * Element-wise addition of the matrix with another one |