[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/lib/phpexcel/PHPExcel/Shared/JAMA/utils/ -> Maths.php (source)

   1  <?php
   2  /**
   3   *    @package JAMA
   4   *
   5   *    Pythagorean Theorem:
   6   *
   7   *    a = 3
   8   *    b = 4
   9   *    r = sqrt(square(a) + square(b))
  10   *    r = 5
  11   *
  12   *    r = sqrt(a^2 + b^2) without under/overflow.
  13   */
  14  function hypo($a, $b)
  15  {
  16      if (abs($a) > abs($b)) {
  17          $r = $b / $a;
  18          $r = abs($a) * sqrt(1 + $r * $r);
  19      } elseif ($b != 0) {
  20          $r = $a / $b;
  21          $r = abs($b) * sqrt(1 + $r * $r);
  22      } else {
  23          $r = 0.0;
  24      }
  25      return $r;
  26  }    //    function hypo()
  27  
  28  
  29  /**
  30   *    Mike Bommarito's version.
  31   *    Compute n-dimensional hyotheneuse.
  32   *
  33  function hypot() {
  34      $s = 0;
  35      foreach (func_get_args() as $d) {
  36          if (is_numeric($d)) {
  37              $s += pow($d, 2);
  38          } else {
  39              throw new PHPExcel_Calculation_Exception(JAMAError(ARGUMENT_TYPE_EXCEPTION));
  40          }
  41      }
  42      return sqrt($s);
  43  }
  44  */


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1