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