Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
LevenbergMarquardtHelper.hh
1 #ifndef __LevenbergMarquardtHelper_hh__
2 #define __LevenbergMarquardtHelper_hh__
3 
4 #include <bias_config.h>
5 
6 namespace BIAS
7 {
8  /**
9  @class LevenbergMarquardtHelper
10  @brief Simple helper class for Levenberg-Marquardt optimization.
11 
12  This class keep track of the best solution computed by a Levenberg-
13  Marquardt optimization.
14  */
15  class BIASMathAlgo_EXPORT LevenbergMarquardtHelper
16  {
17  public:
18 
19  /** @brief Create empty instance.
20  @note Call Init() to provide the number of variables and residuals! */
22 
23  /** @brief Create new instance for given number of variables and
24  objective function residuals. */
25  LevenbergMarquardtHelper(int numVars, int numResiduals);
26 
27  /** @brief Releases the internally stored best variables. */
29 
30  /** @brief Relocates internal array of best variables and resets the
31  best solution. */
32  void Init(int numVars, int numResiduals);
33 
34  /** @brief Add variables and results, and computes the sum of squares.
35  @return Returns if the new solution is better than the one stored. */
36  bool Update(const double *x, const double *fvec);
37 
38  /** @brief Returns pointer to internal array of best variables.
39  @note Returned pointer must NOT be released! */
40  inline double* GetBestVars() const { return vars_; }
41 
42  protected:
43 
44  double *vars_;
45  double sumOfSquares_;
46  int numVars_, numResiduals_;
47 
48  };
49 
50 }
51 
52 #endif // __LevenbergMarquardtHelper_hh__
Simple helper class for Levenberg-Marquardt optimization.
double * GetBestVars() const
Returns pointer to internal array of best variables.