Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixATWriter.java @ 3643:171db4d5d3cb
FixA: AT export: prevent some numerical problems with steep functions around zero.
flys-artifacts/trunk@5363 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Wed, 05 Sep 2012 08:38:12 +0000 |
parents | 83c0735092a3 |
children | 8bbb9e173297 |
comparison
equal
deleted
inserted
replaced
3642:83c0735092a3 | 3643:171db4d5d3cb |
---|---|
30 | 30 |
31 public static final String [] Q_MAX_COLUMN = new String [] { "max_q" }; | 31 public static final String [] Q_MAX_COLUMN = new String [] { "max_q" }; |
32 | 32 |
33 private static final int MAX_ITERATIONS = 10000; | 33 private static final int MAX_ITERATIONS = 10000; |
34 private static final double EPSILON = 1e-8; | 34 private static final double EPSILON = 1e-8; |
35 private static final double MIN_Q = 1e-4; | |
35 | 36 |
36 protected Function function; | 37 protected Function function; |
37 protected Parameters parameters; | 38 protected Parameters parameters; |
38 | 39 |
39 public FixATWriter() { | 40 public FixATWriter() { |
164 | 165 |
165 for (int i = 0; i < MAX_ITERATIONS; ++i) { | 166 for (int i = 0; i < MAX_ITERATIONS; ++i) { |
166 double w = lastW - stepWidth; | 167 double w = lastW - stepWidth; |
167 double q = function.value(w); | 168 double q = function.value(w); |
168 | 169 |
169 if (Double.isNaN(q) || q > lastQ || q < 0d) { | 170 if (Double.isNaN(q) || q > lastQ || q < MIN_Q) { |
170 if (stepWidth < EPSILON) { | 171 if (stepWidth < EPSILON) { |
171 break; | 172 break; |
172 } | 173 } |
173 stepWidth *= 0.5d; | 174 stepWidth *= 0.5d; |
174 continue; | 175 continue; |