public function subtract(Matrix $B) : Matrix
{
if ($B->getM() !== $this->m) {
throw new Exception\MatrixException('Matices have different number of rows');
}
if ($B->getN() !== $this->n) {
throw new Exception\MatrixException('Matices have different number of columns');
}
$R = [];
for ($i = 0; $i < $this->m; $i++) {
for ($j = 0; $j < $this->n; $j++) {
$R[$i][$j] = $this->A[$i][$j] - $B[$i][$j];
}
}
return MatrixFactory::create($R);
}