Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

vnl_cost_function.h

Go to the documentation of this file.
00001 #ifndef vnl_cost_function_h_
00002 #define vnl_cost_function_h_
00003 // This is vxl/vnl/vnl_cost_function.h
00004 
00005 //: \file
00006 //  \brief Vector->Real function
00007 //  \author Andrew W. Fitzgibbon, Oxford RRG, 23 Oct 97
00008 
00009 
00010 //    Modifications
00011 //     971023 AWF Initial version.
00012 //     LSB (Manchester) 26/3/01 Tidied documnetation
00013 //
00014 //-----------------------------------------------------------------------------
00015 
00016 #include <vnl/vnl_matops.h>
00017 #include <vnl/vnl_unary_function.h>
00018 
00019 //:   An object that represents a function from R^n -> R.
00020 //    It is commonly used to express the
00021 //    interface of a minimizer. 
00022 class vnl_cost_function : public vnl_unary_function<double, vnl_vector<double> > {
00023 public:
00024   vnl_cost_function(int number_of_unknowns):dim(number_of_unknowns) {}
00025 
00026   virtual ~vnl_cost_function() {}
00027 
00028 //:  The main function.  Given the parameter vector x, compute the
00029 // value of f(x).
00030   virtual double f(const vnl_vector<double>& x);
00031 
00032 //:  Calculate the Jacobian, given the parameter vector x.
00033   virtual void gradf(const vnl_vector<double>& x, vnl_vector<double>& gradient);
00034 
00035 //:  Compute one or both of f and g.  Normally implemented in terms of the above two,
00036 //  but may be faster if specialized. f != 0 => compute f
00037   virtual void compute(const vnl_vector<double>& x, double *f, vnl_vector<double>* g);
00038 
00039 //:  Return the number of unknowns
00040   int get_number_of_unknowns() const { return dim; }
00041 
00042 //:  Compute finite-difference gradient
00043   void fdgradf(const vnl_vector<double>& x, vnl_vector<double>& gradient, double stepsize = 1e-5);
00044 
00045 //:  Called when error is printed for user.
00046   virtual double reported_error(double f_value) { return f_value; }
00047 
00048 //:  Conveniences for printing grad, fdgrad
00049   vnl_vector<double> gradf(const vnl_vector<double>& x);
00050   vnl_vector<double> fdgradf(const vnl_vector<double>& x);
00051 
00052 public:
00053   int dim;
00054 };
00055 
00056 
00057 #endif // vnl_cost_function_h_

Generated at Wed Mar 12 01:13:15 2003 for ITK by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2000