You are here

public function CholeskyDecomposition::__construct in Loft Data Grids 6.2

Same name and namespace in other branches
  1. 7.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Shared/JAMA/CholeskyDecomposition.php \CholeskyDecomposition::__construct()

* CholeskyDecomposition * * Class constructor - decomposes symmetric positive definite matrix *

Parameters

mixed Matrix square symmetric positive definite matrix:

File

vendor/phpoffice/phpexcel/Classes/PHPExcel/Shared/JAMA/CholeskyDecomposition.php, line 48

Class

CholeskyDecomposition
@package JAMA

Code

public function __construct($A = null) {
  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 {
    throw new PHPExcel_Calculation_Exception(JAMAError(ArgumentTypeException));
  }
}