Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/org/dive4elements/river/artifacts/math/fitting/Function.java @ 5831:bd047b71ab37
Repaired internal references
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 25 Apr 2013 12:06:39 +0200 |
parents | flys-artifacts/src/main/java/de/intevation/flys/artifacts/math/fitting/Function.java@585c0b49e696 |
children |
comparison
equal
deleted
inserted
replaced
5830:160f53ee0870 | 5831:bd047b71ab37 |
---|---|
1 package org.dive4elements.river.artifacts.math.fitting; | |
2 | |
3 import org.apache.commons.math.FunctionEvaluationException; | |
4 | |
5 import org.apache.commons.math.optimization.fitting.ParametricRealFunction; | |
6 | |
7 import org.dive4elements.river.utils.DoubleUtil; | |
8 | |
9 public abstract class Function | |
10 implements ParametricRealFunction | |
11 { | |
12 protected String name; | |
13 protected String description; | |
14 protected String [] parameterNames; | |
15 protected double [] initialGuess; | |
16 | |
17 public static abstract class Derivative { | |
18 | |
19 protected String description; | |
20 | |
21 public Derivative() { | |
22 } | |
23 | |
24 public Derivative(String description) { | |
25 this.description = description; | |
26 } | |
27 | |
28 public String getDescription() { | |
29 return description; | |
30 } | |
31 | |
32 public abstract org.dive4elements.river.artifacts.math.Function | |
33 instantiate(double [] parameters); | |
34 | |
35 } // interface Derivative | |
36 | |
37 public Function() { | |
38 } | |
39 | |
40 public Function( | |
41 String name, | |
42 String description, | |
43 String [] parameterNames | |
44 ) { | |
45 this(name, | |
46 description, | |
47 parameterNames, | |
48 DoubleUtil.fill(parameterNames.length, 1d)); | |
49 } | |
50 | |
51 public Function( | |
52 String name, | |
53 String description, | |
54 String [] parameterNames, | |
55 double [] initialGuess | |
56 ) { | |
57 this.name = name; | |
58 this.description = description; | |
59 this.parameterNames = parameterNames; | |
60 this.initialGuess = initialGuess; | |
61 } | |
62 | |
63 public String getName() { | |
64 return name; | |
65 } | |
66 | |
67 public String getDescription() { | |
68 return description; | |
69 } | |
70 | |
71 public String [] getParameterNames() { | |
72 return parameterNames; | |
73 } | |
74 | |
75 public double [] getInitialGuess() { | |
76 return initialGuess; | |
77 } | |
78 | |
79 public org.dive4elements.river.artifacts.math.Function instantiate( | |
80 final double [] parameters | |
81 ) { | |
82 return new org.dive4elements.river.artifacts.math.Function() { | |
83 | |
84 @Override | |
85 public double value(double x) { | |
86 try { | |
87 return Function.this.value(x, parameters); | |
88 } | |
89 catch (FunctionEvaluationException fee) { | |
90 return Double.NaN; | |
91 } | |
92 } | |
93 }; | |
94 } | |
95 | |
96 public abstract Derivative getDerivative(); | |
97 | |
98 public abstract Function getInverse(); | |
99 } | |
100 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |