00001 // LeastSquaresMinimizer.h: interface for the LeastSquaresMinimizer class. 00002 // 00004 00005 #if !defined(AFX_LEASTSQUARESMINIMIZER_H__B872BB8D_BEEB_412D_BDC2_43D6F067FD89__INCLUDED_) 00006 #define AFX_LEASTSQUARESMINIMIZER_H__B872BB8D_BEEB_412D_BDC2_43D6F067FD89__INCLUDED_ 00007 00008 #if _MSC_VER > 1000 00009 #pragma once 00010 #endif // _MSC_VER > 1000 00011 00012 #ifdef _WIN32 00013 #include <mkl.h> 00014 #else 00015 #include "lapack.h" 00016 #endif 00017 00018 #include <iostream> 00019 #include <fstream> 00020 #include <cmath> 00021 #include <cfloat> 00022 #include <assert.h> 00023 #include "Minimizer.h" 00024 #include "NLLSMinimizable.h" 00025 #include "ParameterFilter.h" 00026 using namespace std; 00027 00028 class CLeastSquaresMinimizer : public Minimizer 00029 { 00030 public: 00031 CLeastSquaresMinimizer(); 00032 virtual ~CLeastSquaresMinimizer(); 00033 // Compute the Hessian and the Gradient via numerical differentiation 00034 void ComputeDerivativeInformation(double *parameters, NLLSMinimizable *nlls); 00035 // Store the diagonal elements of the Hessian 00036 void SaveDiagonal(); 00037 // returns the force matrix 00038 const double **GetForceMatrix() const {return (const double **)m_pdForceMatrix;} 00039 int GetNParameters() {return nParameters;} 00040 int GetNResiduals() {return m_iNResiduals;} 00041 //private: 00042 double m_dFuncAccuracy; // Accuracy of objective function evaluations 00043 double** m_pdAlpha; // Approximate Hessian matrix 00044 double* m_pdGrad; // Gradient (-JT.f) 00045 double* m_pdDiagonal; // Used to preserve diagonal H elements before scaling 00046 CParameterFilter *m_pFilter; // Filter for parameter rescaling 00047 double** m_pdForceMatrix; // Components of gradient (-JT.f) 00048 int m_iNResiduals; // number of residuals in NLLSMinimizable 00049 }; 00050 00051 #endif // !defined(AFX_LEASTSQUARESMINIMIZER_H__B872BB8D_BEEB_412D_BDC2_43D6F067FD89__INCLUDED_)