MCordingley\LinearAlgebra\Decomposition\LUP::upper PHP Method

upper() public method

public upper ( ) : Matrix
return MCordingley\LinearAlgebra\Matrix
    public function upper() : Matrix
    {
        return $this->decomposition->upper(false);
    }

Usage Example

Beispiel #1
0
 /**
  * @return float
  */
 public function determinant() : float
 {
     $this->checkSquare();
     try {
         $decomp = new LUP($this);
     } catch (MatrixException $exception) {
         // Singular matrix, so determinant is defined to be zero.
         return 0.0;
     }
     $upper = $decomp->upper();
     $determinant = 1.0;
     for ($i = 0, $size = $upper->getRowCount(); $i < $size; $i++) {
         $determinant *= $upper->get($i, $i);
     }
     $sign = $decomp->parity() % 2 ? -1 : 1;
     return $sign * $determinant;
 }