X-Git-Url: http://gitweb.fperrin.net/?p=GpsPrune.git;a=blobdiff_plain;f=src%2Ftim%2Fprune%2Ffunction%2Festimate%2Fjama%2FMaths.java;fp=src%2Ftim%2Fprune%2Ffunction%2Festimate%2Fjama%2FMaths.java;h=7c3326dff13f5b59bae17c64ce272977bb2681b7;hp=0000000000000000000000000000000000000000;hb=ce6f2161b8596f7018d6a76bff79bc9e571f35fd;hpb=2d8cb72e84d5cc1089ce77baf1e34ea3ea2f8465 diff --git a/src/tim/prune/function/estimate/jama/Maths.java b/src/tim/prune/function/estimate/jama/Maths.java new file mode 100644 index 0000000..7c3326d --- /dev/null +++ b/src/tim/prune/function/estimate/jama/Maths.java @@ -0,0 +1,31 @@ +package tim.prune.function.estimate.jama; + +/** + * Static helper method, taken from public domain NIST code for JAMA + */ +public abstract class Maths +{ + /** + * Work out sqrt(a^2 + b^2) + */ + public static double pythag(double a, double b) + { + double r; + + if (Math.abs(a) > Math.abs(b)) + { + r = b/a; + r = Math.abs(a)*Math.sqrt(1+r*r); + } + else if (b != 0) + { + r = a/b; + r = Math.abs(b)*Math.sqrt(1+r*r); + } + else + { + r = 0.0; + } + return r; + } +}