Program Listing for File InverseFunction.h¶
↰ Return to documentation for file (/home/kpenev/projects/git/poet/poet_src/unit_tests/testEvolve/InverseFunction.h)
#ifndef __INVERSE_FUNCTION_H
#define __INVERSE_FUNCTION_H
#include "../../Core/Functions.h"
#include "../../Core/InterpSolutionIterator.h"
#include <gsl/gsl_roots.h>
class InverseFunction : public Core::OneArgumentDiffFunction {
private:
const Core::OneArgumentDiffFunction &__to_invert;
double __tolerance;
gsl_root_fsolver *__solver;
gsl_function_fdf __solver_fdf;
gsl_function __solver_f;
mutable double __target;
double __search_min, __search_max;
friend double gsl_f(double x, void *params);
friend double gsl_df(double x, void *params);
friend void gsl_fdf(double x, void *params, double *f, double *df);
public:
InverseFunction(const OneArgumentDiffFunction &to_invert,
double search_min,
double search_max,
double tolerance = 1e-10);
double operator()(double x) const;
double range_high() const
{
throw Core::Error::Runtime(
"Upper end of inverse function range is unknown."
);
}
double range_low() const
{
throw Core::Error::Runtime(
"Lower end of inverse function range is unknown."
);
}
Core::InterpSolutionIterator crossings(double = 0) const
{
throw Core::Error::Runtime(
"Finding all solutinos of an inverse function not implemented."
);
};
const Core::FunctionDerivatives *deriv(double x) const;
~InverseFunction();
};
#endif