Updated gui for user facility settings (#1327)
[openemr.git] / vendor / phpoffice / phpexcel / Classes / PHPExcel / Shared / JAMA / utils / Maths.php
blobaa09a8bbbfa2a34a8b457160ba8d6b7b09619c70
1 <?php
2 /**
3 * @package JAMA
5 * Pythagorean Theorem:
7 * a = 3
8 * b = 4
9 * r = sqrt(square(a) + square(b))
10 * r = 5
12 * r = sqrt(a^2 + b^2) without under/overflow.
14 function hypo($a, $b) {
15 if (abs($a) > abs($b)) {
16 $r = $b / $a;
17 $r = abs($a) * sqrt(1 + $r * $r);
18 } elseif ($b != 0) {
19 $r = $a / $b;
20 $r = abs($b) * sqrt(1 + $r * $r);
21 } else {
22 $r = 0.0;
24 return $r;
25 } // function hypo()
28 /**
29 * Mike Bommarito's version.
30 * Compute n-dimensional hyotheneuse.
32 function hypot() {
33 $s = 0;
34 foreach (func_get_args() as $d) {
35 if (is_numeric($d)) {
36 $s += pow($d, 2);
37 } else {
38 throw new PHPExcel_Calculation_Exception(JAMAError(ArgumentTypeException));
41 return sqrt($s);