casacore
NonLinearFitLM.h
Go to the documentation of this file.
1 //# NonLinearFitLM.h: Solve non-linear fit using Levenberg-Marquardt method.
2 //# Copyright (C) 1995,1999-2002,2004,2006
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //#
27 //# $Id$
28 
29 #ifndef SCIMATH_NONLINEARFITLM_H
30 #define SCIMATH_NONLINEARFITLM_H
31 
32 //# Includes
33 #include <casacore/casa/aips.h>
34 #include <casacore/scimath/Fitting/NonLinearFit.h>
35 namespace casacore { //# begin namespace casa
36 //# Forward declarations
37 
38 //
39 // <summary>
40 // Solve non-linear fit with Levenberg-Marquardt method.
41 // </summary>
42 //
43 // <reviewed reviewer="wbrouw" date="2004/06/15" tests="tNonLinearFitLM.cc"
44 // demos="">
45 // </reviewed>
46 //
47 // <prerequisite>
48 // <li> <linkto class="NonLinearFit">NonLinearFit</linkto>
49 // <li> <linkto module="Fitting">Fitting</linkto>
50 // </prerequisite>
51 //
52 // <etymology>
53 // This class uses the Levenberg-Marquardt method to solve the non-linear
54 // least-squares fit problem hence NonLinearFitLM
55 // </etymology>
56 //
57 // <synopsis>
58 // NOTE: Constraints added. Documentation out of date at moment, check
59 // the tLinearFitSVD and tNonLinearFirLM programs for examples.
60 //
61 // See the <linkto class=NonLinearFit>NonLinearFit</linkto> class for a
62 // general description.
63 //
64 // This class is derived from the general NonLinearFit class. It does
65 // a non-linear least-squares fit using the Levenberg-Marquardt method.
66 //
67 // See Numerical Recipes for more information
68 // on the Levenberg-Marquardt method.
69 // </synopsis>
70 //
71 // <templating arg=T>
72 // <li> Float
73 // <li> Double
74 // <li> Complex
75 // <li> DComplex
76 // </templating>
77 //
78 // <motivation>
79 // Levenberg-Marquardt method is a standard method for non-linear
80 // least-squares fits. It works well in practice over a wide range of
81 // problems.
82 // </motivation>
83 //
84 // <example>
85 // </example>
86 
87 template<class T> class NonLinearFitLM : public NonLinearFit<T>
88 {
89 public:
90  //# Constructors
91  // Create a fitter: the normal way to generate a fitter object. Necessary
92  // data will be deduced from the Functional provided with
93  // <src>setFunction()</src>.
94  // Optionally, a fitter with SVD behaviour
95  explicit NonLinearFitLM(Bool svd=False);
96  // Copy constructor (deep copy)
98  // Assignment (deep copy)
100 
101  // Destructor
102  virtual ~NonLinearFitLM();
103 
104 protected:
105  //# Member functions
106  // Generalised fitter
107  virtual Bool fitIt
109  const Array<typename FunctionTraits<T>::BaseType> &x,
110  const Vector<typename FunctionTraits<T>::BaseType> &y,
111  const Vector<typename FunctionTraits<T>::BaseType> *const sigma,
112  const Vector<Bool> *const mask=0);
113 
114 private:
115  //# Data
116  // The parameter that makes this the Levenberg-Marquardt method.
118  // The current fit state
120 
121 protected:
122  //# Make members of parent classes known.
130  using NonLinearFit<T>::nr_p;
140 };
141 
142 } //# End namespace casacore
143 #ifndef CASACORE_NO_AUTO_TEMPLATES
144 #include <casacore/scimath/Fitting/NonLinearFitLM.tcc>
145 #endif //# CASACORE_NO_AUTO_TEMPLATES
146 #endif
T BaseType
Template base type.
static const String sol
Definition: LSQFit.h:857
Double fitit_p
The current fit state.
Double lamda_p
The parameter that makes this the Levenberg-Marquardt method.
NonLinearFitLM(Bool svd=False)
Create a fitter: the normal way to generate a fitter object.
virtual Bool fitIt(Vector< typename FunctionTraits< T >::BaseType > &sol, const Array< typename FunctionTraits< T >::BaseType > &x, const Vector< typename FunctionTraits< T >::BaseType > &y, const Vector< typename FunctionTraits< T >::BaseType > *const sigma, const Vector< Bool > *const mask=0)
Generalised fitter.
virtual ~NonLinearFitLM()
Destructor.
NonLinearFitLM & operator=(const NonLinearFitLM &other)
Assignment (deep copy)
NonLinearFitLM(const NonLinearFitLM &other)
Copy constructor (deep copy)
this file contains all the compiler specific defines
Definition: mainpage.dox:28
const Bool False
Definition: aipstype.h:44
LatticeExprNode mask(const LatticeExprNode &expr)
This function returns the mask of the given expression.
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
double Double
Definition: aipstype.h:55