/**
* @param self $value
* @return self
* @throws MatrixException
*/
public function multiplyMatrix(self $value) : self
{
if ($this->getColumnCount() !== $value->getRowCount()) {
throw new MatrixException('Cannot multiply matrices of these sizes.');
}
$literal = [];
for ($i = 0, $rows = $this->getRowCount(); $i < $rows; $i++) {
$row = [];
for ($j = 0, $valueColumns = $value->getColumnCount(); $j < $valueColumns; $j++) {
$sum = 0;
for ($k = 0, $columns = $this->getColumnCount(); $k < $columns; $k++) {
$sum += $this->get($i, $k) * $value->get($k, $j);
}
$row[] = $sum;
}
$literal[] = $row;
}
return new static($literal);
}