| @@ 159-169 (lines=11) @@ | ||
| 156 | return new self($product, false); |
|
| 157 | } |
|
| 158 | ||
| 159 | public function divideByScalar($value): self |
|
| 160 | { |
|
| 161 | $newMatrix = []; |
|
| 162 | for ($i = 0; $i < $this->rows; ++$i) { |
|
| 163 | for ($j = 0; $j < $this->columns; ++$j) { |
|
| 164 | $newMatrix[$i][$j] = $this->matrix[$i][$j] / $value; |
|
| 165 | } |
|
| 166 | } |
|
| 167 | ||
| 168 | return new self($newMatrix, false); |
|
| 169 | } |
|
| 170 | ||
| 171 | public function multiplyByScalar($value): self |
|
| 172 | { |
|
| @@ 171-181 (lines=11) @@ | ||
| 168 | return new self($newMatrix, false); |
|
| 169 | } |
|
| 170 | ||
| 171 | public function multiplyByScalar($value): self |
|
| 172 | { |
|
| 173 | $newMatrix = []; |
|
| 174 | for ($i = 0; $i < $this->rows; ++$i) { |
|
| 175 | for ($j = 0; $j < $this->columns; ++$j) { |
|
| 176 | $newMatrix[$i][$j] = $this->matrix[$i][$j] * $value; |
|
| 177 | } |
|
| 178 | } |
|
| 179 | ||
| 180 | return new self($newMatrix, false); |
|
| 181 | } |
|
| 182 | ||
| 183 | /** |
|
| 184 | * Element-wise addition of the matrix with another one |
|