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

vnl_conjugate_gradient.h

Go to the documentation of this file.
00001 #ifndef vnl_conjugate_gradient_h_
00002 #define vnl_conjugate_gradient_h_
00003 //:
00004 //  \file
00005 //  \brief  vnl_conjugate_gradient - real function minimization
00006 //  \author Geoffrey Cross, Oxford RRG, 15 Feb 99
00007 
00008 // Modifications
00009 // 990215 Geoff Initial version.
00010 // 000628 David Capel - Major rewrite. Now derived from vnl_nonlinear_minimizer
00011 //                      and operates on a vnl_cost_function.
00012 //
00013 //-----------------------------------------------------------------------------
00014 
00015 #include <vcl_iosfwd.h>
00016 #include <vnl/vnl_vector.h>
00017 #include <vnl/vnl_matrix.h>
00018 #include <vnl/vnl_nonlinear_minimizer.h>
00019 
00020 class vnl_cost_function;
00021   
00022 //: vnl_conjugate_gradient - real function minimization
00023 //  vnl_conjugate_gradient - real function minimization
00024 
00025 
00026 class vnl_conjugate_gradient : public vnl_nonlinear_minimizer {
00027 public:
00028   // Constructors/Destructors--------------------------------------------------
00029   
00030   //: Initialize with the function object that is to be minimized.
00031   vnl_conjugate_gradient(vnl_cost_function& f) { init( f); }
00032 
00033   //: Initialize as above, and then run minimization.
00034   vnl_conjugate_gradient(vnl_cost_function& f, vnl_vector<double>& x) {
00035     init(f);
00036     minimize(x);
00037   }
00038 
00039   //: Initialize all variables
00040   void init(vnl_cost_function &f);
00041 
00042   //: Destructor.
00043   ~vnl_conjugate_gradient();
00044 
00045   // Operations----------------------------------------------------------------
00046 
00047   void diagnose_outcome(vcl_ostream&) const;
00048   void diagnose_outcome(/*vcl_ostream& = vcl_cout*/) const;
00049 
00050   // Computations--------------------------------------------------------------
00051 
00052   //: Minimize the function supplied in the constructor until convergence
00053   // or failure.  On return, x is such that f(x) is the lowest value achieved.
00054   // Returns true for convergence, false for failure.
00055   bool minimize(vnl_vector<double>& x);
00056 
00057 protected:
00058   // Data Members--------------------------------------------------------------
00059 
00060   vnl_cost_function *f_;
00061   double final_step_size_;
00062 
00063   // Helpers-------------------------------------------------------------------
00064 
00065   friend class vnl_conjugate_gradient_Activate;
00066 #ifdef VCL_SUNPRO_CC
00067 public:
00068 #endif
00069   static double valuecomputer_( double *x);
00070   static int gradientcomputer_( double *g, double *x);
00071   static int valueandgradientcomputer_( double *v, double *g, double *x);
00072   static int preconditioner_( double *out, double *in);
00073 #ifdef VCL_SUNPRO_CC
00074 protected:
00075 #endif
00076 //   void approximate_gradient( const vnl_vector<double> &x, 
00077 //          vnl_vector<double> &g, const double step);
00078 //   void approximate_hessian( const vnl_vector<double> &x,
00079 //          vnl_matrix<double> &h, const double step);
00080 };
00081 
00082 #endif // vnl_conjugate_gradient_h_

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