source: src/main/java/agents/Jama/util/Maths.java@ 50

Last change on this file since 50 was 1, checked in by Wouter Pasman, 6 years ago

Initial import : Genius 9.0.0

File size: 441 bytes
RevLine 
[1]1package agents.Jama.util;
2
3public class Maths {
4
5 /** sqrt(a^2 + b^2) without under/overflow. **/
6
7 public static double hypot(double a, double b) {
8 double r;
9 if (Math.abs(a) > Math.abs(b)) {
10 r = b/a;
11 r = Math.abs(a)*Math.sqrt(1+r*r);
12 } else if (b != 0) {
13 r = a/b;
14 r = Math.abs(b)*Math.sqrt(1+r*r);
15 } else {
16 r = 0.0;
17 }
18 return r;
19 }
20}
Note: See TracBrowser for help on using the repository browser.