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