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