ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
CholeskyDecomposition Class Reference
+ Collaboration diagram for CholeskyDecomposition:

Public Member Functions

 __construct ($A=null)
 CholeskyDecomposition.
 isSPD ()
 Is the matrix symmetric and positive definite?
 getL ()
 getL
 solve ($B=null)
 Solve A*X = B.

Private Attributes

 $L = array()
 $m
 $isspd = true

Detailed Description

Definition at line 18 of file CholeskyDecomposition.php.

Constructor & Destructor Documentation

CholeskyDecomposition::__construct (   $A = null)

CholeskyDecomposition.

Class constructor - decomposes symmetric positive definite matrix

Parameters
mixedMatrix square symmetric positive definite matrix

Definition at line 48 of file CholeskyDecomposition.php.

References $m, ArgumentTypeException, and JAMAError().

{
if ($A instanceof Matrix) {
$this->L = $A->getArray();
$this->m = $A->getRowDimension();
for($i = 0; $i < $this->m; ++$i) {
for($j = $i; $j < $this->m; ++$j) {
for($sum = $this->L[$i][$j], $k = $i - 1; $k >= 0; --$k) {
$sum -= $this->L[$i][$k] * $this->L[$j][$k];
}
if ($i == $j) {
if ($sum >= 0) {
$this->L[$i][$i] = sqrt($sum);
} else {
$this->isspd = false;
}
} else {
if ($this->L[$i][$i] != 0) {
$this->L[$j][$i] = $sum / $this->L[$i][$i];
}
}
}
for ($k = $i+1; $k < $this->m; ++$k) {
$this->L[$i][$k] = 0.0;
}
}
} else {
}
} // function __construct()

+ Here is the call graph for this function:

Member Function Documentation

CholeskyDecomposition::getL ( )

getL

Return triangular factor.

Returns
Matrix Lower triangular matrix

Definition at line 97 of file CholeskyDecomposition.php.

{
return new Matrix($this->L);
} // function getL()
CholeskyDecomposition::isSPD ( )

Is the matrix symmetric and positive definite?

Returns
boolean

Definition at line 86 of file CholeskyDecomposition.php.

References $isspd.

{
return $this->isspd;
} // function isSPD()
CholeskyDecomposition::solve (   $B = null)

Solve A*X = B.

Parameters
$BRow-equal matrix
Returns
Matrix L * L' * X = B

Definition at line 108 of file CholeskyDecomposition.php.

References $m, $X, ArgumentTypeException, JAMAError(), MatrixDimensionException, and MatrixSPDException.

{
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 {
}
} else {
}
} else {
}
} // function solve()

+ Here is the call graph for this function:

Field Documentation

CholeskyDecomposition::$isspd = true
private

Definition at line 39 of file CholeskyDecomposition.php.

Referenced by isSPD().

CholeskyDecomposition::$L = array()
private

Definition at line 25 of file CholeskyDecomposition.php.

CholeskyDecomposition::$m
private

Definition at line 32 of file CholeskyDecomposition.php.

Referenced by __construct(), and solve().


The documentation for this class was generated from the following file: