Subversion Repositories eFlore/Applications.cel

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2390 jpm 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
	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;
23
	}
24
	return $r;
25
}	//	function hypo()
26
 
27
 
28
/**
29
 *	Mike Bommarito's version.
30
 *	Compute n-dimensional hyotheneuse.
31
 *
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));
39
		}
40
	}
41
	return sqrt($s);
42
}
43
*/