00001 #ifndef __F_IterativeNonLS_H__ 00002 #define __F_IterativeNonLS_H__ 00003 00004 00029 #include <stdio.h> 00030 #include "AbsFNonLinearSolver.hpp" 00031 00032 #include "AbsFLineSearch.hpp" 00033 00034 00035 class F_IterativeNonLS : public AbsFNonLinearSolver 00036 { 00037 protected: 00038 00039 int maxIter; 00040 double eps; 00041 00042 bool converge; 00043 00044 AbsFLineSearch* lineSearch; 00045 00046 AFSymMatrix* H; // may be zero or a diagonal Matrix of the Hessian 00047 00048 protected: 00049 00050 virtual FloatVector* singleSolve(AbsFObjectiveFn* fn, FloatVector* x=0)=0; 00051 00052 public: 00053 F_IterativeNonLS(int maxIterations, double epsilon=1.0e-4) 00054 {maxIter=maxIterations; eps=epsilon; lineSearch=0; H=0;} 00055 F_IterativeNonLS(int maxIterations, AbsFLineSearch* lSearch, double epsilon=1.0e-4) 00056 {maxIter=maxIterations; eps=epsilon; lineSearch=lSearch; H=0;} 00057 virtual ~F_IterativeNonLS(){} 00058 00059 // f(A) * xnew = xold 00060 virtual FloatVector* solve(AbsFObjectiveFn* fn, FloatVector* x=0) 00061 { 00062 converge=false; 00063 00064 for(int i=0; i<maxIter; i++) 00065 { 00066 x= singleSolve(fn, x); 00067 00068 if(converge == true) 00069 break; 00070 } 00071 return x; 00072 } 00073 }; 00074 00075 #endif 00076