Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/math/fitting/InvSQPow.java @ 9643:58f3fe98fd6b
Fitting new Option UI
author | dnt_bjoernsen <d.tironi@bjoernsen.de> |
---|---|
date | Mon, 02 Dec 2019 14:14:06 +0100 |
parents | af13ceeba52a |
children |
comparison
equal
deleted
inserted
replaced
9642:3987fef69143 | 9643:58f3fe98fd6b |
---|---|
6 * documentation coming with Dive4Elements River for details. | 6 * documentation coming with Dive4Elements River for details. |
7 */ | 7 */ |
8 | 8 |
9 package org.dive4elements.river.artifacts.math.fitting; | 9 package org.dive4elements.river.artifacts.math.fitting; |
10 | 10 |
11 public class InvSQPow | 11 public class InvSQPow extends Function { |
12 extends Function | 12 public static final Derivative DERIVATIVE = new Derivative("Q'(S) = (S/a)^(1/b)/(b*S)") { |
13 { | |
14 public static final Derivative DERIVATIVE = | |
15 new Derivative("Q'(S) = (S/a)^(1/b)/(b*S)") { | |
16 | 13 |
17 @Override | 14 @Override |
18 public org.dive4elements.river.artifacts.math.Function | 15 public org.dive4elements.river.artifacts.math.Function instantiate(final double[] parameters) { |
19 instantiate(double [] parameters) | 16 final double _1a = 1d / parameters[0]; |
20 { | 17 final double b = parameters[1]; |
21 final double _1a = 1d/parameters[0]; | 18 final double _1b = 1d / b; |
22 final double b = parameters[1]; | |
23 final double _1b = 1d/b; | |
24 | 19 |
25 return new org.dive4elements.river.artifacts.math.Function() { | 20 return new org.dive4elements.river.artifacts.math.Function() { |
26 @Override | 21 @Override |
27 public double value(double S) { | 22 public double value(final double S) { |
28 return Math.pow(S*_1a, _1b)/(b*S); | 23 return Math.pow(S * _1a, _1b) / (b * S); |
29 } | 24 } |
30 }; | 25 }; |
31 } | 26 } |
32 }; | 27 }; |
33 public static final Function INSTANCE = new InvSQPow(); | 28 public static final Function INSTANCE = new InvSQPow(); |
34 | 29 |
35 public InvSQPow() { | 30 public InvSQPow() { |
36 super( | 31 super("inv-special", "Q(S) = Q=(S/a)^(1/b)", new String[] { "a", "b" }); |
37 "inv-sq-pow", | |
38 "Q(S) = Q=(S/a)^(1/b)", | |
39 new String [] { "a", "b" }); | |
40 } | 32 } |
41 | 33 |
42 @Override | 34 @Override |
43 public double value(double S, double [] parameters) { | 35 public double value(final double S, final double[] parameters) { |
44 double a = parameters[0]; | 36 final double a = parameters[0]; |
45 double b = parameters[1]; | 37 final double b = parameters[1]; |
46 return Math.pow(S/a, 1d/b); | 38 return Math.pow(S / a, 1d / b); |
47 } | 39 } |
48 | 40 |
49 @Override | 41 @Override |
50 public double [] gradient(double S, double [] parameters) { | 42 public double[] gradient(final double S, final double[] parameters) { |
51 double a = parameters[0]; | 43 final double a = parameters[0]; |
52 double b = parameters[1]; | 44 final double b = parameters[1]; |
53 double Sa = S/a; | 45 final double Sa = S / a; |
54 double _1b = 1d/b; | 46 final double _1b = 1d / b; |
55 double eSa1b = Math.pow(Sa, _1b); | 47 final double eSa1b = Math.pow(Sa, _1b); |
56 return new double [] { | 48 return new double[] { -eSa1b / (a * b), -(eSa1b * Math.log(Sa)) / (b * b) }; |
57 -eSa1b/(a*b), | |
58 -(eSa1b*Math.log(Sa))/(b*b) | |
59 }; | |
60 } | 49 } |
61 | 50 |
62 @Override | 51 @Override |
63 public Derivative getDerivative() { | 52 public Derivative getDerivative() { |
64 return DERIVATIVE; | 53 return DERIVATIVE; |