Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/utils/DoubleUtil.java @ 5498:d459a885c51f
Schema change: make sq_relation_value.qmax NOT NULL and more informative messages in parser
author | Tom Gottfried <tom.gottfried@intevation.de> |
---|---|
date | Thu, 28 Mar 2013 14:02:52 +0100 |
parents | 240ff7aeb6de |
children |
rev | line source |
---|---|
655
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.utils; |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
2 |
3776
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2569
diff
changeset
|
3 import de.intevation.flys.artifacts.math.Linear; |
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2569
diff
changeset
|
4 |
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2569
diff
changeset
|
5 import gnu.trove.TDoubleArrayList; |
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2569
diff
changeset
|
6 |
1666
09c1292cf36d
Bugfix: #351 Modified determination of single values specified by min/max values and an interval.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
7 import java.util.Arrays; |
09c1292cf36d
Bugfix: #351 Modified determination of single values specified by min/max values and an interval.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
8 |
3776
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2569
diff
changeset
|
9 import org.apache.log4j.Logger; |
1666
09c1292cf36d
Bugfix: #351 Modified determination of single values specified by min/max values and an interval.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
10 |
4052
6d8c7a00e74e
Do cumentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3785
diff
changeset
|
11 /** Utils to deal with Double precision values. */ |
655
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
12 public class DoubleUtil |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
13 { |
4052
6d8c7a00e74e
Do cumentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3785
diff
changeset
|
14 /** Private logger. */ |
3776
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2569
diff
changeset
|
15 private static Logger log = Logger.getLogger(DoubleUtil.class); |
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2569
diff
changeset
|
16 |
655
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
17 public static final double DEFAULT_STEP_PRECISION = 1e6; |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
18 |
5151
240ff7aeb6de
DoubleUtil: Use tolerance when comparing doubles in explode(). Fixes flys/issue1132.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5150
diff
changeset
|
19 /** EPSILON for comparison of double precision values. */ |
240ff7aeb6de
DoubleUtil: Use tolerance when comparing doubles in explode(). Fixes flys/issue1132.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5150
diff
changeset
|
20 public static final double EPSILON = 1e-4; |
240ff7aeb6de
DoubleUtil: Use tolerance when comparing doubles in explode(). Fixes flys/issue1132.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5150
diff
changeset
|
21 |
655
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
22 private DoubleUtil() { |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
23 } |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
24 |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
25 public static final double [] explode(double from, double to, double step) { |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
26 return explode(from, to, step, DEFAULT_STEP_PRECISION); |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
27 } |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
28 |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
29 public static final double round(double x, double precision) { |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
30 return Math.round(x * precision)/precision; |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
31 } |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
32 |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
33 public static final double round(double x) { |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
34 return Math.round(x * DEFAULT_STEP_PRECISION)/DEFAULT_STEP_PRECISION; |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
35 } |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
36 |
5150
345f3bba6f15
Doc fixes.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5104
diff
changeset
|
37 /** |
345f3bba6f15
Doc fixes.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5104
diff
changeset
|
38 * Returns array with values from parameter from to to with given step width. |
345f3bba6f15
Doc fixes.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5104
diff
changeset
|
39 * from and to are included. |
345f3bba6f15
Doc fixes.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5104
diff
changeset
|
40 */ |
655
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
41 public static final double [] explode( |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
42 double from, |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
43 double to, |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
44 double step, |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
45 double precision |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
46 ) { |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
47 double lower = from; |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
48 |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
49 double diff = to - from; |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
50 double tmp = diff / step; |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
51 int num = (int)Math.abs(Math.ceil(tmp)) + 1; |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
52 |
4163
2b4f78ccfbaa
Made DoubleUtil.explode() more robust against invalid result array sizes.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4052
diff
changeset
|
53 if (num < 1) { |
2b4f78ccfbaa
Made DoubleUtil.explode() more robust against invalid result array sizes.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4052
diff
changeset
|
54 return new double[0]; |
2b4f78ccfbaa
Made DoubleUtil.explode() more robust against invalid result array sizes.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4052
diff
changeset
|
55 } |
2b4f78ccfbaa
Made DoubleUtil.explode() more robust against invalid result array sizes.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4052
diff
changeset
|
56 |
655
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
57 double [] values = new double[num]; |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
58 |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
59 if (from > to) { |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
60 step = -step; |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
61 } |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
62 |
1666
09c1292cf36d
Bugfix: #351 Modified determination of single values specified by min/max values and an interval.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
63 double max = Math.max(from, to); |
09c1292cf36d
Bugfix: #351 Modified determination of single values specified by min/max values and an interval.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
64 |
655
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
65 for (int idx = 0; idx < num; idx++) { |
5151
240ff7aeb6de
DoubleUtil: Use tolerance when comparing doubles in explode(). Fixes flys/issue1132.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5150
diff
changeset
|
66 if (lower - max > EPSILON) { |
1666
09c1292cf36d
Bugfix: #351 Modified determination of single values specified by min/max values and an interval.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
67 return Arrays.copyOfRange(values, 0, idx); |
09c1292cf36d
Bugfix: #351 Modified determination of single values specified by min/max values and an interval.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
68 } |
09c1292cf36d
Bugfix: #351 Modified determination of single values specified by min/max values and an interval.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
69 |
655
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
70 values[idx] = round(lower, precision); |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
71 lower += step; |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
72 } |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
73 |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
74 return values; |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
75 } |
1671
da872168a899
Added code to interpolate double values in a sorted array
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1666
diff
changeset
|
76 |
da872168a899
Added code to interpolate double values in a sorted array
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1666
diff
changeset
|
77 public static final double interpolateSorted( |
da872168a899
Added code to interpolate double values in a sorted array
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1666
diff
changeset
|
78 double [] xs, |
da872168a899
Added code to interpolate double values in a sorted array
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1666
diff
changeset
|
79 double [] ys, |
da872168a899
Added code to interpolate double values in a sorted array
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1666
diff
changeset
|
80 double x |
da872168a899
Added code to interpolate double values in a sorted array
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1666
diff
changeset
|
81 ) { |
da872168a899
Added code to interpolate double values in a sorted array
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1666
diff
changeset
|
82 int lo = 0, hi = xs.length-1; |
da872168a899
Added code to interpolate double values in a sorted array
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1666
diff
changeset
|
83 |
da872168a899
Added code to interpolate double values in a sorted array
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1666
diff
changeset
|
84 int mid = -1; |
da872168a899
Added code to interpolate double values in a sorted array
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1666
diff
changeset
|
85 |
da872168a899
Added code to interpolate double values in a sorted array
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1666
diff
changeset
|
86 while (lo <= hi) { |
da872168a899
Added code to interpolate double values in a sorted array
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1666
diff
changeset
|
87 mid = (lo + hi) >> 1; |
da872168a899
Added code to interpolate double values in a sorted array
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1666
diff
changeset
|
88 double mx = xs[mid]; |
da872168a899
Added code to interpolate double values in a sorted array
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1666
diff
changeset
|
89 if (x < mx) hi = mid - 1; |
da872168a899
Added code to interpolate double values in a sorted array
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1666
diff
changeset
|
90 else if (x > mx) lo = mid + 1; |
da872168a899
Added code to interpolate double values in a sorted array
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1666
diff
changeset
|
91 else return ys[mid]; |
da872168a899
Added code to interpolate double values in a sorted array
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1666
diff
changeset
|
92 } |
da872168a899
Added code to interpolate double values in a sorted array
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1666
diff
changeset
|
93 if (mid < lo) { |
da872168a899
Added code to interpolate double values in a sorted array
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1666
diff
changeset
|
94 return lo >= xs.length |
da872168a899
Added code to interpolate double values in a sorted array
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1666
diff
changeset
|
95 ? Double.NaN |
da872168a899
Added code to interpolate double values in a sorted array
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1666
diff
changeset
|
96 : Linear.linear(x, xs[mid], xs[mid+1], ys[mid], ys[mid+1]); |
da872168a899
Added code to interpolate double values in a sorted array
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1666
diff
changeset
|
97 } |
da872168a899
Added code to interpolate double values in a sorted array
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1666
diff
changeset
|
98 return hi < 0 |
da872168a899
Added code to interpolate double values in a sorted array
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1666
diff
changeset
|
99 ? Double.NaN |
da872168a899
Added code to interpolate double values in a sorted array
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1666
diff
changeset
|
100 : Linear.linear(x, xs[mid-1], xs[mid], ys[mid-1], ys[mid]); |
da872168a899
Added code to interpolate double values in a sorted array
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1666
diff
changeset
|
101 } |
1672
0b6dac664bbb
Moved some generic double array code from BackjumpCorrector to DoubleUtil
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1671
diff
changeset
|
102 |
0b6dac664bbb
Moved some generic double array code from BackjumpCorrector to DoubleUtil
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1671
diff
changeset
|
103 public static final boolean isIncreasing(double [] array) { |
0b6dac664bbb
Moved some generic double array code from BackjumpCorrector to DoubleUtil
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1671
diff
changeset
|
104 int inc = 0; |
0b6dac664bbb
Moved some generic double array code from BackjumpCorrector to DoubleUtil
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1671
diff
changeset
|
105 int dec = 0; |
0b6dac664bbb
Moved some generic double array code from BackjumpCorrector to DoubleUtil
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1671
diff
changeset
|
106 int sweet = (array.length-1)/2; |
0b6dac664bbb
Moved some generic double array code from BackjumpCorrector to DoubleUtil
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1671
diff
changeset
|
107 for (int i = 1; i < array.length; ++i) { |
0b6dac664bbb
Moved some generic double array code from BackjumpCorrector to DoubleUtil
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1671
diff
changeset
|
108 if (array[i] > array[i-1]) { |
0b6dac664bbb
Moved some generic double array code from BackjumpCorrector to DoubleUtil
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1671
diff
changeset
|
109 if (++inc > sweet) { |
0b6dac664bbb
Moved some generic double array code from BackjumpCorrector to DoubleUtil
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1671
diff
changeset
|
110 return true; |
0b6dac664bbb
Moved some generic double array code from BackjumpCorrector to DoubleUtil
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1671
diff
changeset
|
111 } |
0b6dac664bbb
Moved some generic double array code from BackjumpCorrector to DoubleUtil
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1671
diff
changeset
|
112 } |
0b6dac664bbb
Moved some generic double array code from BackjumpCorrector to DoubleUtil
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1671
diff
changeset
|
113 else if (++dec > sweet) { |
0b6dac664bbb
Moved some generic double array code from BackjumpCorrector to DoubleUtil
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1671
diff
changeset
|
114 return false; |
0b6dac664bbb
Moved some generic double array code from BackjumpCorrector to DoubleUtil
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1671
diff
changeset
|
115 } |
0b6dac664bbb
Moved some generic double array code from BackjumpCorrector to DoubleUtil
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1671
diff
changeset
|
116 } |
0b6dac664bbb
Moved some generic double array code from BackjumpCorrector to DoubleUtil
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1671
diff
changeset
|
117 return inc > sweet; |
0b6dac664bbb
Moved some generic double array code from BackjumpCorrector to DoubleUtil
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1671
diff
changeset
|
118 } |
0b6dac664bbb
Moved some generic double array code from BackjumpCorrector to DoubleUtil
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1671
diff
changeset
|
119 |
0b6dac664bbb
Moved some generic double array code from BackjumpCorrector to DoubleUtil
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1671
diff
changeset
|
120 public static final double [] swap(double [] array) { |
0b6dac664bbb
Moved some generic double array code from BackjumpCorrector to DoubleUtil
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1671
diff
changeset
|
121 int lo = 0; |
0b6dac664bbb
Moved some generic double array code from BackjumpCorrector to DoubleUtil
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1671
diff
changeset
|
122 int hi = array.length-1; |
0b6dac664bbb
Moved some generic double array code from BackjumpCorrector to DoubleUtil
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1671
diff
changeset
|
123 while (hi > lo) { |
0b6dac664bbb
Moved some generic double array code from BackjumpCorrector to DoubleUtil
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1671
diff
changeset
|
124 double t = array[lo]; |
0b6dac664bbb
Moved some generic double array code from BackjumpCorrector to DoubleUtil
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1671
diff
changeset
|
125 array[lo] = array[hi]; |
0b6dac664bbb
Moved some generic double array code from BackjumpCorrector to DoubleUtil
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1671
diff
changeset
|
126 array[hi] = t; |
0b6dac664bbb
Moved some generic double array code from BackjumpCorrector to DoubleUtil
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1671
diff
changeset
|
127 ++lo; |
0b6dac664bbb
Moved some generic double array code from BackjumpCorrector to DoubleUtil
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1671
diff
changeset
|
128 --hi; |
0b6dac664bbb
Moved some generic double array code from BackjumpCorrector to DoubleUtil
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1671
diff
changeset
|
129 } |
0b6dac664bbb
Moved some generic double array code from BackjumpCorrector to DoubleUtil
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1671
diff
changeset
|
130 |
0b6dac664bbb
Moved some generic double array code from BackjumpCorrector to DoubleUtil
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1671
diff
changeset
|
131 return array; |
0b6dac664bbb
Moved some generic double array code from BackjumpCorrector to DoubleUtil
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1671
diff
changeset
|
132 } |
0b6dac664bbb
Moved some generic double array code from BackjumpCorrector to DoubleUtil
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1671
diff
changeset
|
133 |
0b6dac664bbb
Moved some generic double array code from BackjumpCorrector to DoubleUtil
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1671
diff
changeset
|
134 public static final double [] swapClone(double [] in) { |
0b6dac664bbb
Moved some generic double array code from BackjumpCorrector to DoubleUtil
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1671
diff
changeset
|
135 double [] out = new double[in.length]; |
0b6dac664bbb
Moved some generic double array code from BackjumpCorrector to DoubleUtil
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1671
diff
changeset
|
136 |
0b6dac664bbb
Moved some generic double array code from BackjumpCorrector to DoubleUtil
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1671
diff
changeset
|
137 for (int j = out.length-1, i = 0; j >= 0;) { |
0b6dac664bbb
Moved some generic double array code from BackjumpCorrector to DoubleUtil
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1671
diff
changeset
|
138 out[j--] = in[i++]; |
0b6dac664bbb
Moved some generic double array code from BackjumpCorrector to DoubleUtil
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1671
diff
changeset
|
139 } |
0b6dac664bbb
Moved some generic double array code from BackjumpCorrector to DoubleUtil
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1671
diff
changeset
|
140 |
0b6dac664bbb
Moved some generic double array code from BackjumpCorrector to DoubleUtil
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1671
diff
changeset
|
141 return out; |
0b6dac664bbb
Moved some generic double array code from BackjumpCorrector to DoubleUtil
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1671
diff
changeset
|
142 } |
0b6dac664bbb
Moved some generic double array code from BackjumpCorrector to DoubleUtil
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1671
diff
changeset
|
143 |
0b6dac664bbb
Moved some generic double array code from BackjumpCorrector to DoubleUtil
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1671
diff
changeset
|
144 public static final double [] sumDiffs(double [] in) { |
0b6dac664bbb
Moved some generic double array code from BackjumpCorrector to DoubleUtil
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1671
diff
changeset
|
145 double [] out = new double[in.length]; |
0b6dac664bbb
Moved some generic double array code from BackjumpCorrector to DoubleUtil
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1671
diff
changeset
|
146 |
0b6dac664bbb
Moved some generic double array code from BackjumpCorrector to DoubleUtil
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1671
diff
changeset
|
147 for (int i = 1; i < out.length; ++i) { |
0b6dac664bbb
Moved some generic double array code from BackjumpCorrector to DoubleUtil
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1671
diff
changeset
|
148 out[i] = out[i-1] + Math.abs(in[i-1] - in[i]); |
0b6dac664bbb
Moved some generic double array code from BackjumpCorrector to DoubleUtil
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1671
diff
changeset
|
149 } |
0b6dac664bbb
Moved some generic double array code from BackjumpCorrector to DoubleUtil
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1671
diff
changeset
|
150 |
0b6dac664bbb
Moved some generic double array code from BackjumpCorrector to DoubleUtil
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1671
diff
changeset
|
151 return out; |
0b6dac664bbb
Moved some generic double array code from BackjumpCorrector to DoubleUtil
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1671
diff
changeset
|
152 } |
2569
0dd58ab7e118
Added functions to be used for fitting in the "Fixierungsanalyse" and "Extremwertermittlung".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1672
diff
changeset
|
153 |
0dd58ab7e118
Added functions to be used for fitting in the "Fixierungsanalyse" and "Extremwertermittlung".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1672
diff
changeset
|
154 public static final double [] fill(int N, double value) { |
0dd58ab7e118
Added functions to be used for fitting in the "Fixierungsanalyse" and "Extremwertermittlung".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1672
diff
changeset
|
155 double [] result = new double[N]; |
0dd58ab7e118
Added functions to be used for fitting in the "Fixierungsanalyse" and "Extremwertermittlung".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1672
diff
changeset
|
156 Arrays.fill(result, value); |
0dd58ab7e118
Added functions to be used for fitting in the "Fixierungsanalyse" and "Extremwertermittlung".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1672
diff
changeset
|
157 return result; |
0dd58ab7e118
Added functions to be used for fitting in the "Fixierungsanalyse" and "Extremwertermittlung".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1672
diff
changeset
|
158 } |
3776
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2569
diff
changeset
|
159 |
4052
6d8c7a00e74e
Do cumentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3785
diff
changeset
|
160 |
6d8c7a00e74e
Do cumentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3785
diff
changeset
|
161 /** Use with parseSegments. */ |
3776
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2569
diff
changeset
|
162 public interface SegmentCallback { |
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2569
diff
changeset
|
163 void newSegment(double from, double to, double [] values); |
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2569
diff
changeset
|
164 } |
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2569
diff
changeset
|
165 |
4052
6d8c7a00e74e
Do cumentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3785
diff
changeset
|
166 |
6d8c7a00e74e
Do cumentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3785
diff
changeset
|
167 /** Call callback for every string split by colon. |
4433
5b8919ef601d
Backed out changeset e8a4d2fd25cc
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4432
diff
changeset
|
168 * Expected format FROM:TO:VALUE1,VALUE2,VALUE3*/ |
3776
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2569
diff
changeset
|
169 public static final void parseSegments( |
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2569
diff
changeset
|
170 String input, |
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2569
diff
changeset
|
171 SegmentCallback callback |
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2569
diff
changeset
|
172 ) { |
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2569
diff
changeset
|
173 TDoubleArrayList vs = new TDoubleArrayList(); |
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2569
diff
changeset
|
174 |
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2569
diff
changeset
|
175 for (String segmentStr: input.split(":")) { |
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2569
diff
changeset
|
176 String [] parts = segmentStr.split(";"); |
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2569
diff
changeset
|
177 if (parts.length < 3) { |
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2569
diff
changeset
|
178 log.warn("invalid segment: '" + segmentStr + "'"); |
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2569
diff
changeset
|
179 continue; |
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2569
diff
changeset
|
180 } |
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2569
diff
changeset
|
181 try { |
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2569
diff
changeset
|
182 double from = Double.parseDouble(parts[0].trim()); |
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2569
diff
changeset
|
183 double to = Double.parseDouble(parts[1].trim()); |
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2569
diff
changeset
|
184 |
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2569
diff
changeset
|
185 vs.resetQuick(); |
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2569
diff
changeset
|
186 |
5104
5f70c73b11ed
Display gauge names in WQAdapted input panel instead of gauge range.
Raimund Renkert <rrenkert@intevation.de>
parents:
4821
diff
changeset
|
187 for (String valueStr: parts[3].split(",")) { |
3776
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2569
diff
changeset
|
188 vs.add(round(Double.parseDouble(valueStr.trim()))); |
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2569
diff
changeset
|
189 } |
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2569
diff
changeset
|
190 |
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2569
diff
changeset
|
191 callback.newSegment(from, to, vs.toNativeArray()); |
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2569
diff
changeset
|
192 } |
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2569
diff
changeset
|
193 catch (NumberFormatException nfe) { |
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2569
diff
changeset
|
194 log.warn("invalid segment: '" + segmentStr + "'"); |
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2569
diff
changeset
|
195 } |
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2569
diff
changeset
|
196 } |
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2569
diff
changeset
|
197 } |
3785
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3776
diff
changeset
|
198 |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3776
diff
changeset
|
199 public static final boolean isValid(double [][] data) { |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3776
diff
changeset
|
200 for (double [] ds: data) { |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3776
diff
changeset
|
201 for (double d: ds) { |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3776
diff
changeset
|
202 if (Double.isNaN(d)) { |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3776
diff
changeset
|
203 return false; |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3776
diff
changeset
|
204 } |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3776
diff
changeset
|
205 } |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3776
diff
changeset
|
206 } |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3776
diff
changeset
|
207 return true; |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3776
diff
changeset
|
208 } |
4340
64528d2a89c4
DoubleUtil: New function to find max in an double array.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4163
diff
changeset
|
209 |
64528d2a89c4
DoubleUtil: New function to find max in an double array.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4163
diff
changeset
|
210 |
64528d2a89c4
DoubleUtil: New function to find max in an double array.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4163
diff
changeset
|
211 /** In an array of doubles, search and return the maximum value. */ |
64528d2a89c4
DoubleUtil: New function to find max in an double array.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4163
diff
changeset
|
212 public static final double maxInArray(double[] values) { |
64528d2a89c4
DoubleUtil: New function to find max in an double array.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4163
diff
changeset
|
213 double max = - Double.MAX_VALUE; |
64528d2a89c4
DoubleUtil: New function to find max in an double array.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4163
diff
changeset
|
214 for (double d: values) { |
64528d2a89c4
DoubleUtil: New function to find max in an double array.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4163
diff
changeset
|
215 if (d > max) max = d; |
64528d2a89c4
DoubleUtil: New function to find max in an double array.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4163
diff
changeset
|
216 } |
64528d2a89c4
DoubleUtil: New function to find max in an double array.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4163
diff
changeset
|
217 return max; |
64528d2a89c4
DoubleUtil: New function to find max in an double array.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4163
diff
changeset
|
218 } |
4821
bcf25d8c183e
Moved NaN removal code from W to DoubleUtil. Create QKms when calculating the 'Umhuellende'.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4433
diff
changeset
|
219 |
bcf25d8c183e
Moved NaN removal code from W to DoubleUtil. Create QKms when calculating the 'Umhuellende'.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4433
diff
changeset
|
220 public static void removeNaNs(TDoubleArrayList [] arrays) { |
bcf25d8c183e
Moved NaN removal code from W to DoubleUtil. Create QKms when calculating the 'Umhuellende'.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4433
diff
changeset
|
221 |
bcf25d8c183e
Moved NaN removal code from W to DoubleUtil. Create QKms when calculating the 'Umhuellende'.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4433
diff
changeset
|
222 int dest = 0; |
bcf25d8c183e
Moved NaN removal code from W to DoubleUtil. Create QKms when calculating the 'Umhuellende'.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4433
diff
changeset
|
223 |
bcf25d8c183e
Moved NaN removal code from W to DoubleUtil. Create QKms when calculating the 'Umhuellende'.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4433
diff
changeset
|
224 int A = arrays.length; |
bcf25d8c183e
Moved NaN removal code from W to DoubleUtil. Create QKms when calculating the 'Umhuellende'.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4433
diff
changeset
|
225 int N = arrays[0].size(); |
bcf25d8c183e
Moved NaN removal code from W to DoubleUtil. Create QKms when calculating the 'Umhuellende'.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4433
diff
changeset
|
226 |
bcf25d8c183e
Moved NaN removal code from W to DoubleUtil. Create QKms when calculating the 'Umhuellende'.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4433
diff
changeset
|
227 OUTER: for (int i = 0; i < N; ++i) { |
bcf25d8c183e
Moved NaN removal code from W to DoubleUtil. Create QKms when calculating the 'Umhuellende'.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4433
diff
changeset
|
228 for (int j = 0; j < A; ++j) { |
bcf25d8c183e
Moved NaN removal code from W to DoubleUtil. Create QKms when calculating the 'Umhuellende'.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4433
diff
changeset
|
229 TDoubleArrayList a = arrays[j]; |
bcf25d8c183e
Moved NaN removal code from W to DoubleUtil. Create QKms when calculating the 'Umhuellende'.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4433
diff
changeset
|
230 double v = a.getQuick(i); |
bcf25d8c183e
Moved NaN removal code from W to DoubleUtil. Create QKms when calculating the 'Umhuellende'.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4433
diff
changeset
|
231 if (Double.isNaN(v)) { |
bcf25d8c183e
Moved NaN removal code from W to DoubleUtil. Create QKms when calculating the 'Umhuellende'.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4433
diff
changeset
|
232 continue OUTER; |
bcf25d8c183e
Moved NaN removal code from W to DoubleUtil. Create QKms when calculating the 'Umhuellende'.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4433
diff
changeset
|
233 } |
bcf25d8c183e
Moved NaN removal code from W to DoubleUtil. Create QKms when calculating the 'Umhuellende'.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4433
diff
changeset
|
234 a.setQuick(dest, v); |
bcf25d8c183e
Moved NaN removal code from W to DoubleUtil. Create QKms when calculating the 'Umhuellende'.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4433
diff
changeset
|
235 } |
bcf25d8c183e
Moved NaN removal code from W to DoubleUtil. Create QKms when calculating the 'Umhuellende'.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4433
diff
changeset
|
236 ++dest; |
bcf25d8c183e
Moved NaN removal code from W to DoubleUtil. Create QKms when calculating the 'Umhuellende'.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4433
diff
changeset
|
237 } |
bcf25d8c183e
Moved NaN removal code from W to DoubleUtil. Create QKms when calculating the 'Umhuellende'.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4433
diff
changeset
|
238 |
bcf25d8c183e
Moved NaN removal code from W to DoubleUtil. Create QKms when calculating the 'Umhuellende'.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4433
diff
changeset
|
239 if (dest < N) { |
bcf25d8c183e
Moved NaN removal code from W to DoubleUtil. Create QKms when calculating the 'Umhuellende'.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4433
diff
changeset
|
240 for (int i = 0; i < A; ++i) { |
bcf25d8c183e
Moved NaN removal code from W to DoubleUtil. Create QKms when calculating the 'Umhuellende'.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4433
diff
changeset
|
241 arrays[i].remove(dest, N-dest); |
bcf25d8c183e
Moved NaN removal code from W to DoubleUtil. Create QKms when calculating the 'Umhuellende'.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4433
diff
changeset
|
242 } |
bcf25d8c183e
Moved NaN removal code from W to DoubleUtil. Create QKms when calculating the 'Umhuellende'.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4433
diff
changeset
|
243 } |
bcf25d8c183e
Moved NaN removal code from W to DoubleUtil. Create QKms when calculating the 'Umhuellende'.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4433
diff
changeset
|
244 } |
655
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
245 } |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
246 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |