Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/math/fitting/InvLog.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/InvLog.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 InvLog | |
4 extends Function | |
5 { | |
6 public static final Derivative DERIVATIVE = | |
7 new Derivative("Q'(W) = exp(W/m)/m") { | |
8 | |
9 @Override | |
10 public org.dive4elements.river.artifacts.math.Function | |
11 instantiate(double [] parameters) | |
12 { | |
13 final double _1m = 1d / parameters[0]; | |
14 | |
15 return new org.dive4elements.river.artifacts.math.Function() { | |
16 @Override | |
17 public double value(double W) { | |
18 return Math.exp(W*_1m)*_1m; | |
19 } | |
20 }; | |
21 } | |
22 }; | |
23 | |
24 public static final Function INSTANCE = new InvLog(); | |
25 | |
26 public InvLog() { | |
27 super("inv-log", "Q(W) = e^(W/m) - b", new String [] { "m", "b" }); | |
28 } | |
29 | |
30 @Override | |
31 public double value(double w, double [] parameters) { | |
32 double m = parameters[0]; | |
33 double b = parameters[1]; | |
34 return Math.exp(w/m) - b; | |
35 } | |
36 | |
37 @Override | |
38 public double [] gradient(double w, double [] parameters) { | |
39 double m = parameters[0]; | |
40 double b = parameters[1]; | |
41 double ewm = Math.exp(w/m); | |
42 return new double [] { -w*ewm/(m*m), -1 }; | |
43 } | |
44 | |
45 @Override | |
46 public Derivative getDerivative() { | |
47 return DERIVATIVE; | |
48 } | |
49 | |
50 @Override | |
51 public Function getInverse() { | |
52 return Log.INSTANCE; | |
53 } | |
54 } | |
55 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |