Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/math/fitting/InvLogLinear.java @ 5565:a44a3f997ec8
Cleanup whitespace. Removed unused variable.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Fri, 05 Apr 2013 09:03:34 +0200 |
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 InvLogLinear |
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) = e^(W/a)/(a*m)") { |
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 final double _1a = 1d/parameters[0]; |
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
14 final double _1am = 1d/(parameters[0] * parameters[1]); |
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
15 |
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
16 return new de.intevation.flys.artifacts.math.Function() { |
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
17 @Override |
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
18 public double value(double W) { |
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
19 return Math.exp(W*_1a)*_1am; |
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
20 } |
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
21 }; |
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
22 } |
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
23 }; |
3177
585c0b49e696
Added inverses of the fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
24 public static final Function INSTANCE = new InvLogLinear(); |
585c0b49e696
Added inverses of the fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
25 |
585c0b49e696
Added inverses of the fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
26 public InvLogLinear() { |
3181
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
27 super( |
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
28 "inv-log-linear", |
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
29 "Q(W)=(e^(W/a)-b)/m", |
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
30 new String [] { "a", "m", "b" }); |
3177
585c0b49e696
Added inverses of the fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
31 } |
585c0b49e696
Added inverses of the fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
32 |
585c0b49e696
Added inverses of the fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
33 @Override |
585c0b49e696
Added inverses of the fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
34 public double value(double W, double [] parameters) { |
3181
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
35 double a = parameters[0]; |
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
36 double m = parameters[1]; |
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
37 double b = parameters[2]; |
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
38 return (Math.exp(W/a) - b)/m; |
3177
585c0b49e696
Added inverses of the fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
39 } |
585c0b49e696
Added inverses of the fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
40 |
585c0b49e696
Added inverses of the fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
41 @Override |
3181
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
42 public double [] gradient(double W, double [] parameters) { |
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
43 double a = parameters[0]; |
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
44 double m = parameters[1]; |
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
45 double b = parameters[2]; |
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
46 double eWa = Math.exp(W/a); |
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
47 return new double [] { |
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
48 -(W*eWa)/(a*a*m) |
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
49 -(eWa-b)/(m*m), |
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
50 -1/m |
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
51 }; |
3177
585c0b49e696
Added inverses of the fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
52 } |
585c0b49e696
Added inverses of the fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
53 |
585c0b49e696
Added inverses of the fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
54 @Override |
585c0b49e696
Added inverses of the fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
55 public Derivative getDerivative() { |
3181
de67497de5a0
Completed inverse functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3178
diff
changeset
|
56 return DERIVATIVE; |
3177
585c0b49e696
Added inverses of the fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
57 } |
585c0b49e696
Added inverses of the fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
58 |
585c0b49e696
Added inverses of the fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
59 @Override |
585c0b49e696
Added inverses of the fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
60 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
|
61 return LogLinear.INSTANCE; |
3177
585c0b49e696
Added inverses of the fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
62 } |
585c0b49e696
Added inverses of the fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
63 } |
585c0b49e696
Added inverses of the fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
64 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |