Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WQKms.java @ 675:8b0152363bdb
Added methods to remove NaN values.
flys-artifacts/trunk@2099 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Fri, 10 Jun 2011 10:10:04 +0000 |
parents | 5606ba4139e0 |
children | 19a3185822a4 |
comparison
equal
deleted
inserted
replaced
674:d5f9ba1d055f | 675:8b0152363bdb |
---|---|
51 this.w = new TDoubleArrayList(capacity); | 51 this.w = new TDoubleArrayList(capacity); |
52 this.q = new TDoubleArrayList(capacity); | 52 this.q = new TDoubleArrayList(capacity); |
53 this.kms = new TDoubleArrayList(capacity); | 53 this.kms = new TDoubleArrayList(capacity); |
54 } | 54 } |
55 | 55 |
56 public static void removeNaNs(TDoubleArrayList [] arrays) { | |
57 | |
58 int dest = 0; | |
59 | |
60 int A = arrays.length; | |
61 int N = arrays[0].size(); | |
62 | |
63 OUTER: for (int i = 0; i < N; ++i) { | |
64 for (int j = 0; j < A; ++j) { | |
65 TDoubleArrayList a = arrays[j]; | |
66 double v = a.getQuick(i); | |
67 if (Double.isNaN(v)) { | |
68 continue OUTER; | |
69 } | |
70 a.setQuick(dest, v); | |
71 } | |
72 ++dest; | |
73 } | |
74 | |
75 if (dest < N) { | |
76 for (int i = 0; i < A; ++i) { | |
77 arrays[i].remove(dest, N-dest); | |
78 } | |
79 } | |
80 } | |
81 | |
82 public void removeNaNs() { | |
83 removeNaNs(new TDoubleArrayList [] { w, q, kms }); | |
84 } | |
85 | |
56 | 86 |
57 public WQKms(double[] kms, double[] qs, double[] ws) { | 87 public WQKms(double[] kms, double[] qs, double[] ws) { |
58 this(kms, qs, ws, ""); | 88 this(kms, qs, ws, ""); |
59 } | 89 } |
60 | 90 |
105 * @param dst destination array | 135 * @param dst destination array |
106 * | 136 * |
107 * @return a triple of [W, Q, Kms] in dst. | 137 * @return a triple of [W, Q, Kms] in dst. |
108 */ | 138 */ |
109 public double[] get(int idx, double [] dst) { | 139 public double[] get(int idx, double [] dst) { |
110 dst[0] = w .get(idx); | 140 dst[0] = w .getQuick(idx); |
111 dst[1] = q .get(idx); | 141 dst[1] = q .getQuick(idx); |
112 dst[2] = kms.get(idx); | 142 dst[2] = kms.getQuick(idx); |
113 return dst; | 143 return dst; |
114 } | 144 } |
115 | 145 |
116 | 146 |
117 public double getKms(int idx) { | 147 public double getKms(int idx) { |
118 return kms.get(idx); | 148 return kms.getQuick(idx); |
119 } | 149 } |
120 | 150 |
121 | 151 |
122 public double[] getKms() { | 152 public double[] getKms() { |
123 return kms.toNativeArray(); | 153 return kms.toNativeArray(); |