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