]> gitweb.fperrin.net Git - GpsPrune.git/blob - tim/prune/function/estimate/jama/Maths.java
7c3326dff13f5b59bae17c64ce272977bb2681b7
[GpsPrune.git] / tim / prune / function / estimate / jama / Maths.java
1 package tim.prune.function.estimate.jama;
2
3 /**
4  * Static helper method, taken from public domain NIST code for JAMA
5  */
6 public abstract class Maths
7 {
8         /**
9          * Work out sqrt(a^2 + b^2)
10          */
11         public static double pythag(double a, double b)
12         {
13                 double r;
14
15                 if (Math.abs(a) > Math.abs(b))
16                 {
17                         r = b/a;
18                         r = Math.abs(a)*Math.sqrt(1+r*r);
19                 }
20                 else if (b != 0)
21                 {
22                         r = a/b;
23                         r = Math.abs(b)*Math.sqrt(1+r*r);
24                 }
25                 else
26                 {
27                         r = 0.0;
28                 }
29                 return r;
30         }
31 }