public function divideByScalar($value)
{
$newMatrix = array();
for ($i = 0; $i < $this->rows; ++$i) {
for ($j = 0; $j < $this->columns; ++$j) {
$newMatrix[$i][$j] = $this->matrix[$i][$j] / $value;
}
}
return new self($newMatrix, false);
}
public function testDivideByScalar() { $matrix = new Matrix([[4, 6, 8], [2, 10, 20]]); $quotient = [[2, 3, 4], [1, 5, 10]]; $this->assertEquals($quotient, $matrix->divideByScalar(2)->toArray()); }