Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Parameters.java @ 3066:4c22194b733a
Some minor bugfixes in fix analysis calculation and some more debug output.
flys-artifacts/trunk@4650 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Wed, 13 Jun 2012 11:13:17 +0000 |
parents | 49baebb39305 |
children | 5642a83420f2 |
rev | line source |
---|---|
2695
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.model; |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
2 |
3059
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
3 import de.intevation.flys.artifacts.math.Linear; |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
4 |
2695
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
5 import gnu.trove.TDoubleArrayList; |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
6 |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
7 import java.io.Serializable; |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
8 |
2785
f87fcedbfa82
FixA: Fixed stupid index bug.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2744
diff
changeset
|
9 import org.apache.log4j.Logger; |
f87fcedbfa82
FixA: Fixed stupid index bug.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2744
diff
changeset
|
10 |
2695
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
11 public class Parameters |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
12 implements Serializable |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
13 { |
2785
f87fcedbfa82
FixA: Fixed stupid index bug.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2744
diff
changeset
|
14 private static Logger log = Logger.getLogger(Parameters.class); |
f87fcedbfa82
FixA: Fixed stupid index bug.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2744
diff
changeset
|
15 |
3059
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
16 public static final double EPSILON = 1e-4; |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
17 |
2695
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
18 protected String [] columnNames; |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
19 protected TDoubleArrayList [] columns; |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
20 |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
21 public Parameters() { |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
22 } |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
23 |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
24 public Parameters(String [] columnNames) { |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
25 if (columnNames == null || columnNames.length < 1) { |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
26 throw new IllegalArgumentException("columnNames too short."); |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
27 } |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
28 this.columnNames = columnNames; |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
29 columns = new TDoubleArrayList[columnNames.length]; |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
30 for (int i = 0; i < columns.length; ++i) { |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
31 columns[i] = new TDoubleArrayList(); |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
32 } |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
33 } |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
34 |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
35 public int columnIndex(String name) { |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
36 for (int i = 0; i < columnNames.length; ++i) { |
2993
70469e3d34b9
FixA: Made Delta W/t calculation finally work
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2785
diff
changeset
|
37 if (columnNames[i].equals(name)) { |
2695
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
38 return i; |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
39 } |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
40 } |
3057
febc39e77672
Make it compilable again
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3056
diff
changeset
|
41 if (log.isDebugEnabled()) { |
febc39e77672
Make it compilable again
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3056
diff
changeset
|
42 log.debug("columnIndex: " + name + " not found in columnNames"); |
febc39e77672
Make it compilable again
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3056
diff
changeset
|
43 } |
2695
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
44 return -1; |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
45 } |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
46 |
2729
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2695
diff
changeset
|
47 public int newRow() { |
2695
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
48 |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
49 int N = columns[0].size(); |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
50 |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
51 for (int i = 0; i < columns.length; ++i) { |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
52 columns[i].add(Double.NaN); |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
53 } |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
54 |
2729
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2695
diff
changeset
|
55 return N; |
2695
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
56 } |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
57 |
3010
05a3fe8800b3
FixA: Store Chi^2 of fitting into result, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2993
diff
changeset
|
58 public double get(int row, int index) { |
05a3fe8800b3
FixA: Store Chi^2 of fitting into result, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2993
diff
changeset
|
59 return columns[index].getQuick(row); |
2695
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
60 } |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
61 |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
62 public double get(int i, String columnName) { |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
63 int index = columnIndex(columnName); |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
64 return index >= 0 |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
65 ? columns[index].getQuick(i) |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
66 : Double.NaN; |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
67 } |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
68 |
3010
05a3fe8800b3
FixA: Store Chi^2 of fitting into result, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2993
diff
changeset
|
69 public void set(int row, int index, double value) { |
05a3fe8800b3
FixA: Store Chi^2 of fitting into result, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2993
diff
changeset
|
70 columns[index].setQuick(row, value); |
05a3fe8800b3
FixA: Store Chi^2 of fitting into result, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2993
diff
changeset
|
71 } |
05a3fe8800b3
FixA: Store Chi^2 of fitting into result, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2993
diff
changeset
|
72 |
2729
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2695
diff
changeset
|
73 public void set(int i, String columnName, double value) { |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2695
diff
changeset
|
74 int idx = columnIndex(columnName); |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2695
diff
changeset
|
75 if (idx >= 0) { |
2785
f87fcedbfa82
FixA: Fixed stupid index bug.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2744
diff
changeset
|
76 columns[idx].setQuick(i, value); |
2729
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2695
diff
changeset
|
77 } |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2695
diff
changeset
|
78 } |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2695
diff
changeset
|
79 |
3011
ab81ffd1343e
FixA: Reactivated rewrite of the outlier checks.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3010
diff
changeset
|
80 public boolean set(int row, int [] indices, double [] values) { |
ab81ffd1343e
FixA: Reactivated rewrite of the outlier checks.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3010
diff
changeset
|
81 boolean invalid = false; |
ab81ffd1343e
FixA: Reactivated rewrite of the outlier checks.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3010
diff
changeset
|
82 for (int i = 0; i < indices.length; ++i) { |
ab81ffd1343e
FixA: Reactivated rewrite of the outlier checks.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3010
diff
changeset
|
83 double v = values[i]; |
ab81ffd1343e
FixA: Reactivated rewrite of the outlier checks.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3010
diff
changeset
|
84 if (Double.isNaN(v)) { |
ab81ffd1343e
FixA: Reactivated rewrite of the outlier checks.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3010
diff
changeset
|
85 invalid = true; |
ab81ffd1343e
FixA: Reactivated rewrite of the outlier checks.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3010
diff
changeset
|
86 } |
ab81ffd1343e
FixA: Reactivated rewrite of the outlier checks.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3010
diff
changeset
|
87 else { |
ab81ffd1343e
FixA: Reactivated rewrite of the outlier checks.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3010
diff
changeset
|
88 columns[indices[i]].setQuick(row, v); |
ab81ffd1343e
FixA: Reactivated rewrite of the outlier checks.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3010
diff
changeset
|
89 } |
ab81ffd1343e
FixA: Reactivated rewrite of the outlier checks.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3010
diff
changeset
|
90 } |
ab81ffd1343e
FixA: Reactivated rewrite of the outlier checks.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3010
diff
changeset
|
91 return invalid; |
ab81ffd1343e
FixA: Reactivated rewrite of the outlier checks.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3010
diff
changeset
|
92 } |
ab81ffd1343e
FixA: Reactivated rewrite of the outlier checks.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3010
diff
changeset
|
93 |
2695
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
94 public int size() { |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
95 return columns[0].size(); |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
96 } |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
97 |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
98 public int getNumberColumns() { |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
99 return columnNames.length; |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
100 } |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
101 |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
102 public String [] getColumnNames() { |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
103 return columnNames; |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
104 } |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
105 |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
106 public void removeNaNs() { |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
107 W.removeNaNs(columns); |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
108 } |
2744
c1f2e792704a
FixA: Calculate Delta W/t, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2729
diff
changeset
|
109 |
c1f2e792704a
FixA: Calculate Delta W/t, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2729
diff
changeset
|
110 public int [] columnIndices(String [] columns) { |
c1f2e792704a
FixA: Calculate Delta W/t, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2729
diff
changeset
|
111 int [] indices = new int[columns.length]; |
c1f2e792704a
FixA: Calculate Delta W/t, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2729
diff
changeset
|
112 for (int i = 0; i < columns.length; ++i) { |
c1f2e792704a
FixA: Calculate Delta W/t, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2729
diff
changeset
|
113 indices[i] = columnIndex(columns[i]); |
c1f2e792704a
FixA: Calculate Delta W/t, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2729
diff
changeset
|
114 } |
c1f2e792704a
FixA: Calculate Delta W/t, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2729
diff
changeset
|
115 return indices; |
c1f2e792704a
FixA: Calculate Delta W/t, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2729
diff
changeset
|
116 } |
c1f2e792704a
FixA: Calculate Delta W/t, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2729
diff
changeset
|
117 |
c1f2e792704a
FixA: Calculate Delta W/t, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2729
diff
changeset
|
118 public void get(int row, int [] columnIndices, double [] values) { |
c1f2e792704a
FixA: Calculate Delta W/t, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2729
diff
changeset
|
119 for (int i = 0; i < columnIndices.length; ++i) { |
c1f2e792704a
FixA: Calculate Delta W/t, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2729
diff
changeset
|
120 int index = columnIndices[i]; |
c1f2e792704a
FixA: Calculate Delta W/t, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2729
diff
changeset
|
121 values[i] = index >= 0 && index < columns.length |
c1f2e792704a
FixA: Calculate Delta W/t, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2729
diff
changeset
|
122 ? columns[index].getQuick(row) |
c1f2e792704a
FixA: Calculate Delta W/t, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2729
diff
changeset
|
123 : Double.NaN; |
c1f2e792704a
FixA: Calculate Delta W/t, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2729
diff
changeset
|
124 } |
c1f2e792704a
FixA: Calculate Delta W/t, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2729
diff
changeset
|
125 } |
3027
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
126 |
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
127 public int binarySearch(String columnName, double value) { |
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
128 return binarySearch(columnIndex(columnName), value); |
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
129 } |
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
130 |
3056
0b5a7a2c3724
Try to workaround some exception in FixWQCurveFacet and FixWQCurveGenerator
Christian Lins <christian.lins@intevation.de>
parents:
3027
diff
changeset
|
131 /** |
0b5a7a2c3724
Try to workaround some exception in FixWQCurveFacet and FixWQCurveGenerator
Christian Lins <christian.lins@intevation.de>
parents:
3027
diff
changeset
|
132 * Performes a binary search in the column identified by its |
0b5a7a2c3724
Try to workaround some exception in FixWQCurveFacet and FixWQCurveGenerator
Christian Lins <christian.lins@intevation.de>
parents:
3027
diff
changeset
|
133 * index. |
0b5a7a2c3724
Try to workaround some exception in FixWQCurveFacet and FixWQCurveGenerator
Christian Lins <christian.lins@intevation.de>
parents:
3027
diff
changeset
|
134 * @return Index of found element or negative insertion point (shifted by one) |
0b5a7a2c3724
Try to workaround some exception in FixWQCurveFacet and FixWQCurveGenerator
Christian Lins <christian.lins@intevation.de>
parents:
3027
diff
changeset
|
135 */ |
3027
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
136 public int binarySearch(int columnIndex, double value) { |
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
137 TDoubleArrayList column = columns[columnIndex]; |
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
138 return column.binarySearch(value); |
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
139 } |
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
140 |
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
141 public int binarySearch(String columnName, double value, double epsilon) { |
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
142 return binarySearch(columnIndex(columnName), value, epsilon); |
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
143 } |
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
144 |
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
145 public int binarySearch(int columnIndex, double value, double epsilon) { |
3057
febc39e77672
Make it compilable again
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3056
diff
changeset
|
146 if (epsilon < 0d) epsilon = -epsilon; |
3027
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
147 double vl = value - epsilon; |
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
148 double vh = value + epsilon; |
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
149 |
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
150 TDoubleArrayList column = columns[columnIndex]; |
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
151 int lo = 0, hi = column.size()-1; |
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
152 while (hi >= lo) { |
3056
0b5a7a2c3724
Try to workaround some exception in FixWQCurveFacet and FixWQCurveGenerator
Christian Lins <christian.lins@intevation.de>
parents:
3027
diff
changeset
|
153 int mid = (lo + hi) >> 1; |
3027
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
154 double v = column.getQuick(mid); |
3057
febc39e77672
Make it compilable again
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3056
diff
changeset
|
155 if (v < vl) hi = mid - 1; |
febc39e77672
Make it compilable again
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3056
diff
changeset
|
156 else if (v > vh) lo = mid + 1; |
febc39e77672
Make it compilable again
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3056
diff
changeset
|
157 else return mid; |
3027
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
158 } |
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
159 |
3059
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
160 return -(lo + 1); |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
161 } |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
162 |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
163 public double [] interpolate(int columnIndex, double key) { |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
164 return interpolate(columnIndex, key, new double[columns.length]); |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
165 } |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
166 |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
167 public double [] interpolate(String columnName, double key) { |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
168 return interpolate( |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
169 columnIndex(columnName), key, new double[columns.length]); |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
170 } |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
171 |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
172 public double [] interpolate( |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
173 String columnName, |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
174 double key, |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
175 double [] values |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
176 ) { |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
177 return interpolate(columnIndex(columnName), key, values); |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
178 } |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
179 |
3061
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
180 public double [] interpolate( |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
181 int columnIndex, |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
182 double key, |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
183 double [] values |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
184 ) { |
3059
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
185 int row = binarySearch(columnIndex, key, EPSILON); |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
186 |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
187 if (row >= 0) { |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
188 for (int i = 0; i < values.length; ++i) { |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
189 values[i] = columns[i].getQuick(row); |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
190 } |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
191 } |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
192 else { |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
193 row = -row - 1; |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
194 if (row < 1 || row >= size()) { |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
195 return null; |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
196 } |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
197 double v1 = columns[columnIndex].getQuick(row-1); |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
198 double v2 = columns[columnIndex].getQuick(row); |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
199 double factor = Linear.factor(key, v1, v2); |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
200 for (int i = 0; i < values.length; ++i) { |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
201 values[i] = Linear.weight( |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
202 factor, |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
203 columns[i].getQuick(row-1), |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
204 columns[i].getQuick(row)); |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
205 } |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
206 } |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
207 return values; |
3027
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
208 } |
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
209 |
3061
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
210 |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
211 public double [] interpolate( |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
212 String keyName, |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
213 double key, |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
214 String [] columnNames |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
215 ) { |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
216 int keyIndex = columnIndex(keyName); |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
217 return keyIndex < 0 |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
218 ? null |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
219 : interpolate(keyIndex, key, columnNames); |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
220 } |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
221 |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
222 public double [] interpolate( |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
223 int keyIndex, |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
224 double key, |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
225 String [] columnNames |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
226 ) { |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
227 int row = binarySearch(keyIndex, key, EPSILON); |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
228 |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
229 if (row >= 0) { // direct match |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
230 double [] values = new double[columnNames.length]; |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
231 for (int i = 0; i < values.length; ++i) { |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
232 int ci = columnIndex(columnNames[i]); |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
233 values[i] = ci < 0 |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
234 ? Double.NaN |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
235 : columns[ci].getQuick(row); |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
236 } |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
237 return values; |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
238 } |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
239 |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
240 row = -row - 1; |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
241 if (row < 1 || row >= size()) { // out of bounds |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
242 return null; |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
243 } |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
244 |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
245 double v1 = columns[keyIndex].getQuick(row-1); |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
246 double v2 = columns[keyIndex].getQuick(row); |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
247 double factor = Linear.factor(key, v1, v2); |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
248 |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
249 double [] values = new double[columnNames.length]; |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
250 |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
251 for (int i = 0; i < values.length; ++i) { |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
252 int ci = columnIndex(columnNames[i]); |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
253 values[i] = ci < 0 |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
254 ? Double.NaN |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
255 : Linear.weight( |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
256 factor, |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
257 columns[ci].getQuick(row-1), |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
258 columns[ci].getQuick(row)); |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
259 } |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
260 |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
261 return values; |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
262 } |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
263 |
3027
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
264 public boolean isSorted(String columnName) { |
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
265 return isSorted(columnIndex(columnName)); |
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
266 } |
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
267 |
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
268 public boolean isSorted(int columnIndex) { |
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
269 TDoubleArrayList column = columns[columnIndex]; |
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
270 for (int i = 1, N = column.size(); i < N; ++i) { |
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
271 if (column.getQuick(i-1) > column.getQuick(i)) { |
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
272 return false; |
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
273 } |
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
274 } |
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
275 return true; |
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
276 } |
2695
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
277 } |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
278 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |