view flys-artifacts/src/main/java/de/intevation/flys/artifacts/math/fitting/InvLog.java @ 4655:cd44d28d0fbc

Move the access to artifact data to the Access object Use BedHeightAccess class to receive the data from the artifact. This abstracts the data access from the actual artifact.
author Björn Ricks <bjoern.ricks@intevation.de>
date Tue, 11 Dec 2012 09:44:04 +0100
parents 9422b559b2d5
children
line wrap: on
line source
package de.intevation.flys.artifacts.math.fitting;

public class InvLog
extends      Function
{
    public static final Derivative DERIVATIVE =
        new Derivative("Q'(W) = exp(W/m)/m") {

        @Override
        public de.intevation.flys.artifacts.math.Function
            instantiate(double [] parameters)
        {
            final double _1m = 1d / parameters[0];

            return new de.intevation.flys.artifacts.math.Function() {
                @Override
                public double value(double W) {
                    return Math.exp(W*_1m)*_1m;
                }
            };
        }
    };

    public static final Function INSTANCE = new InvLog();

    public InvLog() {
        super("inv-log",  "Q(W) = e^(W/m) - b", new String [] { "m", "b" });
    }

    @Override
    public double value(double w, double [] parameters) {
        double m = parameters[0];
        double b = parameters[1];
        return Math.exp(w/m) - b;
    }

    @Override
    public double [] gradient(double w, double [] parameters) {
        double m   = parameters[0];
        double b   = parameters[1];
        double ewm = Math.exp(w/m);
        return new double [] { -w*ewm/(m*m), -1 };
    }

    @Override
    public Derivative getDerivative() {
        return DERIVATIVE;
    }

    @Override
    public Function getInverse() {
        return Log.INSTANCE;
    }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org