X-Git-Url: http://gitweb.fperrin.net/?a=blobdiff_plain;f=tim%2Fprune%2Ffunction%2Festimate%2Fjama%2FMaths.java;fp=tim%2Fprune%2Ffunction%2Festimate%2Fjama%2FMaths.java;h=7c3326dff13f5b59bae17c64ce272977bb2681b7;hb=7f5ed2be62905bd37717376dc22d09e5ea7edb4d;hp=0000000000000000000000000000000000000000;hpb=b361869e590bbca32664c16ac24d6296926594a5;p=GpsPrune.git diff --git a/tim/prune/function/estimate/jama/Maths.java b/tim/prune/function/estimate/jama/Maths.java new file mode 100644 index 0000000..7c3326d --- /dev/null +++ b/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; + } +}