public function inverse() { $determinant = new Determinant($this->matrix); $factor = $determinant->retrieve(); if ($factor === $this->valueZero) { throw new NotInverseException(); } $factor = 1 / $factor; $transposed = $this->transposed(); $operations = new Operations($transposed, $this->precision); $adjugate = $operations->adjugateMatrix(); $operations = new Operations($adjugate, $this->precision); return $operations->multiplicationScalar($factor); }
/** * @return string * @throws OperationNotAllowedException */ public function forOrderN() { if ($this->matrix->getNumRows() <= 3) { throw new OperationNotAllowedException('determinantOrderN only allowed on 4x4 or greater matrix'); } $this->gaussReduction(); $determinant = new Determinant($this->cofactor(1, 1)); return bcmul($this->matrix->getPoint(1, 1), $determinant->retrieve(), $this->precision); }
public function determinant($precision = null) { $precision = $this->getPrecision($precision); $determinant = new Determinant($this->matrix, $precision); return $determinant->retrieve(); }