Vendor/phpspreadsheet/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/JAMA/CholeskyDecomposition.php
public function solve(Matrix $B)
    {
        if ($B->getRowDimension() == $this->m) {
            if ($this->isspd) {
                $X = $B->getArrayCopy();
                $nx = $B->getColumnDimension();

                for ($k = 0; $k < $this->m; ++$k) {
                    for ($i = $k + 1; $i < $this->m; ++$i) {
                        for ($j = 0; $j < $nx; ++$j) {
                            $X[$i][$j] -= $X[$k][$j] * $this->L[$i][$k];
                        }
                    }
                    for ($j = 0; $j < $nx; ++$j) {
                        $X[$k][$j] /= $this->L[$k][$k];
                    }
                }

                for ($k = $this->m - 1; $k >= 0; --$k) {
                    for ($j = 0; $j < $nx; ++$j) {
                        $X[$k][$j] /= $this->L[$k][$k];
                    }
                    for ($i = 0; $i < $k; ++$i) {
                        for ($j = 0; $j < $nx; ++$j) {
                            $X[$i][$j] -= $X[$k][$j] * $this->L[$k][$i];
                        }
                    }
                }

                return new Matrix($X, $this->m, $nx);
            }

            throw new CalculationException(Matrix::MATRIX_SPD_EXCEPTION);
        }

        throw new CalculationException(Matrix::MATRIX_DIMENSION_EXCEPTION);
    }
public function solve(Matrix $B)
    {
        if ($B->getRowDimension() == $this->m) {
            if ($this->isspd) {
                $X = $B->getArrayCopy();
                $nx = $B->getColumnDimension();

                for ($k = 0; $k < $this->m; ++$k) {
                    for ($i = $k + 1; $i < $this->m; ++$i) {
                        for ($j = 0; $j < $nx; ++$j) {
                            $X[$i][$j] -= $X[$k][$j] * $this->L[$i][$k];
                        }
                    }
                    for ($j = 0; $j < $nx; ++$j) {
                        $X[$k][$j] /= $this->L[$k][$k];
                    }
                }

                for ($k = $this->m - 1; $k >= 0; --$k) {
                    for ($j = 0; $j < $nx; ++$j) {
                        $X[$k][$j] /= $this->L[$k][$k];
                    }
                    for ($i = 0; $i < $k; ++$i) {
                        for ($j = 0; $j < $nx; ++$j) {
                            $X[$i][$j] -= $X[$k][$j] * $this->L[$k][$i];
                        }
                    }
                }

                return new Matrix($X, $this->m, $nx);
            }

            throw new CalculationException(Matrix::MATRIX_SPD_EXCEPTION);
        }

        throw new CalculationException(Matrix::MATRIX_DIMENSION_EXCEPTION);
    }
public function solve ( Matrix $ B ) { if ( $ B -> getRowDimension ( ) == $ this -> m ) { if ( $ this -> isspd ) { $ X = $ B -> getArrayCopy ( ) ; $ nx = $ B -> getColumnDimension ( ) ; for ( $ k = 0 ; $ k < $ this -> m ; ++ $ k ) { for ( $ i = $ k + 1 ; $ i < $ this -> m ; ++ $ i ) { for ( $ j = 0 ; $ j < $ nx ; ++ $ j ) { $ X [ $ i ] [ $ j ] -= $ X [ $ k ] [ $ j ] * $ this -> L [ $ i ] [ $ k ] ; } } for ( $ j = 0 ; $ j < $ nx ; ++ $ j ) { $ X [ $ k ] [ $ j ] /= $ this -> L [ $ k ] [ $ k ] ; } } for ( $ k = $ this -> m - 1 ; $ k >= 0 ; -- $ k ) { for ( $ j = 0 ; $ j < $ nx ; ++ $ j ) { $ X [ $ k ] [ $ j ] /= $ this -> L [ $ k ] [ $ k ] ; } for ( $ i = 0 ; $ i < $ k ; ++ $ i ) { for ( $ j = 0 ; $ j < $ nx ; ++ $ j ) { $ X [ $ i ] [ $ j ] -= $ X [ $ k ] [ $ j ] * $ this -> L [ $ k ] [ $ i ] ; } } } return new Matrix ( $ X , $ this -> m , $ nx ) ; } throw new CalculationException ( Matrix :: MATRIX_SPD_EXCEPTION ) ; } throw new CalculationException ( Matrix :: MATRIX_DIMENSION_EXCEPTION ) ; }
Solve A*X = B.

@param $B Row-equal matrix

@return Matrix L * L' * X = B
Solve A * X = B .