You are here

private function EigenvalueDecomposition::orthes in Loft Data Grids 7.2

Same name and namespace in other branches
  1. 6.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Shared/JAMA/EigenvalueDecomposition.php \EigenvalueDecomposition::orthes()

* Nonsymmetric reduction to Hessenberg form. * * This is derived from the Algol procedures orthes and ortran, * by Martin and Wilkinson, Handbook for Auto. Comp., * Vol.ii-Linear Algebra, and the corresponding * Fortran subroutines in EISPACK. * * @access private

1 call to EigenvalueDecomposition::orthes()
EigenvalueDecomposition::__construct in vendor/phpoffice/phpexcel/Classes/PHPExcel/Shared/JAMA/EigenvalueDecomposition.php
* Constructor: Check for symmetry, then construct the eigenvalue decomposition * * @access public *

File

vendor/phpoffice/phpexcel/Classes/PHPExcel/Shared/JAMA/EigenvalueDecomposition.php, line 291

Class

EigenvalueDecomposition
@package JAMA

Code

private function orthes() {
  $low = 0;
  $high = $this->n - 1;
  for ($m = $low + 1; $m <= $high - 1; ++$m) {

    // Scale column.
    $scale = 0.0;
    for ($i = $m; $i <= $high; ++$i) {
      $scale = $scale + abs($this->H[$i][$m - 1]);
    }
    if ($scale != 0.0) {

      // Compute Householder transformation.
      $h = 0.0;
      for ($i = $high; $i >= $m; --$i) {
        $this->ort[$i] = $this->H[$i][$m - 1] / $scale;
        $h += $this->ort[$i] * $this->ort[$i];
      }
      $g = sqrt($h);
      if ($this->ort[$m] > 0) {
        $g *= -1;
      }
      $h -= $this->ort[$m] * $g;
      $this->ort[$m] -= $g;

      // Apply Householder similarity transformation
      // H = (I -u * u' / h) * H * (I -u * u') / h)
      for ($j = $m; $j < $this->n; ++$j) {
        $f = 0.0;
        for ($i = $high; $i >= $m; --$i) {
          $f += $this->ort[$i] * $this->H[$i][$j];
        }
        $f /= $h;
        for ($i = $m; $i <= $high; ++$i) {
          $this->H[$i][$j] -= $f * $this->ort[$i];
        }
      }
      for ($i = 0; $i <= $high; ++$i) {
        $f = 0.0;
        for ($j = $high; $j >= $m; --$j) {
          $f += $this->ort[$j] * $this->H[$i][$j];
        }
        $f = $f / $h;
        for ($j = $m; $j <= $high; ++$j) {
          $this->H[$i][$j] -= $f * $this->ort[$j];
        }
      }
      $this->ort[$m] = $scale * $this->ort[$m];
      $this->H[$m][$m - 1] = $scale * $g;
    }
  }

  // Accumulate transformations (Algol's ortran).
  for ($i = 0; $i < $this->n; ++$i) {
    for ($j = 0; $j < $this->n; ++$j) {
      $this->V[$i][$j] = $i == $j ? 1.0 : 0.0;
    }
  }
  for ($m = $high - 1; $m >= $low + 1; --$m) {
    if ($this->H[$m][$m - 1] != 0.0) {
      for ($i = $m + 1; $i <= $high; ++$i) {
        $this->ort[$i] = $this->H[$i][$m - 1];
      }
      for ($j = $m; $j <= $high; ++$j) {
        $g = 0.0;
        for ($i = $m; $i <= $high; ++$i) {
          $g += $this->ort[$i] * $this->V[$i][$j];
        }

        // Double division avoids possible underflow
        $g = $g / $this->ort[$m] / $this->H[$m][$m - 1];
        for ($i = $m; $i <= $high; ++$i) {
          $this->V[$i][$j] += $g * $this->ort[$i];
        }
      }
    }
  }
}