Go to the documentation of this file.00001
00002 #ifndef vnl_conjugate_gradient_h_
00003 #define vnl_conjugate_gradient_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <vcl_iosfwd.h>
00023 #include <vnl/vnl_vector.h>
00024 #include <vnl/vnl_matrix.h>
00025 #include <vnl/vnl_nonlinear_minimizer.h>
00026
00027 class vnl_cost_function;
00028
00029
00030
00031 class vnl_conjugate_gradient : public vnl_nonlinear_minimizer
00032 {
00033 public:
00034
00035
00036
00037 vnl_conjugate_gradient(vnl_cost_function& f) { init( f); }
00038
00039
00040 vnl_conjugate_gradient(vnl_cost_function& f, vnl_vector<double>& x) {
00041 init(f);
00042 minimize(x);
00043 }
00044
00045
00046 void init(vnl_cost_function &f);
00047
00048
00049 ~vnl_conjugate_gradient();
00050
00051
00052
00053 void diagnose_outcome(vcl_ostream&) const;
00054 void diagnose_outcome() const;
00055
00056
00057
00058
00059
00060
00061 bool minimize(vnl_vector<double>& x);
00062
00063 protected:
00064
00065
00066 vnl_cost_function *f_;
00067 double final_step_size_;
00068
00069
00070
00071 #ifdef VCL_SUNPRO_CC
00072 public:
00073 #endif
00074 static double valuecomputer_( double *x, void* userdata);
00075 static void gradientcomputer_( double *g, double *x, void* userdata);
00076 static void valueandgradientcomputer_( double *v, double *g, double *x, void* userdata);
00077 static void preconditioner_( double *out, double *in, void* userdata);
00078
00079 #if 0
00080 protected:
00081 void approximate_gradient( const vnl_vector<double> &x,
00082 vnl_vector<double> &g, const double step);
00083 void approximate_hessian( const vnl_vector<double> &x,
00084 vnl_matrix<double> &h, const double step);
00085 #endif
00086 };
00087
00088 #endif // vnl_conjugate_gradient_h_