Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/math/fitting/AbstractLogLinear.java @ 9643:58f3fe98fd6b
Fitting new Option UI
author | dnt_bjoernsen <d.tironi@bjoernsen.de> |
---|---|
date | Mon, 02 Dec 2019 14:14:06 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
9642:3987fef69143 | 9643:58f3fe98fd6b |
---|---|
1 /** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde | |
2 * Software engineering by | |
3 * Björnsen Beratende Ingenieure GmbH | |
4 * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt | |
5 * | |
6 * This file is Free Software under the GNU AGPL (>=v3) | |
7 * and comes with ABSOLUTELY NO WARRANTY! Check out the | |
8 * documentation coming with Dive4Elements River for details. | |
9 */ | |
10 package org.dive4elements.river.artifacts.math.fitting; | |
11 | |
12 /** | |
13 * @author Domenico Nardi Tironi | |
14 * | |
15 */ | |
16 /* | |
17 * Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde | |
18 * Software engineering by Intevation GmbH | |
19 * This file is Free Software under the GNU AGPL (>=v3) | |
20 * and comes with ABSOLUTELY NO WARRANTY! Check out the | |
21 * documentation coming with Dive4Elements River for details. | |
22 */ | |
23 | |
24 public abstract class AbstractLogLinear extends Function { | |
25 public static final Derivative DERIVATIVE = new Derivative("W'(Q) = a*m/(m*Q + b)") { | |
26 | |
27 @Override | |
28 public org.dive4elements.river.artifacts.math.Function instantiate(final double[] parameters) { | |
29 final double a = parameters[0]; | |
30 final double m = parameters[1]; | |
31 final double b = parameters[2]; | |
32 | |
33 return new org.dive4elements.river.artifacts.math.Function() { | |
34 @Override | |
35 public double value(final double Q) { | |
36 return a * m / (m * Q + b); | |
37 } | |
38 }; | |
39 } | |
40 }; | |
41 | |
42 public AbstractLogLinear(final String name, final String description) { | |
43 super(name, description, new String[] { "a", "m", "b" }); | |
44 } | |
45 | |
46 @Override | |
47 public final double value(final double x, final double[] parameters) { | |
48 return parameters[0] * Math.log(parameters[1] * x + parameters[2]); | |
49 } | |
50 | |
51 @Override | |
52 public double[] gradient(final double x, final double[] parameters) { | |
53 final double a = parameters[0]; | |
54 final double m = parameters[1]; | |
55 final double b = parameters[2]; | |
56 | |
57 final double lin = m * x + b; | |
58 | |
59 return new double[] { Math.log(lin), a * x / lin, a / lin }; | |
60 } | |
61 | |
62 @Override | |
63 public final Derivative getDerivative() { | |
64 return DERIVATIVE; | |
65 } | |
66 | |
67 @Override | |
68 public Function getInverse() { | |
69 return InvLogLinear.INSTANCE; | |
70 } | |
71 } | |
72 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |