Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/org/dive4elements/river/artifacts/math/fitting/InvSQPow.java @ 5831:bd047b71ab37
Repaired internal references
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 25 Apr 2013 12:06:39 +0200 |
parents | flys-artifacts/src/main/java/de/intevation/flys/artifacts/math/fitting/InvSQPow.java@de67497de5a0 |
children |
comparison
equal
deleted
inserted
replaced
5830:160f53ee0870 | 5831:bd047b71ab37 |
---|---|
1 package org.dive4elements.river.artifacts.math.fitting; | |
2 | |
3 public class InvSQPow | |
4 extends Function | |
5 { | |
6 public static final Derivative DERIVATIVE = | |
7 new Derivative("Q'(S) = (S/a)^(1/b)/(b*S)") { | |
8 | |
9 @Override | |
10 public org.dive4elements.river.artifacts.math.Function | |
11 instantiate(double [] parameters) | |
12 { | |
13 final double _1a = 1d/parameters[0]; | |
14 final double b = parameters[1]; | |
15 final double _1b = 1d/b; | |
16 | |
17 return new org.dive4elements.river.artifacts.math.Function() { | |
18 @Override | |
19 public double value(double S) { | |
20 return Math.pow(S*_1a, _1b)/(b*S); | |
21 } | |
22 }; | |
23 } | |
24 }; | |
25 public static final Function INSTANCE = new InvSQPow(); | |
26 | |
27 public InvSQPow() { | |
28 super( | |
29 "inv-sq-pow", | |
30 "Q(S) = Q=(S/a)^(1/b)", | |
31 new String [] { "a", "b" }); | |
32 } | |
33 | |
34 @Override | |
35 public double value(double S, double [] parameters) { | |
36 double a = parameters[0]; | |
37 double b = parameters[1]; | |
38 return Math.pow(S/a, 1d/b); | |
39 } | |
40 | |
41 @Override | |
42 public double [] gradient(double S, double [] parameters) { | |
43 double a = parameters[0]; | |
44 double b = parameters[1]; | |
45 double Sa = S/a; | |
46 double _1b = 1d/b; | |
47 double eSa1b = Math.pow(Sa, _1b); | |
48 return new double [] { | |
49 -eSa1b/(a*b), | |
50 -(eSa1b*Math.log(Sa))/(b*b) | |
51 }; | |
52 } | |
53 | |
54 @Override | |
55 public Derivative getDerivative() { | |
56 return DERIVATIVE; | |
57 } | |
58 | |
59 @Override | |
60 public Function getInverse() { | |
61 return SQPow.INSTANCE; | |
62 } | |
63 } | |
64 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |