Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/math/fitting/InvPow.java @ 4789:0df2247d98e1
Create and add sieves regardless of the the order of diameter/value.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Wed, 09 Jan 2013 09:28:01 +0100 |
parents | de67497de5a0 |
children |
rev | line source |
---|---|
3177
585c0b49e696
Added inverses of the fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.math.fitting; |
585c0b49e696
Added inverses of the fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
2 |
585c0b49e696
Added inverses of the fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
3 public class InvPow |
585c0b49e696
Added inverses of the fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
4 extends Function |
585c0b49e696
Added inverses of the fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
5 { |
3181
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
6 public static final Derivative DERIVATIVE = |
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
7 new Derivative("Q'(W) = ((W-d)/a)^(1/c)/(c*(W-d))") { |
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
8 |
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
9 @Override |
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
10 public de.intevation.flys.artifacts.math.Function |
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
11 instantiate(double [] parameters) |
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
12 { |
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
13 double a = parameters[0]; |
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
14 final double c = parameters[1]; |
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
15 final double d = parameters[2]; |
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
16 final double _1a = 1d/a; |
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
17 final double _1c = 1d/c; |
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
18 |
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
19 return new de.intevation.flys.artifacts.math.Function() { |
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
20 @Override |
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
21 public double value(double W) { |
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
22 double Wd = W-d; |
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
23 return Math.pow(Wd*_1a, _1c)/(c*Wd); |
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
24 } |
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
25 }; |
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
26 } |
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
27 }; |
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
28 |
3177
585c0b49e696
Added inverses of the fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
29 public static final Function INSTANCE = new InvPow(); |
585c0b49e696
Added inverses of the fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
30 |
585c0b49e696
Added inverses of the fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
31 public InvPow() { |
3181
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
32 super( |
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
33 "pow", |
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
34 "Q(W) = ((W-d)/a)^(1/c)", |
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
35 new String [] { "a", "c", "d" }); |
3177
585c0b49e696
Added inverses of the fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
36 } |
585c0b49e696
Added inverses of the fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
37 |
585c0b49e696
Added inverses of the fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
38 @Override |
585c0b49e696
Added inverses of the fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
39 public double value(double W, double [] parameters) { |
3181
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
40 double a = parameters[0]; |
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
41 double c = parameters[1]; |
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
42 double d = parameters[2]; |
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
43 return Math.pow((W-d)/a, 1d/c); |
3177
585c0b49e696
Added inverses of the fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
44 } |
585c0b49e696
Added inverses of the fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
45 |
585c0b49e696
Added inverses of the fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
46 @Override |
3181
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
47 public double [] gradient(double W, double [] parameters) { |
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
48 double a = parameters[0]; |
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
49 double c = parameters[1]; |
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
50 double d = parameters[2]; |
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
51 double _1c = 1d/c; |
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
52 double Wdac = Math.pow((W-d)/a, 1d/c); |
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
53 double Wd = W-d; |
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
54 return new double [] { |
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
55 -Wdac/(a*c), |
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
56 (Wdac*Math.log(Wd/a))/(c*c), |
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
57 -Wdac/(c*Wd) |
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
58 }; |
3177
585c0b49e696
Added inverses of the fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
59 } |
585c0b49e696
Added inverses of the fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
60 |
585c0b49e696
Added inverses of the fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
61 @Override |
585c0b49e696
Added inverses of the fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
62 public Derivative getDerivative() { |
585c0b49e696
Added inverses of the fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
63 // TODO: Implement me! |
585c0b49e696
Added inverses of the fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
64 return null; |
585c0b49e696
Added inverses of the fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
65 } |
585c0b49e696
Added inverses of the fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
66 |
585c0b49e696
Added inverses of the fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
67 @Override |
585c0b49e696
Added inverses of the fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
68 public Function getInverse() { |
3178
59b14bc676ec
Fitting: Link the functions to there inverses via getInverse().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3177
diff
changeset
|
69 return Pow.INSTANCE; |
3177
585c0b49e696
Added inverses of the fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
70 } |
585c0b49e696
Added inverses of the fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
71 } |
585c0b49e696
Added inverses of the fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
72 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |