public function CholeskyDecomposition::solve in Loft Data Grids 6.2
Same name and namespace in other branches
- 7.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Shared/JAMA/CholeskyDecomposition.php \CholeskyDecomposition::solve()
* Solve A*X = B * *
Parameters
$B Row-equal matrix: * @return Matrix L * L' * X = B
File
- vendor/
phpoffice/ phpexcel/ Classes/ PHPExcel/ Shared/ JAMA/ CholeskyDecomposition.php, line 108
Class
- CholeskyDecomposition
- @package JAMA
Code
public function solve($B = null) {
if ($B instanceof Matrix) {
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);
}
else {
throw new PHPExcel_Calculation_Exception(JAMAError(MatrixSPDException));
}
}
else {
throw new PHPExcel_Calculation_Exception(JAMAError(MatrixDimensionException));
}
}
else {
throw new PHPExcel_Calculation_Exception(JAMAError(ArgumentTypeException));
}
}