# HG changeset patch # User Sascha L. Teichmann # Date 1347211190 0 # Node ID 976be312a84cb376bb37cc3b499727af2342ca5a # Parent da1969b052921012c2847217f25680b749c5b081 Simplified code for extreme curves. flys-artifacts/trunk@5412 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r da1969b05292 -r 976be312a84c flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Sun Sep 09 15:29:06 2012 +0000 +++ b/flys-artifacts/ChangeLog Sun Sep 09 17:19:50 2012 +0000 @@ -1,3 +1,10 @@ +2012-09-09 Sascha L. Teichmann + + * src/main/java/de/intevation/flys/artifacts/model/extreme/Curve.java: + Store Ws and Qs in double arrays instead of WQ objects (as + they are return from WstValueTable.interpolateTabular()). + This simplifies the code and should be more memory effective. + 2012-09-09 Sascha L. Teichmann * src/main/java/de/intevation/flys/artifacts/math/Linear.java: diff -r da1969b05292 -r 976be312a84c flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/extreme/Curve.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/extreme/Curve.java Sun Sep 09 15:29:06 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/extreme/Curve.java Sun Sep 09 17:19:50 2012 +0000 @@ -6,8 +6,6 @@ import de.intevation.flys.artifacts.math.fitting.FunctionFactory; -import de.intevation.flys.artifacts.model.QW; - import java.io.Serializable; import java.lang.ref.SoftReference; @@ -23,7 +21,8 @@ { private static Logger log = Logger.getLogger(Curve.class); - protected QW [] qws; + protected double [] qs; + protected double [] ws; protected String function; protected double [] coeffs; @@ -34,14 +33,24 @@ public Curve() { } - public Curve(QW [] qws, String function, double [] coeffs) { - this.qws = qws; + public Curve( + double [] qs, + double [] ws, + String function, + double [] coeffs + ) { + this.qs = qs; + this.ws = ws; this.function = function; this.coeffs = coeffs; } - public QW [] getQWs() { - return qws; + public double [] getQs() { + return qs; + } + + public double [] getWs() { + return ws; } public String getFunction() { @@ -54,8 +63,8 @@ @Override public double value(double x) { - if (x < qws[0].getQ()) return Double.NaN; - return (x <= qws[qws.length-1].getQ() + if (x < qs[0]) return Double.NaN; + return (x <= qs[qs.length-1] ? getSpline() : getExtrapolation()).value(x); } @@ -85,13 +94,6 @@ protected Function createSpline() { SplineInterpolator interpolator = new SplineInterpolator(); - double [] qs = new double[qws.length]; - double [] ws = new double[qws.length]; - for (int i = 0; i < qws.length; ++i) { - QW qw = qws[i]; - qs[i] = qw.getQ(); - ws[i] = qw.getW(); - } try { return new UnivariateRealFunctionFunction( interpolator.interpolate(qs, ws));