view flys-artifacts/src/main/java/de/intevation/flys/artifacts/math/fitting/InvPow.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 de67497de5a0
children
line wrap: on
line source
package de.intevation.flys.artifacts.math.fitting;

public class InvPow
extends      Function
{
    public static final Derivative DERIVATIVE =
        new Derivative("Q'(W) = ((W-d)/a)^(1/c)/(c*(W-d))") {

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

            return new de.intevation.flys.artifacts.math.Function() {
                @Override
                public double value(double W) {
                    double Wd = W-d;
                    return Math.pow(Wd*_1a, _1c)/(c*Wd);
                }
            };
        }
    };

    public static final Function INSTANCE = new InvPow();

    public InvPow() {
        super(
            "pow",
            "Q(W) = ((W-d)/a)^(1/c)",
            new String [] { "a", "c", "d" });
    }

    @Override
    public double value(double W, double [] parameters) {
        double a = parameters[0];
        double c = parameters[1];
        double d = parameters[2];
        return Math.pow((W-d)/a, 1d/c);
    }

    @Override
    public double [] gradient(double W, double [] parameters) {
        double a = parameters[0];
        double c = parameters[1];
        double d = parameters[2];
        double _1c = 1d/c;
        double Wdac = Math.pow((W-d)/a, 1d/c);
        double Wd = W-d;
        return new double [] {
            -Wdac/(a*c),
            (Wdac*Math.log(Wd/a))/(c*c),
            -Wdac/(c*Wd)
        };
    }

    @Override
    public Derivative getDerivative() {
        // TODO: Implement me!
        return null;
    }

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

http://dive4elements.wald.intevation.org