00001 // LeastSquaresADMinimizer.h: interface for the LeastSquaresADMinimizer class. 00002 // 00004 00005 #if !defined(AFX_LEASTSQUARESADMINIMIZER_H__B872BB8D_BEEB_412D_BDC2_43D6F067FD89__INCLUDED_) 00006 #define AFX_LEASTSQUARESADMINIMIZER_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 #include "adouble.h" 00027 #include "adutils.h" 00028 00029 using namespace std; 00030 00031 class CLeastSquaresADMinimizer : public Minimizer 00032 { 00033 public: 00034 CLeastSquaresADMinimizer(); 00035 virtual ~CLeastSquaresADMinimizer(); 00036 // Compute the Hessian and the Gradient via automatic differentiation 00037 void ComputeDerivativeInformation(double *parameters, NLLSMinimizable *nlls); 00038 // Store the diagonal elements of the Hessian 00039 void SaveDiagonal(); 00040 // returns the force matrix 00041 const double **GetForceMatrix() const {return (const double **)m_pdForceMatrix;} 00042 int GetNParameters() {return nParameters;} 00043 int GetNResiduals() {return m_iNResiduals;} 00044 //private: 00045 double m_dFuncAccuracy; // Accuracy of objective function evaluations 00046 double** m_pdAlpha; // Approximate Hessian matrix 00047 double* m_pdGrad; // Gradient (-JT.f) 00048 double* m_pdDiagonal; // Used to preserve diagonal H elements before scaling 00049 CParameterFilter *m_pFilter; // Filter for parameter rescaling 00050 double** m_pdForceMatrix; // Components of gradient (-JT.f) 00051 int m_iNResiduals; // number of residuals in NLLSMinimizable 00052 }; 00053 00054 #endif // !defined(AFX_LEASTSQUARESADMINIMIZER_H__B872BB8D_BEEB_412D_BDC2_43D6F067FD89__INCLUDED_)