13#ifndef DUMUX_NUMERIC_DIFFERENTIATION_HH 
   14#define DUMUX_NUMERIC_DIFFERENTIATION_HH 
   35    template<
class Scalar>
 
   36    static Scalar 
epsilon(
const Scalar value, 
const Scalar baseEps = 1e-10)
 
   38        assert(std::numeric_limits<Scalar>::epsilon()*1e4 < baseEps);
 
   42        return baseEps*(abs(value) + 1.0);
 
 
   49    template<
class Function, 
class Scalar, 
class FunctionEvalType>
 
   51                                  FunctionEvalType& derivative,
 
   52                                  const FunctionEvalType& fx0,
 
   53                                  const int numericDifferenceMethod = 1)
 
 
   66    template<
class Function, 
class Scalar, 
class FunctionEvalType>
 
   68                                  FunctionEvalType& derivative,
 
   69                                  const FunctionEvalType& fx0,
 
   71                                  const int numericDifferenceMethod = 1)
 
   76        if (numericDifferenceMethod == 5)
 
   78            derivative = function(x0 + eps);
 
   79            derivative -= function(x0 - eps);
 
   81            derivative += function(x0 - 2*eps);
 
   82            derivative -= function(x0 + 2*eps);
 
   91        if (numericDifferenceMethod >= 0)
 
   95            derivative = function(x0 + eps);
 
  101        else derivative = fx0;
 
  105        if (numericDifferenceMethod <= 0)
 
  109            derivative -= function(x0 - eps);
 
  115        else derivative -= fx0;
 
 
 
A class for numeric differentiation with respect to a scalar parameter.
Definition numericdifferentiation.hh:27
static Scalar epsilon(const Scalar value, const Scalar baseEps=1e-10)
Computes the epsilon used for numeric differentiation.
Definition numericdifferentiation.hh:36
static void partialDerivative(const Function &function, Scalar x0, FunctionEvalType &derivative, const FunctionEvalType &fx0, const int numericDifferenceMethod=1)
Computes the derivative of a function with respect to a function parameter.
Definition numericdifferentiation.hh:50
static void partialDerivative(const Function &function, Scalar x0, FunctionEvalType &derivative, const FunctionEvalType &fx0, const Scalar eps, const int numericDifferenceMethod=1)
Computes the derivative of a function with respect to a function parameter.
Definition numericdifferentiation.hh:67