71 if ($A instanceof
Matrix) {
73 $this->LU = $A->getArray();
74 $this->m = $A->getRowDimension();
75 $this->
n = $A->getColumnDimension();
80 $LUrowi = $LUcolj = [];
86 $LUcolj[
$i] = &$this->LU[
$i][$j];
90 $LUrowi = $this->LU[
$i];
94 for ($k = 0; $k < $kmax; ++$k) {
95 $s += $LUrowi[$k] * $LUcolj[$k];
97 $LUrowi[$j] = $LUcolj[
$i] -=
$s;
102 if (abs($LUcolj[
$i]) > abs($LUcolj[$p])) {
108 $t = $this->LU[$p][$k];
109 $this->LU[$p][$k] = $this->LU[$j][$k];
110 $this->LU[$j][$k] =
$t;
113 $this->piv[$p] = $this->piv[$j];
115 $this->pivsign = $this->pivsign * -1;
118 if (($j < $this->m) && ($this->LU[$j][$j] != 0.0)) {
120 $this->LU[
$i][$j] /= $this->LU[$j][$j];
142 $L[
$i][$j] = $this->LU[
$i][$j];
143 } elseif (
$i == $j) {
167 $U[
$i][$j] = $this->LU[
$i][$j];
211 if ($this->LU[$j][$j] == 0) {
228 if ($this->m == $this->
n) {
231 $d *= $this->LU[$j][$j];
259 for ($j = 0; $j < $nx; ++$j) {
260 $X->A[
$i][$j] -=
$X->A[$k][$j] * $this->LU[
$i][$k];
265 for ($k = $this->n - 1; $k >= 0; --$k) {
266 for ($j = 0; $j < $nx; ++$j) {
267 $X->A[$k][$j] /= $this->LU[$k][$k];
269 for (
$i = 0;
$i < $k; ++
$i) {
270 for ($j = 0; $j < $nx; ++$j) {
271 $X->A[
$i][$j] -=
$X->A[$k][$j] * $this->LU[
$i][$k];
For an m-by-n matrix A with m >= n, the LU decomposition is an m-by-n unit lower triangular matrix L...
getL()
Get lower triangular factor.
getDoublePivot()
Alias for getPivot.
getU()
Get upper triangular factor.
const MATRIX_SINGULAR_EXCEPTION
if(! $in) print Initializing normalization quick check tables n
getRowDimension()
getRowDimension.
const ARGUMENT_TYPE_EXCEPTION
getPivot()
Return pivot permutation vector.
getMatrix(... $args)
getMatrix.
const MATRIX_SQUARE_EXCEPTION
solve(Matrix $B)
Solve A*X = B.
__construct($A)
LU Decomposition constructor.
getColumnDimension()
getColumnDimension.
const MATRIX_DIMENSION_EXCEPTION
isNonsingular()
Is the matrix nonsingular?
Class for the creating "special" Matrices.
for($i=6; $i< 13; $i++) for($i=1; $i< 13; $i++) $d