The invrse of an existing function. More...
#include <InverseFunction.h>
Public Member Functions | |
InverseFunction (const OneArgumentDiffFunction &to_invert, double search_min, double search_max, double tolerance=1e-10) | |
Invert the given function. More... | |
double | operator() (double x) const |
The value of the function at the given abscissa. More... | |
double | range_high () const |
The lower end of the range over which the function is defined is uknown. More... | |
double | range_low () const |
The upper end of the range over which the function is defined. More... | |
Core::InterpSolutionIterator | crossings (double=0) const |
An iterator over the abscissas where the function takes the given y value. More... | |
const Core::FunctionDerivatives * | deriv (double x) const |
Returns a pointer to the derivative of the function. More... | |
Public Member Functions inherited from Core::OneArgumentFunction< double, double > | |
virtual | ~OneArgumentFunction () |
Provide a virtual destructor for a virtual class. More... | |
Private Attributes | |
const Core::OneArgumentDiffFunction & | __to_invert |
The function being inverted. More... | |
double | __tolerance |
The relative tolerance in the value returned by the function at the best guess for the solution. More... | |
gsl_root_fsolver * | __solver |
The GSL derivative-based solver. More... | |
gsl_function_fdf | __solver_fdf |
The fdf argument used by the GSL solver. More... | |
gsl_function | __solver_f |
The f argument used by the GSL solver. More... | |
double | __target |
The value we are trying to match the function to. More... | |
double | __search_min |
The range which to search for a solution (must bracket a zero). More... | |
double | __search_max |
Friends | |
double | gsl_f (double x, void *params) |
GLS format function to invert. More... | |
double | gsl_df (double x, void *params) |
GLS format derivative of function to invert. More... | |
void | gsl_fdf (double x, void *params, double *f, double *df) |
GLS format function and its derivative to invert. More... | |
The invrse of an existing function.
Uses the last returned result as a guess for the next solution, so this class workes best when invoked with consecutive arguments close to each other, like for example evaluating it at the set of ages of a POET solution in ascending/descending order.
In other cases, use set_guess before each query.
Definition at line 26 of file InverseFunction.h.
InverseFunction::InverseFunction | ( | const OneArgumentDiffFunction & | to_invert, |
double | search_min, | ||
double | search_max, | ||
double | tolerance = 1e-10 |
||
) |
Invert the given function.
Definition at line 41 of file InverseFunction.cpp.
|
inlinevirtual |
An iterator over the abscissas where the function takes the given y value.
Implements Core::OneArgumentFunction< double, double >.
Definition at line 87 of file InverseFunction.h.
|
virtual |
Returns a pointer to the derivative of the function.
The use of a pointer allows avoiding potentially expensive copy opertaions.
Implements Core::OneArgumentDiffFunction.
Definition at line 99 of file InverseFunction.cpp.
|
virtual |
The value of the function at the given abscissa.
Implements Core::OneArgumentFunction< double, double >.
Definition at line 66 of file InverseFunction.cpp.
|
inlinevirtual |
The lower end of the range over which the function is defined is uknown.
Implements Core::OneArgumentFunction< double, double >.
Definition at line 70 of file InverseFunction.h.
|
inlinevirtual |
The upper end of the range over which the function is defined.
Implements Core::OneArgumentFunction< double, double >.
Definition at line 78 of file InverseFunction.h.
|
friend |
GLS format derivative of function to invert.
Definition at line 19 of file InverseFunction.cpp.
|
friend |
GLS format function to invert.
Definition at line 10 of file InverseFunction.cpp.
|
friend |
GLS format function and its derivative to invert.
Definition at line 30 of file InverseFunction.cpp.
|
private |
The range which to search for a solution (must bracket a zero).
Definition at line 48 of file InverseFunction.h.
|
private |
The GSL derivative-based solver.
Definition at line 36 of file InverseFunction.h.
|
private |
The f argument used by the GSL solver.
Definition at line 42 of file InverseFunction.h.
|
private |
The fdf argument used by the GSL solver.
Definition at line 39 of file InverseFunction.h.
|
mutableprivate |
The value we are trying to match the function to.
Definition at line 45 of file InverseFunction.h.
|
private |
The function being inverted.
Definition at line 29 of file InverseFunction.h.
|
private |
The relative tolerance in the value returned by the function at the best guess for the solution.
Definition at line 33 of file InverseFunction.h.