Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/math/fitting/InvPow.java @ 3181:de67497de5a0
Completed inverse functions.
flys-artifacts/trunk@4796 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Tue, 26 Jun 2012 10:54:12 +0000 |
parents | 59b14bc676ec |
children |
comparison
equal
deleted
inserted
replaced
3180:4d5b15049ac2 | 3181:de67497de5a0 |
---|---|
1 package de.intevation.flys.artifacts.math.fitting; | 1 package de.intevation.flys.artifacts.math.fitting; |
2 | 2 |
3 public class InvPow | 3 public class InvPow |
4 extends Function | 4 extends Function |
5 { | 5 { |
6 public static final Derivative DERIVATIVE = | |
7 new Derivative("Q'(W) = ((W-d)/a)^(1/c)/(c*(W-d))") { | |
8 | |
9 @Override | |
10 public de.intevation.flys.artifacts.math.Function | |
11 instantiate(double [] parameters) | |
12 { | |
13 double a = parameters[0]; | |
14 final double c = parameters[1]; | |
15 final double d = parameters[2]; | |
16 final double _1a = 1d/a; | |
17 final double _1c = 1d/c; | |
18 | |
19 return new de.intevation.flys.artifacts.math.Function() { | |
20 @Override | |
21 public double value(double W) { | |
22 double Wd = W-d; | |
23 return Math.pow(Wd*_1a, _1c)/(c*Wd); | |
24 } | |
25 }; | |
26 } | |
27 }; | |
28 | |
6 public static final Function INSTANCE = new InvPow(); | 29 public static final Function INSTANCE = new InvPow(); |
7 | 30 |
8 public InvPow() { | 31 public InvPow() { |
9 // TODO: Implement me! | 32 super( |
33 "pow", | |
34 "Q(W) = ((W-d)/a)^(1/c)", | |
35 new String [] { "a", "c", "d" }); | |
10 } | 36 } |
11 | 37 |
12 @Override | 38 @Override |
13 public double value(double W, double [] parameters) { | 39 public double value(double W, double [] parameters) { |
14 // TODO: Implement me! | 40 double a = parameters[0]; |
15 return 0d; | 41 double c = parameters[1]; |
42 double d = parameters[2]; | |
43 return Math.pow((W-d)/a, 1d/c); | |
16 } | 44 } |
17 | 45 |
18 @Override | 46 @Override |
19 public double [] gradient(double Q, double [] parameters) { | 47 public double [] gradient(double W, double [] parameters) { |
20 // TODO: Implement me! | 48 double a = parameters[0]; |
21 return null; | 49 double c = parameters[1]; |
50 double d = parameters[2]; | |
51 double _1c = 1d/c; | |
52 double Wdac = Math.pow((W-d)/a, 1d/c); | |
53 double Wd = W-d; | |
54 return new double [] { | |
55 -Wdac/(a*c), | |
56 (Wdac*Math.log(Wd/a))/(c*c), | |
57 -Wdac/(c*Wd) | |
58 }; | |
22 } | 59 } |
23 | 60 |
24 @Override | 61 @Override |
25 public Derivative getDerivative() { | 62 public Derivative getDerivative() { |
26 // TODO: Implement me! | 63 // TODO: Implement me! |