Abstract base for minimising functions. More...
#include <vnl_least_squares_function.h>
Public Types | |
| enum | UseGradient { no_gradient, use_gradient } |
Public Member Functions | |
| vnl_least_squares_function (unsigned int number_of_unknowns, unsigned int number_of_residuals, UseGradient g=use_gradient) | |
| Construct vnl_least_squares_function. More... | |
| virtual | ~vnl_least_squares_function ()=default |
| void | throw_failure () |
| void | clear_failure () |
| virtual void | f (vnl_vector< double > const &x, vnl_vector< double > &fx)=0 |
| The main function. More... | |
| virtual void | gradf (vnl_vector< double > const &x, vnl_matrix< double > &jacobian) |
| Calculate the Jacobian, given the parameter vector x. More... | |
| void | fdgradf (vnl_vector< double > const &x, vnl_matrix< double > &jacobian, double stepsize) |
| Use this to compute a finite-difference gradient other than lmdif. More... | |
| void | ffdgradf (vnl_vector< double > const &x, vnl_matrix< double > &jacobian, double stepsize) |
| Use this to compute a finite-forward-difference gradient other than lmdif. More... | |
| virtual void | trace (int iteration, vnl_vector< double > const &x, vnl_vector< double > const &fx) |
| Called after each LM iteration to print debugging etc. More... | |
| double | rms (vnl_vector< double > const &x) |
| Compute the rms error at x by calling f and returning the norm of the residual vector. More... | |
| unsigned int | get_number_of_unknowns () const |
| Return the number of unknowns. More... | |
| unsigned int | get_number_of_residuals () const |
| Return the number of residuals. More... | |
| bool | has_gradient () const |
| Return true if the derived class has indicated that gradf has been implemented. More... | |
Public Attributes | |
| bool | failure |
Protected Member Functions | |
| void | init (unsigned int number_of_unknowns, unsigned int number_of_residuals) |
Protected Attributes | |
| unsigned int | p_ |
| unsigned int | n_ |
| bool | use_gradient_ |
Private Member Functions | |
| void | dim_warning (unsigned int n_unknowns, unsigned int n_residuals) |
Related Functions | |
(Note that these are not member functions.) | |
| bool VNL_ALGO_EXPORT | vnl_discrete_diff_fwd (vnl_least_squares_function *lsf, double h, vnl_vector< double > const &x, vnl_matrix< double > &J) |
| forward differences. More... | |
| bool VNL_ALGO_EXPORT | vnl_discrete_diff_fwd (vnl_least_squares_function *lsf, vnl_vector< double > const &h, vnl_vector< double > const &x, vnl_matrix< double > &J) |
| forward differences. More... | |
| bool VNL_ALGO_EXPORT | vnl_discrete_diff_fwd (vnl_least_squares_function *lsf, vnl_vector< double > const &h, vnl_vector< double > const &x, vnl_vector< double > const &y, vnl_matrix< double > &J) |
| forward differences. More... | |
| bool VNL_ALGO_EXPORT | vnl_discrete_diff_sym (vnl_least_squares_function *lsf, double h, vnl_vector< double > const &x, vnl_matrix< double > &J) |
| symmetric differences. More... | |
| bool VNL_ALGO_EXPORT | vnl_discrete_diff_sym (vnl_least_squares_function *lsf, vnl_vector< double > const &h, vnl_vector< double > const &x, vnl_matrix< double > &J) |
| symmetric differences. More... | |
Abstract base for minimising functions.
vnl_least_squares_function is an abstract base for functions to be minimized by an optimizer. To define your own function to be minimized, subclass from vnl_least_squares_function, and implement the pure virtual f (and optionally grad_f).
Whether or not f ought to be const is a problem. Clients might well want to cache some information during the call, and if they're compute objects, will almost certainly be writing to members during the computation. For the moment it's non-const, but we'll see...
Definition at line 35 of file vnl_least_squares_function.h.
| Enumerator | |
|---|---|
| no_gradient | |
| use_gradient | |
Definition at line 38 of file vnl_least_squares_function.h.
|
inline |
Construct vnl_least_squares_function.
Passing number of parameters (unknowns, domain dimension) and number of residuals (range dimension). The optional argument should be no_gradient if the gradf function has not been implemented. Default is use_gradient.
Definition at line 49 of file vnl_least_squares_function.h.
|
virtualdefault |
|
inline |
Definition at line 60 of file vnl_least_squares_function.h.
|
private |
Definition at line 11 of file vnl_least_squares_function.cxx.
|
pure virtual |
The main function.
Given the parameter vector x, compute the vector of residuals fx. Fx has been sized appropriately before the call.
| void vnl_least_squares_function::fdgradf | ( | vnl_vector< double > const & | x, |
| vnl_matrix< double > & | jacobian, | ||
| double | stepsize | ||
| ) |
Use this to compute a finite-difference gradient other than lmdif.
Compute finite differences gradient using central differences.
Definition at line 27 of file vnl_least_squares_function.cxx.
| void vnl_least_squares_function::ffdgradf | ( | vnl_vector< double > const & | x, |
| vnl_matrix< double > & | jacobian, | ||
| double | stepsize | ||
| ) |
Use this to compute a finite-forward-difference gradient other than lmdif.
Compute finite differences gradient using forward differences.
This takes about half as many estimates as fdgradf
Definition at line 61 of file vnl_least_squares_function.cxx.
|
inline |
Return the number of residuals.
Definition at line 91 of file vnl_least_squares_function.h.
|
inline |
Return the number of unknowns.
Definition at line 88 of file vnl_least_squares_function.h.
|
virtual |
Calculate the Jacobian, given the parameter vector x.
Definition at line 20 of file vnl_least_squares_function.cxx.
|
inline |
Return true if the derived class has indicated that gradf has been implemented.
Definition at line 94 of file vnl_least_squares_function.h.
|
inlineprotected |
Definition at line 101 of file vnl_least_squares_function.h.
| double vnl_least_squares_function::rms | ( | vnl_vector< double > const & | x | ) |
Compute the rms error at x by calling f and returning the norm of the residual vector.
Definition at line 97 of file vnl_least_squares_function.cxx.
|
inline |
Definition at line 59 of file vnl_least_squares_function.h.
|
virtual |
Called after each LM iteration to print debugging etc.
Definition at line 90 of file vnl_least_squares_function.cxx.
|
related |
forward differences.
Definition at line 10 of file vnl_discrete_diff.cxx.
|
related |
forward differences.
Definition at line 24 of file vnl_discrete_diff.cxx.
|
related |
forward differences.
Definition at line 36 of file vnl_discrete_diff.cxx.
|
related |
symmetric differences.
Definition at line 64 of file vnl_discrete_diff.cxx.
|
related |
symmetric differences.
Definition at line 74 of file vnl_discrete_diff.cxx.
| bool vnl_least_squares_function::failure |
Definition at line 42 of file vnl_least_squares_function.h.
|
protected |
Definition at line 98 of file vnl_least_squares_function.h.
|
protected |
Definition at line 97 of file vnl_least_squares_function.h.
|
protected |
Definition at line 99 of file vnl_least_squares_function.h.
1.8.15