| @@ 256-260 (lines=5) @@ | ||
| 253 | $X = $this->getSubMatrix($B->toArray(), $this->piv, 0, $nx-1); |
|
| 254 | // Solve L*Y = B(piv,:) |
|
| 255 | for ($k = 0; $k < $this->n; ++$k) { |
|
| 256 | for ($i = $k+1; $i < $this->n; ++$i) { |
|
| 257 | for ($j = 0; $j < $nx; ++$j) { |
|
| 258 | $X[$i][$j] -= $X[$k][$j] * $this->LU[$i][$k]; |
|
| 259 | } |
|
| 260 | } |
|
| 261 | } |
|
| 262 | // Solve U*X = Y; |
|
| 263 | for ($k = $this->n-1; $k >= 0; --$k) { |
|
| @@ 267-271 (lines=5) @@ | ||
| 264 | for ($j = 0; $j < $nx; ++$j) { |
|
| 265 | $X[$k][$j] /= $this->LU[$k][$k]; |
|
| 266 | } |
|
| 267 | for ($i = 0; $i < $k; ++$i) { |
|
| 268 | for ($j = 0; $j < $nx; ++$j) { |
|
| 269 | $X[$i][$j] -= $X[$k][$j] * $this->LU[$i][$k]; |
|
| 270 | } |
|
| 271 | } |
|
| 272 | } |
|
| 273 | return $X; |
|
| 274 | } // function solve() |
|