Tron.h
Go to the documentation of this file.00001 #ifndef _CTron_H
00002 #define _CTron_H
00003
00004 #include "lib/config.h"
00005
00006 #ifdef HAVE_LAPACK
00007 #include "base/SGObject.h"
00008
00010 class function
00011 {
00012 public:
00020 virtual double fun(double *w) = 0 ;
00021
00029 virtual void grad(double *w, double *g) = 0 ;
00030
00038 virtual void Hv(double *s, double *Hs) = 0 ;
00039
00046 virtual int get_nr_variable(void) = 0 ;
00047
00048 virtual ~function(void){}
00049 };
00050
00052 class CTron : public CSGObject
00053 {
00054 public:
00061 CTron(const function *fun_obj, double eps = 0.1, int max_iter = 1000);
00062 ~CTron();
00063
00068 void tron(double *w);
00069
00070 private:
00071 int trcg(double delta, double *g, double *s, double *r);
00072 double norm_inf(int n, double *x);
00073
00074 double eps;
00075 int max_iter;
00076 function *fun_obj;
00077 };
00078
00079 #endif
00080 #endif //HAVE_LAPACK