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