49 if ($A instanceof Matrix) {
50 $this->L = $A->getArray();
51 $this->m = $A->getRowDimension();
55 for($sum = $this->L[$i][$j], $k = $i - 1; $k >= 0; --$k) {
56 $sum -= $this->L[$i][$k] * $this->L[$j][$k];
60 $this->L[$i][$i] = sqrt($sum);
65 if ($this->L[$i][$i] != 0) {
66 $this->L[$j][$i] = $sum / $this->L[$i][$i];
71 for ($k = $i+1; $k <
$this->m; ++$k) {
72 $this->L[$i][$k] = 0.0;
98 return new Matrix($this->L);
109 if ($B instanceof Matrix) {
110 if ($B->getRowDimension() ==
$this->m) {
112 $X = $B->getArrayCopy();
113 $nx = $B->getColumnDimension();
116 for ($i = $k + 1; $i <
$this->m; ++$i) {
117 for ($j = 0; $j < $nx; ++$j) {
118 $X[$i][$j] -= $X[$k][$j] * $this->L[$i][$k];
121 for ($j = 0; $j < $nx; ++$j) {
122 $X[$k][$j] /= $this->L[$k][$k];
126 for ($k = $this->m - 1; $k >= 0; --$k) {
127 for ($j = 0; $j < $nx; ++$j) {
128 $X[$k][$j] /= $this->L[$k][$k];
130 for ($i = 0; $i < $k; ++$i) {
131 for ($j = 0; $j < $nx; ++$j) {
132 $X[$i][$j] -= $X[$k][$j] * $this->L[$k][$i];
137 return new Matrix($X, $this->m, $nx);
isSPD()
Is the matrix symmetric and positive definite?
const MatrixDimensionException
const ArgumentTypeException
__construct($A=null)
CholeskyDecomposition.
Create styles array
The data for the language used.
JAMAError($errorNumber=null)
Custom error handler.
solve($B=null)
Solve A*X = B.