MCordingley\LinearAlgebra\Decomposition\LU::decompose PHP Method

decompose() private method

private decompose ( Matrix $source )
$source MCordingley\LinearAlgebra\Matrix
    private function decompose(Matrix $source)
    {
        $decompositionLiteral = $source->toArray();
        if (!$source->isSquare()) {
            throw new MatrixException('Operation can only be called on square matrix: ' . print_r($decompositionLiteral, true));
        }
        $size = $source->getRowCount();
        for ($k = 0; $k < $size; $k++) {
            for ($i = $k + 1; $i < $size; $i++) {
                $decompositionLiteral[$i][$k] = $decompositionLiteral[$i][$k] / $decompositionLiteral[$k][$k];
            }
            for ($i = $k + 1; $i < $size; $i++) {
                for ($j = $k + 1; $j < $size; $j++) {
                    $decompositionLiteral[$i][$j] = $decompositionLiteral[$i][$j] - $decompositionLiteral[$i][$k] * $decompositionLiteral[$k][$j];
                }
            }
        }
        $this->decomposition = new Matrix($decompositionLiteral);
    }