public function multiplicationScalar($multiplier) { $result = new Matrix($this->matrix->getNumRows(), $this->matrix->getNumCols(), $this->precision); for ($row = 1; $row <= $this->matrix->getNumRows(); $row++) { for ($col = 1; $col <= $this->matrix->getNumCols(); $col++) { $newValue = bcmul($this->matrix->getPoint($row, $col), $multiplier, $this->precision); $result->setPoint($row, $col, $newValue); } } return $result; }
/** * @param $i * @param $j * @return Matrix */ public function cofactor($i, $j) { $cofactor = new Matrix($this->matrix->getNumRows() - 1, $this->matrix->getNumCols() - 1, $this->precision); for ($m = 1; $m <= $this->matrix->getNumRows(); $m++) { for ($n = 1; $n <= $this->matrix->getNumCols(); $n++) { if ($m == $i || $n == $j) { continue; } $row = $m < $i ? $m : $m - 1; $col = $n < $j ? $n : $n - 1; $cofactor->setPoint($row, $col, $this->matrix->getPoint($m, $n)); } } return $cofactor; }